documentation.d.ts 3.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909
  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. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * 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.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * 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).
  166. * 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.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @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.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** 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 */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** 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 */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** 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 */
  695. static readonly GEQUAL: number;
  696. /** 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 */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * 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.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. 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>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. 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;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. 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;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. 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;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Interface for the size containing width and height
  1617. */
  1618. export interface ISize {
  1619. /**
  1620. * Width
  1621. */
  1622. width: number;
  1623. /**
  1624. * Heighht
  1625. */
  1626. height: number;
  1627. }
  1628. /**
  1629. * Size containing widht and height
  1630. */
  1631. export class Size implements ISize {
  1632. /**
  1633. * Width
  1634. */
  1635. width: number;
  1636. /**
  1637. * Height
  1638. */
  1639. height: number;
  1640. /**
  1641. * Creates a Size object from the given width and height (floats).
  1642. * @param width width of the new size
  1643. * @param height height of the new size
  1644. */
  1645. constructor(width: number, height: number);
  1646. /**
  1647. * Returns a string with the Size width and height
  1648. * @returns a string with the Size width and height
  1649. */
  1650. toString(): string;
  1651. /**
  1652. * "Size"
  1653. * @returns the string "Size"
  1654. */
  1655. getClassName(): string;
  1656. /**
  1657. * Returns the Size hash code.
  1658. * @returns a hash code for a unique width and height
  1659. */
  1660. getHashCode(): number;
  1661. /**
  1662. * Updates the current size from the given one.
  1663. * @param src the given size
  1664. */
  1665. copyFrom(src: Size): void;
  1666. /**
  1667. * Updates in place the current Size from the given floats.
  1668. * @param width width of the new size
  1669. * @param height height of the new size
  1670. * @returns the updated Size.
  1671. */
  1672. copyFromFloats(width: number, height: number): Size;
  1673. /**
  1674. * Updates in place the current Size from the given floats.
  1675. * @param width width to set
  1676. * @param height height to set
  1677. * @returns the updated Size.
  1678. */
  1679. set(width: number, height: number): Size;
  1680. /**
  1681. * Multiplies the width and height by numbers
  1682. * @param w factor to multiple the width by
  1683. * @param h factor to multiple the height by
  1684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1685. */
  1686. multiplyByFloats(w: number, h: number): Size;
  1687. /**
  1688. * Clones the size
  1689. * @returns a new Size copied from the given one.
  1690. */
  1691. clone(): Size;
  1692. /**
  1693. * True if the current Size and the given one width and height are strictly equal.
  1694. * @param other the other size to compare against
  1695. * @returns True if the current Size and the given one width and height are strictly equal.
  1696. */
  1697. equals(other: Size): boolean;
  1698. /**
  1699. * The surface of the Size : width * height (float).
  1700. */
  1701. get surface(): number;
  1702. /**
  1703. * Create a new size of zero
  1704. * @returns a new Size set to (0.0, 0.0)
  1705. */
  1706. static Zero(): Size;
  1707. /**
  1708. * Sums the width and height of two sizes
  1709. * @param otherSize size to add to this size
  1710. * @returns a new Size set as the addition result of the current Size and the given one.
  1711. */
  1712. add(otherSize: Size): Size;
  1713. /**
  1714. * Subtracts the width and height of two
  1715. * @param otherSize size to subtract to this size
  1716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1717. */
  1718. subtract(otherSize: Size): Size;
  1719. /**
  1720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1721. * @param start starting size to lerp between
  1722. * @param end end size to lerp between
  1723. * @param amount amount to lerp between the start and end values
  1724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1725. */
  1726. static Lerp(start: Size, end: Size, amount: number): Size;
  1727. }
  1728. }
  1729. declare module BABYLON {
  1730. /**
  1731. * Base class of all the textures in babylon.
  1732. * It groups all the common properties required to work with Thin Engine.
  1733. */
  1734. export class ThinTexture {
  1735. protected _wrapU: number;
  1736. /**
  1737. * | Value | Type | Description |
  1738. * | ----- | ------------------ | ----------- |
  1739. * | 0 | CLAMP_ADDRESSMODE | |
  1740. * | 1 | WRAP_ADDRESSMODE | |
  1741. * | 2 | MIRROR_ADDRESSMODE | |
  1742. */
  1743. get wrapU(): number;
  1744. set wrapU(value: number);
  1745. protected _wrapV: number;
  1746. /**
  1747. * | Value | Type | Description |
  1748. * | ----- | ------------------ | ----------- |
  1749. * | 0 | CLAMP_ADDRESSMODE | |
  1750. * | 1 | WRAP_ADDRESSMODE | |
  1751. * | 2 | MIRROR_ADDRESSMODE | |
  1752. */
  1753. get wrapV(): number;
  1754. set wrapV(value: number);
  1755. /**
  1756. * | Value | Type | Description |
  1757. * | ----- | ------------------ | ----------- |
  1758. * | 0 | CLAMP_ADDRESSMODE | |
  1759. * | 1 | WRAP_ADDRESSMODE | |
  1760. * | 2 | MIRROR_ADDRESSMODE | |
  1761. */
  1762. wrapR: number;
  1763. /**
  1764. * With compliant hardware and browser (supporting anisotropic filtering)
  1765. * this defines the level of anisotropic filtering in the texture.
  1766. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1767. */
  1768. anisotropicFilteringLevel: number;
  1769. /**
  1770. * Define the current state of the loading sequence when in delayed load mode.
  1771. */
  1772. delayLoadState: number;
  1773. /**
  1774. * How a texture is mapped.
  1775. * Unused in thin texture mode.
  1776. */
  1777. get coordinatesMode(): number;
  1778. /**
  1779. * Define if the texture is a cube texture or if false a 2d texture.
  1780. */
  1781. get isCube(): boolean;
  1782. set isCube(value: boolean);
  1783. /**
  1784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1785. */
  1786. get is3D(): boolean;
  1787. set is3D(value: boolean);
  1788. /**
  1789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1790. */
  1791. get is2DArray(): boolean;
  1792. set is2DArray(value: boolean);
  1793. /**
  1794. * Get the class name of the texture.
  1795. * @returns "ThinTexture"
  1796. */
  1797. getClassName(): string;
  1798. /** @hidden */
  1799. _texture: Nullable<InternalTexture>;
  1800. protected _engine: Nullable<ThinEngine>;
  1801. private _cachedSize;
  1802. private _cachedBaseSize;
  1803. /**
  1804. * Instantiates a new ThinTexture.
  1805. * Base class of all the textures in babylon.
  1806. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1807. * @param internalTexture Define the internalTexture to wrap
  1808. */
  1809. constructor(internalTexture: Nullable<InternalTexture>);
  1810. /**
  1811. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1812. * @returns true if fully ready
  1813. */
  1814. isReady(): boolean;
  1815. /**
  1816. * Triggers the load sequence in delayed load mode.
  1817. */
  1818. delayLoad(): void;
  1819. /**
  1820. * Get the underlying lower level texture from Babylon.
  1821. * @returns the insternal texture
  1822. */
  1823. getInternalTexture(): Nullable<InternalTexture>;
  1824. /**
  1825. * Get the size of the texture.
  1826. * @returns the texture size.
  1827. */
  1828. getSize(): ISize;
  1829. /**
  1830. * Get the base size of the texture.
  1831. * It can be different from the size if the texture has been resized for POT for instance
  1832. * @returns the base size
  1833. */
  1834. getBaseSize(): ISize;
  1835. /**
  1836. * Update the sampling mode of the texture.
  1837. * Default is Trilinear mode.
  1838. *
  1839. * | Value | Type | Description |
  1840. * | ----- | ------------------ | ----------- |
  1841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1847. * | 7 | NEAREST_LINEAR | |
  1848. * | 8 | NEAREST_NEAREST | |
  1849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1851. * | 11 | LINEAR_LINEAR | |
  1852. * | 12 | LINEAR_NEAREST | |
  1853. *
  1854. * > _mag_: magnification filter (close to the viewer)
  1855. * > _min_: minification filter (far from the viewer)
  1856. * > _mip_: filter used between mip map levels
  1857. *@param samplingMode Define the new sampling mode of the texture
  1858. */
  1859. updateSamplingMode(samplingMode: number): void;
  1860. /**
  1861. * Release and destroy the underlying lower level texture aka internalTexture.
  1862. */
  1863. releaseInternalTexture(): void;
  1864. /**
  1865. * Dispose the texture and release its associated resources.
  1866. */
  1867. dispose(): void;
  1868. }
  1869. }
  1870. declare module BABYLON {
  1871. /**
  1872. * Defines an array and its length.
  1873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1874. */
  1875. export interface ISmartArrayLike<T> {
  1876. /**
  1877. * The data of the array.
  1878. */
  1879. data: Array<T>;
  1880. /**
  1881. * The active length of the array.
  1882. */
  1883. length: number;
  1884. }
  1885. /**
  1886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1887. */
  1888. export class SmartArray<T> implements ISmartArrayLike<T> {
  1889. /**
  1890. * The full set of data from the array.
  1891. */
  1892. data: Array<T>;
  1893. /**
  1894. * The active length of the array.
  1895. */
  1896. length: number;
  1897. protected _id: number;
  1898. /**
  1899. * Instantiates a Smart Array.
  1900. * @param capacity defines the default capacity of the array.
  1901. */
  1902. constructor(capacity: number);
  1903. /**
  1904. * Pushes a value at the end of the active data.
  1905. * @param value defines the object to push in the array.
  1906. */
  1907. push(value: T): void;
  1908. /**
  1909. * Iterates over the active data and apply the lambda to them.
  1910. * @param func defines the action to apply on each value.
  1911. */
  1912. forEach(func: (content: T) => void): void;
  1913. /**
  1914. * Sorts the full sets of data.
  1915. * @param compareFn defines the comparison function to apply.
  1916. */
  1917. sort(compareFn: (a: T, b: T) => number): void;
  1918. /**
  1919. * Resets the active data to an empty array.
  1920. */
  1921. reset(): void;
  1922. /**
  1923. * Releases all the data from the array as well as the array.
  1924. */
  1925. dispose(): void;
  1926. /**
  1927. * Concats the active data with a given array.
  1928. * @param array defines the data to concatenate with.
  1929. */
  1930. concat(array: any): void;
  1931. /**
  1932. * Returns the position of a value in the active data.
  1933. * @param value defines the value to find the index for
  1934. * @returns the index if found in the active data otherwise -1
  1935. */
  1936. indexOf(value: T): number;
  1937. /**
  1938. * Returns whether an element is part of the active data.
  1939. * @param value defines the value to look for
  1940. * @returns true if found in the active data otherwise false
  1941. */
  1942. contains(value: T): boolean;
  1943. private static _GlobalId;
  1944. }
  1945. /**
  1946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1947. * The data in this array can only be present once
  1948. */
  1949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1950. private _duplicateId;
  1951. /**
  1952. * Pushes a value at the end of the active data.
  1953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1954. * @param value defines the object to push in the array.
  1955. */
  1956. push(value: T): void;
  1957. /**
  1958. * Pushes a value at the end of the active data.
  1959. * If the data is already present, it won t be added again
  1960. * @param value defines the object to push in the array.
  1961. * @returns true if added false if it was already present
  1962. */
  1963. pushNoDuplicate(value: T): boolean;
  1964. /**
  1965. * Resets the active data to an empty array.
  1966. */
  1967. reset(): void;
  1968. /**
  1969. * Concats the active data with a given array.
  1970. * This ensures no dupplicate will be present in the result.
  1971. * @param array defines the data to concatenate with.
  1972. */
  1973. concatWithNoDuplicate(array: any): void;
  1974. }
  1975. }
  1976. declare module BABYLON {
  1977. /**
  1978. * Class used to evalaute queries containing `and` and `or` operators
  1979. */
  1980. export class AndOrNotEvaluator {
  1981. /**
  1982. * Evaluate a query
  1983. * @param query defines the query to evaluate
  1984. * @param evaluateCallback defines the callback used to filter result
  1985. * @returns true if the query matches
  1986. */
  1987. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1988. private static _HandleParenthesisContent;
  1989. private static _SimplifyNegation;
  1990. }
  1991. }
  1992. declare module BABYLON {
  1993. /**
  1994. * Class used to store custom tags
  1995. */
  1996. export class Tags {
  1997. /**
  1998. * Adds support for tags on the given object
  1999. * @param obj defines the object to use
  2000. */
  2001. static EnableFor(obj: any): void;
  2002. /**
  2003. * Removes tags support
  2004. * @param obj defines the object to use
  2005. */
  2006. static DisableFor(obj: any): void;
  2007. /**
  2008. * Gets a boolean indicating if the given object has tags
  2009. * @param obj defines the object to use
  2010. * @returns a boolean
  2011. */
  2012. static HasTags(obj: any): boolean;
  2013. /**
  2014. * Gets the tags available on a given object
  2015. * @param obj defines the object to use
  2016. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2017. * @returns the tags
  2018. */
  2019. static GetTags(obj: any, asString?: boolean): any;
  2020. /**
  2021. * Adds tags to an object
  2022. * @param obj defines the object to use
  2023. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2024. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2025. */
  2026. static AddTagsTo(obj: any, tagsString: string): void;
  2027. /**
  2028. * @hidden
  2029. */
  2030. static _AddTagTo(obj: any, tag: string): void;
  2031. /**
  2032. * Removes specific tags from a specific object
  2033. * @param obj defines the object to use
  2034. * @param tagsString defines the tags to remove
  2035. */
  2036. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2037. /**
  2038. * @hidden
  2039. */
  2040. static _RemoveTagFrom(obj: any, tag: string): void;
  2041. /**
  2042. * Defines if tags hosted on an object match a given query
  2043. * @param obj defines the object to use
  2044. * @param tagsQuery defines the tag query
  2045. * @returns a boolean
  2046. */
  2047. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2048. }
  2049. }
  2050. declare module BABYLON {
  2051. /**
  2052. * Scalar computation library
  2053. */
  2054. export class Scalar {
  2055. /**
  2056. * Two pi constants convenient for computation.
  2057. */
  2058. static TwoPi: number;
  2059. /**
  2060. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2061. * @param a number
  2062. * @param b number
  2063. * @param epsilon (default = 1.401298E-45)
  2064. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2065. */
  2066. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2067. /**
  2068. * Returns a string : the upper case translation of the number i to hexadecimal.
  2069. * @param i number
  2070. * @returns the upper case translation of the number i to hexadecimal.
  2071. */
  2072. static ToHex(i: number): string;
  2073. /**
  2074. * Returns -1 if value is negative and +1 is value is positive.
  2075. * @param value the value
  2076. * @returns the value itself if it's equal to zero.
  2077. */
  2078. static Sign(value: number): number;
  2079. /**
  2080. * Returns the value itself if it's between min and max.
  2081. * Returns min if the value is lower than min.
  2082. * Returns max if the value is greater than max.
  2083. * @param value the value to clmap
  2084. * @param min the min value to clamp to (default: 0)
  2085. * @param max the max value to clamp to (default: 1)
  2086. * @returns the clamped value
  2087. */
  2088. static Clamp(value: number, min?: number, max?: number): number;
  2089. /**
  2090. * the log2 of value.
  2091. * @param value the value to compute log2 of
  2092. * @returns the log2 of value.
  2093. */
  2094. static Log2(value: number): number;
  2095. /**
  2096. * Loops the value, so that it is never larger than length and never smaller than 0.
  2097. *
  2098. * This is similar to the modulo operator but it works with floating point numbers.
  2099. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2100. * With t = 5 and length = 2.5, the result would be 0.0.
  2101. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2102. * @param value the value
  2103. * @param length the length
  2104. * @returns the looped value
  2105. */
  2106. static Repeat(value: number, length: number): number;
  2107. /**
  2108. * Normalize the value between 0.0 and 1.0 using min and max values
  2109. * @param value value to normalize
  2110. * @param min max to normalize between
  2111. * @param max min to normalize between
  2112. * @returns the normalized value
  2113. */
  2114. static Normalize(value: number, min: number, max: number): number;
  2115. /**
  2116. * Denormalize the value from 0.0 and 1.0 using min and max values
  2117. * @param normalized value to denormalize
  2118. * @param min max to denormalize between
  2119. * @param max min to denormalize between
  2120. * @returns the denormalized value
  2121. */
  2122. static Denormalize(normalized: number, min: number, max: number): number;
  2123. /**
  2124. * Calculates the shortest difference between two given angles given in degrees.
  2125. * @param current current angle in degrees
  2126. * @param target target angle in degrees
  2127. * @returns the delta
  2128. */
  2129. static DeltaAngle(current: number, target: number): number;
  2130. /**
  2131. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2132. * @param tx value
  2133. * @param length length
  2134. * @returns The returned value will move back and forth between 0 and length
  2135. */
  2136. static PingPong(tx: number, length: number): number;
  2137. /**
  2138. * Interpolates between min and max with smoothing at the limits.
  2139. *
  2140. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2141. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2142. * @param from from
  2143. * @param to to
  2144. * @param tx value
  2145. * @returns the smooth stepped value
  2146. */
  2147. static SmoothStep(from: number, to: number, tx: number): number;
  2148. /**
  2149. * Moves a value current towards target.
  2150. *
  2151. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2152. * Negative values of maxDelta pushes the value away from target.
  2153. * @param current current value
  2154. * @param target target value
  2155. * @param maxDelta max distance to move
  2156. * @returns resulting value
  2157. */
  2158. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2159. /**
  2160. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2161. *
  2162. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2163. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2164. * @param current current value
  2165. * @param target target value
  2166. * @param maxDelta max distance to move
  2167. * @returns resulting angle
  2168. */
  2169. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2170. /**
  2171. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2172. * @param start start value
  2173. * @param end target value
  2174. * @param amount amount to lerp between
  2175. * @returns the lerped value
  2176. */
  2177. static Lerp(start: number, end: number, amount: number): number;
  2178. /**
  2179. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2180. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2181. * @param start start value
  2182. * @param end target value
  2183. * @param amount amount to lerp between
  2184. * @returns the lerped value
  2185. */
  2186. static LerpAngle(start: number, end: number, amount: number): number;
  2187. /**
  2188. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2189. * @param a start value
  2190. * @param b target value
  2191. * @param value value between a and b
  2192. * @returns the inverseLerp value
  2193. */
  2194. static InverseLerp(a: number, b: number, value: number): number;
  2195. /**
  2196. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2197. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2198. * @param value1 spline value
  2199. * @param tangent1 spline value
  2200. * @param value2 spline value
  2201. * @param tangent2 spline value
  2202. * @param amount input value
  2203. * @returns hermite result
  2204. */
  2205. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2206. /**
  2207. * Returns a random float number between and min and max values
  2208. * @param min min value of random
  2209. * @param max max value of random
  2210. * @returns random value
  2211. */
  2212. static RandomRange(min: number, max: number): number;
  2213. /**
  2214. * This function returns percentage of a number in a given range.
  2215. *
  2216. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2217. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2218. * @param number to convert to percentage
  2219. * @param min min range
  2220. * @param max max range
  2221. * @returns the percentage
  2222. */
  2223. static RangeToPercent(number: number, min: number, max: number): number;
  2224. /**
  2225. * This function returns number that corresponds to the percentage in a given range.
  2226. *
  2227. * PercentToRange(0.34,0,100) will return 34.
  2228. * @param percent to convert to number
  2229. * @param min min range
  2230. * @param max max range
  2231. * @returns the number
  2232. */
  2233. static PercentToRange(percent: number, min: number, max: number): number;
  2234. /**
  2235. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2236. * @param angle The angle to normalize in radian.
  2237. * @return The converted angle.
  2238. */
  2239. static NormalizeRadians(angle: number): number;
  2240. }
  2241. }
  2242. declare module BABYLON {
  2243. /**
  2244. * Constant used to convert a value to gamma space
  2245. * @ignorenaming
  2246. */
  2247. export const ToGammaSpace: number;
  2248. /**
  2249. * Constant used to convert a value to linear space
  2250. * @ignorenaming
  2251. */
  2252. export const ToLinearSpace = 2.2;
  2253. /**
  2254. * Constant used to define the minimal number value in Babylon.js
  2255. * @ignorenaming
  2256. */
  2257. let Epsilon: number;
  2258. }
  2259. declare module BABYLON {
  2260. /**
  2261. * Class used to represent a viewport on screen
  2262. */
  2263. export class Viewport {
  2264. /** viewport left coordinate */
  2265. x: number;
  2266. /** viewport top coordinate */
  2267. y: number;
  2268. /**viewport width */
  2269. width: number;
  2270. /** viewport height */
  2271. height: number;
  2272. /**
  2273. * Creates a Viewport object located at (x, y) and sized (width, height)
  2274. * @param x defines viewport left coordinate
  2275. * @param y defines viewport top coordinate
  2276. * @param width defines the viewport width
  2277. * @param height defines the viewport height
  2278. */
  2279. constructor(
  2280. /** viewport left coordinate */
  2281. x: number,
  2282. /** viewport top coordinate */
  2283. y: number,
  2284. /**viewport width */
  2285. width: number,
  2286. /** viewport height */
  2287. height: number);
  2288. /**
  2289. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2290. * @param renderWidth defines the rendering width
  2291. * @param renderHeight defines the rendering height
  2292. * @returns a new Viewport
  2293. */
  2294. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2295. /**
  2296. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2297. * @param renderWidth defines the rendering width
  2298. * @param renderHeight defines the rendering height
  2299. * @param ref defines the target viewport
  2300. * @returns the current viewport
  2301. */
  2302. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2303. /**
  2304. * Returns a new Viewport copied from the current one
  2305. * @returns a new Viewport
  2306. */
  2307. clone(): Viewport;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. /**
  2312. * Class containing a set of static utilities functions for arrays.
  2313. */
  2314. export class ArrayTools {
  2315. /**
  2316. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2317. * @param size the number of element to construct and put in the array
  2318. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2319. * @returns a new array filled with new objects
  2320. */
  2321. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2322. }
  2323. }
  2324. declare module BABYLON {
  2325. /**
  2326. * Represents a plane by the equation ax + by + cz + d = 0
  2327. */
  2328. export class Plane {
  2329. private static _TmpMatrix;
  2330. /**
  2331. * Normal of the plane (a,b,c)
  2332. */
  2333. normal: Vector3;
  2334. /**
  2335. * d component of the plane
  2336. */
  2337. d: number;
  2338. /**
  2339. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2340. * @param a a component of the plane
  2341. * @param b b component of the plane
  2342. * @param c c component of the plane
  2343. * @param d d component of the plane
  2344. */
  2345. constructor(a: number, b: number, c: number, d: number);
  2346. /**
  2347. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2348. */
  2349. asArray(): number[];
  2350. /**
  2351. * @returns a new plane copied from the current Plane.
  2352. */
  2353. clone(): Plane;
  2354. /**
  2355. * @returns the string "Plane".
  2356. */
  2357. getClassName(): string;
  2358. /**
  2359. * @returns the Plane hash code.
  2360. */
  2361. getHashCode(): number;
  2362. /**
  2363. * Normalize the current Plane in place.
  2364. * @returns the updated Plane.
  2365. */
  2366. normalize(): Plane;
  2367. /**
  2368. * Applies a transformation the plane and returns the result
  2369. * @param transformation the transformation matrix to be applied to the plane
  2370. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2371. */
  2372. transform(transformation: DeepImmutable<Matrix>): Plane;
  2373. /**
  2374. * Compute the dot product between the point and the plane normal
  2375. * @param point point to calculate the dot product with
  2376. * @returns the dot product (float) of the point coordinates and the plane normal.
  2377. */
  2378. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2379. /**
  2380. * Updates the current Plane from the plane defined by the three given points.
  2381. * @param point1 one of the points used to contruct the plane
  2382. * @param point2 one of the points used to contruct the plane
  2383. * @param point3 one of the points used to contruct the plane
  2384. * @returns the updated Plane.
  2385. */
  2386. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2387. /**
  2388. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2389. * Note that for this function to work as expected you should make sure that:
  2390. * - direction and the plane normal are normalized
  2391. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2392. * @param direction the direction to check if the plane is facing
  2393. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2394. * @returns True if the plane is facing the given direction
  2395. */
  2396. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2397. /**
  2398. * Calculates the distance to a point
  2399. * @param point point to calculate distance to
  2400. * @returns the signed distance (float) from the given point to the Plane.
  2401. */
  2402. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2403. /**
  2404. * Creates a plane from an array
  2405. * @param array the array to create a plane from
  2406. * @returns a new Plane from the given array.
  2407. */
  2408. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2409. /**
  2410. * Creates a plane from three points
  2411. * @param point1 point used to create the plane
  2412. * @param point2 point used to create the plane
  2413. * @param point3 point used to create the plane
  2414. * @returns a new Plane defined by the three given points.
  2415. */
  2416. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2417. /**
  2418. * Creates a plane from an origin point and a normal
  2419. * @param origin origin of the plane to be constructed
  2420. * @param normal normal of the plane to be constructed
  2421. * @returns a new Plane the normal vector to this plane at the given origin point.
  2422. * Note : the vector "normal" is updated because normalized.
  2423. */
  2424. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2425. /**
  2426. * Calculates the distance from a plane and a point
  2427. * @param origin origin of the plane to be constructed
  2428. * @param normal normal of the plane to be constructed
  2429. * @param point point to calculate distance to
  2430. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2431. */
  2432. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2433. }
  2434. }
  2435. declare module BABYLON {
  2436. /** @hidden */
  2437. export class PerformanceConfigurator {
  2438. /** @hidden */
  2439. static MatrixUse64Bits: boolean;
  2440. /** @hidden */
  2441. static MatrixTrackPrecisionChange: boolean;
  2442. /** @hidden */
  2443. static MatrixCurrentType: any;
  2444. /** @hidden */
  2445. static MatrixTrackedMatrices: Array<any> | null;
  2446. /** @hidden */
  2447. static SetMatrixPrecision(use64bits: boolean): void;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. /**
  2452. * Class representing a vector containing 2 coordinates
  2453. */
  2454. export class Vector2 {
  2455. /** defines the first coordinate */
  2456. x: number;
  2457. /** defines the second coordinate */
  2458. y: number;
  2459. /**
  2460. * Creates a new Vector2 from the given x and y coordinates
  2461. * @param x defines the first coordinate
  2462. * @param y defines the second coordinate
  2463. */
  2464. constructor(
  2465. /** defines the first coordinate */
  2466. x?: number,
  2467. /** defines the second coordinate */
  2468. y?: number);
  2469. /**
  2470. * Gets a string with the Vector2 coordinates
  2471. * @returns a string with the Vector2 coordinates
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets class name
  2476. * @returns the string "Vector2"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Gets current vector hash code
  2481. * @returns the Vector2 hash code as a number
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2486. * @param array defines the source array
  2487. * @param index defines the offset in source array
  2488. * @returns the current Vector2
  2489. */
  2490. toArray(array: FloatArray, index?: number): Vector2;
  2491. /**
  2492. * Update the current vector from an array
  2493. * @param array defines the destination array
  2494. * @param index defines the offset in the destination array
  2495. * @returns the current Vector3
  2496. */
  2497. fromArray(array: FloatArray, index?: number): Vector2;
  2498. /**
  2499. * Copy the current vector to an array
  2500. * @returns a new array with 2 elements: the Vector2 coordinates.
  2501. */
  2502. asArray(): number[];
  2503. /**
  2504. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2505. * @param source defines the source Vector2
  2506. * @returns the current updated Vector2
  2507. */
  2508. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2509. /**
  2510. * Sets the Vector2 coordinates with the given floats
  2511. * @param x defines the first coordinate
  2512. * @param y defines the second coordinate
  2513. * @returns the current updated Vector2
  2514. */
  2515. copyFromFloats(x: number, y: number): Vector2;
  2516. /**
  2517. * Sets the Vector2 coordinates with the given floats
  2518. * @param x defines the first coordinate
  2519. * @param y defines the second coordinate
  2520. * @returns the current updated Vector2
  2521. */
  2522. set(x: number, y: number): Vector2;
  2523. /**
  2524. * Add another vector with the current one
  2525. * @param otherVector defines the other vector
  2526. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2527. */
  2528. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2529. /**
  2530. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2531. * @param otherVector defines the other vector
  2532. * @param result defines the target vector
  2533. * @returns the unmodified current Vector2
  2534. */
  2535. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2536. /**
  2537. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2538. * @param otherVector defines the other vector
  2539. * @returns the current updated Vector2
  2540. */
  2541. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2542. /**
  2543. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2544. * @param otherVector defines the other vector
  2545. * @returns a new Vector2
  2546. */
  2547. addVector3(otherVector: Vector3): Vector2;
  2548. /**
  2549. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2550. * @param otherVector defines the other vector
  2551. * @returns a new Vector2
  2552. */
  2553. subtract(otherVector: Vector2): Vector2;
  2554. /**
  2555. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2556. * @param otherVector defines the other vector
  2557. * @param result defines the target vector
  2558. * @returns the unmodified current Vector2
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2561. /**
  2562. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2563. * @param otherVector defines the other vector
  2564. * @returns the current updated Vector2
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2567. /**
  2568. * Multiplies in place the current Vector2 coordinates by the given ones
  2569. * @param otherVector defines the other vector
  2570. * @returns the current updated Vector2
  2571. */
  2572. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2573. /**
  2574. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2575. * @param otherVector defines the other vector
  2576. * @returns a new Vector2
  2577. */
  2578. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2579. /**
  2580. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2581. * @param otherVector defines the other vector
  2582. * @param result defines the target vector
  2583. * @returns the unmodified current Vector2
  2584. */
  2585. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2586. /**
  2587. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2588. * @param x defines the first coordinate
  2589. * @param y defines the second coordinate
  2590. * @returns a new Vector2
  2591. */
  2592. multiplyByFloats(x: number, y: number): Vector2;
  2593. /**
  2594. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2595. * @param otherVector defines the other vector
  2596. * @returns a new Vector2
  2597. */
  2598. divide(otherVector: Vector2): Vector2;
  2599. /**
  2600. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2601. * @param otherVector defines the other vector
  2602. * @param result defines the target vector
  2603. * @returns the unmodified current Vector2
  2604. */
  2605. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2606. /**
  2607. * Divides the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Gets a new Vector2 with current Vector2 negated coordinates
  2614. * @returns a new Vector2
  2615. */
  2616. negate(): Vector2;
  2617. /**
  2618. * Negate this vector in place
  2619. * @returns this
  2620. */
  2621. negateInPlace(): Vector2;
  2622. /**
  2623. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector2
  2626. */
  2627. negateToRef(result: Vector2): Vector2;
  2628. /**
  2629. * Multiply the Vector2 coordinates by scale
  2630. * @param scale defines the scaling factor
  2631. * @returns the current updated Vector2
  2632. */
  2633. scaleInPlace(scale: number): Vector2;
  2634. /**
  2635. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2636. * @param scale defines the scaling factor
  2637. * @returns a new Vector2
  2638. */
  2639. scale(scale: number): Vector2;
  2640. /**
  2641. * Scale the current Vector2 values by a factor to a given Vector2
  2642. * @param scale defines the scale factor
  2643. * @param result defines the Vector2 object where to store the result
  2644. * @returns the unmodified current Vector2
  2645. */
  2646. scaleToRef(scale: number, result: Vector2): Vector2;
  2647. /**
  2648. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2649. * @param scale defines the scale factor
  2650. * @param result defines the Vector2 object where to store the result
  2651. * @returns the unmodified current Vector2
  2652. */
  2653. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2654. /**
  2655. * Gets a boolean if two vectors are equals
  2656. * @param otherVector defines the other vector
  2657. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2658. */
  2659. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2660. /**
  2661. * Gets a boolean if two vectors are equals (using an epsilon value)
  2662. * @param otherVector defines the other vector
  2663. * @param epsilon defines the minimal distance to consider equality
  2664. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2665. */
  2666. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2667. /**
  2668. * Gets a new Vector2 from current Vector2 floored values
  2669. * @returns a new Vector2
  2670. */
  2671. floor(): Vector2;
  2672. /**
  2673. * Gets a new Vector2 from current Vector2 floored values
  2674. * @returns a new Vector2
  2675. */
  2676. fract(): Vector2;
  2677. /**
  2678. * Gets the length of the vector
  2679. * @returns the vector length (float)
  2680. */
  2681. length(): number;
  2682. /**
  2683. * Gets the vector squared length
  2684. * @returns the vector squared length (float)
  2685. */
  2686. lengthSquared(): number;
  2687. /**
  2688. * Normalize the vector
  2689. * @returns the current updated Vector2
  2690. */
  2691. normalize(): Vector2;
  2692. /**
  2693. * Gets a new Vector2 copied from the Vector2
  2694. * @returns a new Vector2
  2695. */
  2696. clone(): Vector2;
  2697. /**
  2698. * Gets a new Vector2(0, 0)
  2699. * @returns a new Vector2
  2700. */
  2701. static Zero(): Vector2;
  2702. /**
  2703. * Gets a new Vector2(1, 1)
  2704. * @returns a new Vector2
  2705. */
  2706. static One(): Vector2;
  2707. /**
  2708. * Gets a new Vector2 set from the given index element of the given array
  2709. * @param array defines the data source
  2710. * @param offset defines the offset in the data source
  2711. * @returns a new Vector2
  2712. */
  2713. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2714. /**
  2715. * Sets "result" from the given index element of the given array
  2716. * @param array defines the data source
  2717. * @param offset defines the offset in the data source
  2718. * @param result defines the target vector
  2719. */
  2720. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2721. /**
  2722. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2723. * @param value1 defines 1st point of control
  2724. * @param value2 defines 2nd point of control
  2725. * @param value3 defines 3rd point of control
  2726. * @param value4 defines 4th point of control
  2727. * @param amount defines the interpolation factor
  2728. * @returns a new Vector2
  2729. */
  2730. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2731. /**
  2732. * 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".
  2733. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2734. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2735. * @param value defines the value to clamp
  2736. * @param min defines the lower limit
  2737. * @param max defines the upper limit
  2738. * @returns a new Vector2
  2739. */
  2740. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2741. /**
  2742. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2743. * @param value1 defines the 1st control point
  2744. * @param tangent1 defines the outgoing tangent
  2745. * @param value2 defines the 2nd control point
  2746. * @param tangent2 defines the incoming tangent
  2747. * @param amount defines the interpolation factor
  2748. * @returns a new Vector2
  2749. */
  2750. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2751. /**
  2752. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2753. * @param start defines the start vector
  2754. * @param end defines the end vector
  2755. * @param amount defines the interpolation factor
  2756. * @returns a new Vector2
  2757. */
  2758. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2759. /**
  2760. * Gets the dot product of the vector "left" and the vector "right"
  2761. * @param left defines first vector
  2762. * @param right defines second vector
  2763. * @returns the dot product (float)
  2764. */
  2765. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2766. /**
  2767. * Returns a new Vector2 equal to the normalized given vector
  2768. * @param vector defines the vector to normalize
  2769. * @returns a new Vector2
  2770. */
  2771. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2774. * @param left defines 1st vector
  2775. * @param right defines 2nd vector
  2776. * @returns a new Vector2
  2777. */
  2778. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2779. /**
  2780. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2781. * @param left defines 1st vector
  2782. * @param right defines 2nd vector
  2783. * @returns a new Vector2
  2784. */
  2785. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2786. /**
  2787. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2788. * @param vector defines the vector to transform
  2789. * @param transformation defines the matrix to apply
  2790. * @returns a new Vector2
  2791. */
  2792. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2793. /**
  2794. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2795. * @param vector defines the vector to transform
  2796. * @param transformation defines the matrix to apply
  2797. * @param result defines the target vector
  2798. */
  2799. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2800. /**
  2801. * Determines if a given vector is included in a triangle
  2802. * @param p defines the vector to test
  2803. * @param p0 defines 1st triangle point
  2804. * @param p1 defines 2nd triangle point
  2805. * @param p2 defines 3rd triangle point
  2806. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2807. */
  2808. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2809. /**
  2810. * Gets the distance between the vectors "value1" and "value2"
  2811. * @param value1 defines first vector
  2812. * @param value2 defines second vector
  2813. * @returns the distance between vectors
  2814. */
  2815. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2816. /**
  2817. * Returns the squared distance between the vectors "value1" and "value2"
  2818. * @param value1 defines first vector
  2819. * @param value2 defines second vector
  2820. * @returns the squared distance between vectors
  2821. */
  2822. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2823. /**
  2824. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2825. * @param value1 defines first vector
  2826. * @param value2 defines second vector
  2827. * @returns a new Vector2
  2828. */
  2829. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2832. * @param p defines the middle point
  2833. * @param segA defines one point of the segment
  2834. * @param segB defines the other point of the segment
  2835. * @returns the shortest distance
  2836. */
  2837. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2838. }
  2839. /**
  2840. * Class used to store (x,y,z) vector representation
  2841. * A Vector3 is the main object used in 3D geometry
  2842. * It can represent etiher the coordinates of a point the space, either a direction
  2843. * Reminder: js uses a left handed forward facing system
  2844. */
  2845. export class Vector3 {
  2846. private static _UpReadOnly;
  2847. private static _ZeroReadOnly;
  2848. /** @hidden */
  2849. _x: number;
  2850. /** @hidden */
  2851. _y: number;
  2852. /** @hidden */
  2853. _z: number;
  2854. /** @hidden */
  2855. _isDirty: boolean;
  2856. /** Gets or sets the x coordinate */
  2857. get x(): number;
  2858. set x(value: number);
  2859. /** Gets or sets the y coordinate */
  2860. get y(): number;
  2861. set y(value: number);
  2862. /** Gets or sets the z coordinate */
  2863. get z(): number;
  2864. set z(value: number);
  2865. /**
  2866. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2867. * @param x defines the first coordinates (on X axis)
  2868. * @param y defines the second coordinates (on Y axis)
  2869. * @param z defines the third coordinates (on Z axis)
  2870. */
  2871. constructor(x?: number, y?: number, z?: number);
  2872. /**
  2873. * Creates a string representation of the Vector3
  2874. * @returns a string with the Vector3 coordinates.
  2875. */
  2876. toString(): string;
  2877. /**
  2878. * Gets the class name
  2879. * @returns the string "Vector3"
  2880. */
  2881. getClassName(): string;
  2882. /**
  2883. * Creates the Vector3 hash code
  2884. * @returns a number which tends to be unique between Vector3 instances
  2885. */
  2886. getHashCode(): number;
  2887. /**
  2888. * Creates an array containing three elements : the coordinates of the Vector3
  2889. * @returns a new array of numbers
  2890. */
  2891. asArray(): number[];
  2892. /**
  2893. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2894. * @param array defines the destination array
  2895. * @param index defines the offset in the destination array
  2896. * @returns the current Vector3
  2897. */
  2898. toArray(array: FloatArray, index?: number): Vector3;
  2899. /**
  2900. * Update the current vector from an array
  2901. * @param array defines the destination array
  2902. * @param index defines the offset in the destination array
  2903. * @returns the current Vector3
  2904. */
  2905. fromArray(array: FloatArray, index?: number): Vector3;
  2906. /**
  2907. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2908. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2909. */
  2910. toQuaternion(): Quaternion;
  2911. /**
  2912. * Adds the given vector to the current Vector3
  2913. * @param otherVector defines the second operand
  2914. * @returns the current updated Vector3
  2915. */
  2916. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2917. /**
  2918. * Adds the given coordinates to the current Vector3
  2919. * @param x defines the x coordinate of the operand
  2920. * @param y defines the y coordinate of the operand
  2921. * @param z defines the z coordinate of the operand
  2922. * @returns the current updated Vector3
  2923. */
  2924. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2925. /**
  2926. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2927. * @param otherVector defines the second operand
  2928. * @returns the resulting Vector3
  2929. */
  2930. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2931. /**
  2932. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2933. * @param otherVector defines the second operand
  2934. * @param result defines the Vector3 object where to store the result
  2935. * @returns the current Vector3
  2936. */
  2937. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2938. /**
  2939. * Subtract the given vector from the current Vector3
  2940. * @param otherVector defines the second operand
  2941. * @returns the current updated Vector3
  2942. */
  2943. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2946. * @param otherVector defines the second operand
  2947. * @returns the resulting Vector3
  2948. */
  2949. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2950. /**
  2951. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2952. * @param otherVector defines the second operand
  2953. * @param result defines the Vector3 object where to store the result
  2954. * @returns the current Vector3
  2955. */
  2956. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2959. * @param x defines the x coordinate of the operand
  2960. * @param y defines the y coordinate of the operand
  2961. * @param z defines the z coordinate of the operand
  2962. * @returns the resulting Vector3
  2963. */
  2964. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2965. /**
  2966. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2967. * @param x defines the x coordinate of the operand
  2968. * @param y defines the y coordinate of the operand
  2969. * @param z defines the z coordinate of the operand
  2970. * @param result defines the Vector3 object where to store the result
  2971. * @returns the current Vector3
  2972. */
  2973. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2974. /**
  2975. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2976. * @returns a new Vector3
  2977. */
  2978. negate(): Vector3;
  2979. /**
  2980. * Negate this vector in place
  2981. * @returns this
  2982. */
  2983. negateInPlace(): Vector3;
  2984. /**
  2985. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2986. * @param result defines the Vector3 object where to store the result
  2987. * @returns the current Vector3
  2988. */
  2989. negateToRef(result: Vector3): Vector3;
  2990. /**
  2991. * Multiplies the Vector3 coordinates by the float "scale"
  2992. * @param scale defines the multiplier factor
  2993. * @returns the current updated Vector3
  2994. */
  2995. scaleInPlace(scale: number): Vector3;
  2996. /**
  2997. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2998. * @param scale defines the multiplier factor
  2999. * @returns a new Vector3
  3000. */
  3001. scale(scale: number): Vector3;
  3002. /**
  3003. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3004. * @param scale defines the multiplier factor
  3005. * @param result defines the Vector3 object where to store the result
  3006. * @returns the current Vector3
  3007. */
  3008. scaleToRef(scale: number, result: Vector3): Vector3;
  3009. /**
  3010. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3011. * @param scale defines the scale factor
  3012. * @param result defines the Vector3 object where to store the result
  3013. * @returns the unmodified current Vector3
  3014. */
  3015. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3016. /**
  3017. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3018. * @param origin defines the origin of the projection ray
  3019. * @param plane defines the plane to project to
  3020. * @returns the projected vector3
  3021. */
  3022. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3023. /**
  3024. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3025. * @param origin defines the origin of the projection ray
  3026. * @param plane defines the plane to project to
  3027. * @param result defines the Vector3 where to store the result
  3028. */
  3029. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3030. /**
  3031. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3032. * @param otherVector defines the second operand
  3033. * @returns true if both vectors are equals
  3034. */
  3035. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3036. /**
  3037. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3038. * @param otherVector defines the second operand
  3039. * @param epsilon defines the minimal distance to define values as equals
  3040. * @returns true if both vectors are distant less than epsilon
  3041. */
  3042. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3043. /**
  3044. * Returns true if the current Vector3 coordinates equals the given floats
  3045. * @param x defines the x coordinate of the operand
  3046. * @param y defines the y coordinate of the operand
  3047. * @param z defines the z coordinate of the operand
  3048. * @returns true if both vectors are equals
  3049. */
  3050. equalsToFloats(x: number, y: number, z: number): boolean;
  3051. /**
  3052. * Multiplies the current Vector3 coordinates by the given ones
  3053. * @param otherVector defines the second operand
  3054. * @returns the current updated Vector3
  3055. */
  3056. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3059. * @param otherVector defines the second operand
  3060. * @returns the new Vector3
  3061. */
  3062. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3063. /**
  3064. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3065. * @param otherVector defines the second operand
  3066. * @param result defines the Vector3 object where to store the result
  3067. * @returns the current Vector3
  3068. */
  3069. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3070. /**
  3071. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3072. * @param x defines the x coordinate of the operand
  3073. * @param y defines the y coordinate of the operand
  3074. * @param z defines the z coordinate of the operand
  3075. * @returns the new Vector3
  3076. */
  3077. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3080. * @param otherVector defines the second operand
  3081. * @returns the new Vector3
  3082. */
  3083. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3084. /**
  3085. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3086. * @param otherVector defines the second operand
  3087. * @param result defines the Vector3 object where to store the result
  3088. * @returns the current Vector3
  3089. */
  3090. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3091. /**
  3092. * Divides the current Vector3 coordinates by the given ones.
  3093. * @param otherVector defines the second operand
  3094. * @returns the current updated Vector3
  3095. */
  3096. divideInPlace(otherVector: Vector3): Vector3;
  3097. /**
  3098. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3099. * @param other defines the second operand
  3100. * @returns the current updated Vector3
  3101. */
  3102. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3103. /**
  3104. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3105. * @param other defines the second operand
  3106. * @returns the current updated Vector3
  3107. */
  3108. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3111. * @param x defines the x coordinate of the operand
  3112. * @param y defines the y coordinate of the operand
  3113. * @param z defines the z coordinate of the operand
  3114. * @returns the current updated Vector3
  3115. */
  3116. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3117. /**
  3118. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3119. * @param x defines the x coordinate of the operand
  3120. * @param y defines the y coordinate of the operand
  3121. * @param z defines the z coordinate of the operand
  3122. * @returns the current updated Vector3
  3123. */
  3124. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3125. /**
  3126. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3127. * Check if is non uniform within a certain amount of decimal places to account for this
  3128. * @param epsilon the amount the values can differ
  3129. * @returns if the the vector is non uniform to a certain number of decimal places
  3130. */
  3131. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3132. /**
  3133. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3134. */
  3135. get isNonUniform(): boolean;
  3136. /**
  3137. * Gets a new Vector3 from current Vector3 floored values
  3138. * @returns a new Vector3
  3139. */
  3140. floor(): Vector3;
  3141. /**
  3142. * Gets a new Vector3 from current Vector3 floored values
  3143. * @returns a new Vector3
  3144. */
  3145. fract(): Vector3;
  3146. /**
  3147. * Gets the length of the Vector3
  3148. * @returns the length of the Vector3
  3149. */
  3150. length(): number;
  3151. /**
  3152. * Gets the squared length of the Vector3
  3153. * @returns squared length of the Vector3
  3154. */
  3155. lengthSquared(): number;
  3156. /**
  3157. * Normalize the current Vector3.
  3158. * Please note that this is an in place operation.
  3159. * @returns the current updated Vector3
  3160. */
  3161. normalize(): Vector3;
  3162. /**
  3163. * Reorders the x y z properties of the vector in place
  3164. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3165. * @returns the current updated vector
  3166. */
  3167. reorderInPlace(order: string): this;
  3168. /**
  3169. * Rotates the vector around 0,0,0 by a quaternion
  3170. * @param quaternion the rotation quaternion
  3171. * @param result vector to store the result
  3172. * @returns the resulting vector
  3173. */
  3174. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3175. /**
  3176. * Rotates a vector around a given point
  3177. * @param quaternion the rotation quaternion
  3178. * @param point the point to rotate around
  3179. * @param result vector to store the result
  3180. * @returns the resulting vector
  3181. */
  3182. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3183. /**
  3184. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3185. * The cross product is then orthogonal to both current and "other"
  3186. * @param other defines the right operand
  3187. * @returns the cross product
  3188. */
  3189. cross(other: Vector3): Vector3;
  3190. /**
  3191. * Normalize the current Vector3 with the given input length.
  3192. * Please note that this is an in place operation.
  3193. * @param len the length of the vector
  3194. * @returns the current updated Vector3
  3195. */
  3196. normalizeFromLength(len: number): Vector3;
  3197. /**
  3198. * Normalize the current Vector3 to a new vector
  3199. * @returns the new Vector3
  3200. */
  3201. normalizeToNew(): Vector3;
  3202. /**
  3203. * Normalize the current Vector3 to the reference
  3204. * @param reference define the Vector3 to update
  3205. * @returns the updated Vector3
  3206. */
  3207. normalizeToRef(reference: Vector3): Vector3;
  3208. /**
  3209. * Creates a new Vector3 copied from the current Vector3
  3210. * @returns the new Vector3
  3211. */
  3212. clone(): Vector3;
  3213. /**
  3214. * Copies the given vector coordinates to the current Vector3 ones
  3215. * @param source defines the source Vector3
  3216. * @returns the current updated Vector3
  3217. */
  3218. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3219. /**
  3220. * Copies the given floats to the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the current updated Vector3
  3225. */
  3226. copyFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Copies the given floats to the current Vector3 coordinates
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @returns the current updated Vector3
  3233. */
  3234. set(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Copies the given float to the current Vector3 coordinates
  3237. * @param v defines the x, y and z coordinates of the operand
  3238. * @returns the current updated Vector3
  3239. */
  3240. setAll(v: number): Vector3;
  3241. /**
  3242. * Get the clip factor between two vectors
  3243. * @param vector0 defines the first operand
  3244. * @param vector1 defines the second operand
  3245. * @param axis defines the axis to use
  3246. * @param size defines the size along the axis
  3247. * @returns the clip factor
  3248. */
  3249. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3250. /**
  3251. * Get angle between two vectors
  3252. * @param vector0 angle between vector0 and vector1
  3253. * @param vector1 angle between vector0 and vector1
  3254. * @param normal direction of the normal
  3255. * @return the angle between vector0 and vector1
  3256. */
  3257. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3258. /**
  3259. * Returns a new Vector3 set from the index "offset" of the given array
  3260. * @param array defines the source array
  3261. * @param offset defines the offset in the source array
  3262. * @returns the new Vector3
  3263. */
  3264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3265. /**
  3266. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3267. * @param array defines the source array
  3268. * @param offset defines the offset in the source array
  3269. * @returns the new Vector3
  3270. * @deprecated Please use FromArray instead.
  3271. */
  3272. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3273. /**
  3274. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3275. * @param array defines the source array
  3276. * @param offset defines the offset in the source array
  3277. * @param result defines the Vector3 where to store the result
  3278. */
  3279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3280. /**
  3281. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3282. * @param array defines the source array
  3283. * @param offset defines the offset in the source array
  3284. * @param result defines the Vector3 where to store the result
  3285. * @deprecated Please use FromArrayToRef instead.
  3286. */
  3287. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3288. /**
  3289. * Sets the given vector "result" with the given floats.
  3290. * @param x defines the x coordinate of the source
  3291. * @param y defines the y coordinate of the source
  3292. * @param z defines the z coordinate of the source
  3293. * @param result defines the Vector3 where to store the result
  3294. */
  3295. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3296. /**
  3297. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3298. * @returns a new empty Vector3
  3299. */
  3300. static Zero(): Vector3;
  3301. /**
  3302. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3303. * @returns a new unit Vector3
  3304. */
  3305. static One(): Vector3;
  3306. /**
  3307. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3308. * @returns a new up Vector3
  3309. */
  3310. static Up(): Vector3;
  3311. /**
  3312. * Gets a up Vector3 that must not be updated
  3313. */
  3314. static get UpReadOnly(): DeepImmutable<Vector3>;
  3315. /**
  3316. * Gets a zero Vector3 that must not be updated
  3317. */
  3318. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3319. /**
  3320. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3321. * @returns a new down Vector3
  3322. */
  3323. static Down(): Vector3;
  3324. /**
  3325. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3326. * @param rightHandedSystem is the scene right-handed (negative z)
  3327. * @returns a new forward Vector3
  3328. */
  3329. static Forward(rightHandedSystem?: boolean): Vector3;
  3330. /**
  3331. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3332. * @param rightHandedSystem is the scene right-handed (negative-z)
  3333. * @returns a new forward Vector3
  3334. */
  3335. static Backward(rightHandedSystem?: boolean): Vector3;
  3336. /**
  3337. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3338. * @returns a new right Vector3
  3339. */
  3340. static Right(): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3343. * @returns a new left Vector3
  3344. */
  3345. static Left(): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3348. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3349. * @param vector defines the Vector3 to transform
  3350. * @param transformation defines the transformation matrix
  3351. * @returns the transformed Vector3
  3352. */
  3353. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3354. /**
  3355. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3356. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3357. * @param vector defines the Vector3 to transform
  3358. * @param transformation defines the transformation matrix
  3359. * @param result defines the Vector3 where to store the result
  3360. */
  3361. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3362. /**
  3363. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3364. * This method computes tranformed coordinates only, not transformed direction vectors
  3365. * @param x define the x coordinate of the source vector
  3366. * @param y define the y coordinate of the source vector
  3367. * @param z define the z coordinate of the source vector
  3368. * @param transformation defines the transformation matrix
  3369. * @param result defines the Vector3 where to store the result
  3370. */
  3371. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3372. /**
  3373. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3374. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3375. * @param vector defines the Vector3 to transform
  3376. * @param transformation defines the transformation matrix
  3377. * @returns the new Vector3
  3378. */
  3379. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3380. /**
  3381. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3382. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3383. * @param vector defines the Vector3 to transform
  3384. * @param transformation defines the transformation matrix
  3385. * @param result defines the Vector3 where to store the result
  3386. */
  3387. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3388. /**
  3389. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3390. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3391. * @param x define the x coordinate of the source vector
  3392. * @param y define the y coordinate of the source vector
  3393. * @param z define the z coordinate of the source vector
  3394. * @param transformation defines the transformation matrix
  3395. * @param result defines the Vector3 where to store the result
  3396. */
  3397. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3398. /**
  3399. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3400. * @param value1 defines the first control point
  3401. * @param value2 defines the second control point
  3402. * @param value3 defines the third control point
  3403. * @param value4 defines the fourth control point
  3404. * @param amount defines the amount on the spline to use
  3405. * @returns the new Vector3
  3406. */
  3407. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3408. /**
  3409. * 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"
  3410. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3411. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3412. * @param value defines the current value
  3413. * @param min defines the lower range value
  3414. * @param max defines the upper range value
  3415. * @returns the new Vector3
  3416. */
  3417. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3418. /**
  3419. * 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"
  3420. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3421. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3422. * @param value defines the current value
  3423. * @param min defines the lower range value
  3424. * @param max defines the upper range value
  3425. * @param result defines the Vector3 where to store the result
  3426. */
  3427. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3428. /**
  3429. * Checks if a given vector is inside a specific range
  3430. * @param v defines the vector to test
  3431. * @param min defines the minimum range
  3432. * @param max defines the maximum range
  3433. */
  3434. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3435. /**
  3436. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3437. * @param value1 defines the first control point
  3438. * @param tangent1 defines the first tangent vector
  3439. * @param value2 defines the second control point
  3440. * @param tangent2 defines the second tangent vector
  3441. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3442. * @returns the new Vector3
  3443. */
  3444. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3445. /**
  3446. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3447. * @param start defines the start value
  3448. * @param end defines the end value
  3449. * @param amount max defines amount between both (between 0 and 1)
  3450. * @returns the new Vector3
  3451. */
  3452. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3453. /**
  3454. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3455. * @param start defines the start value
  3456. * @param end defines the end value
  3457. * @param amount max defines amount between both (between 0 and 1)
  3458. * @param result defines the Vector3 where to store the result
  3459. */
  3460. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3461. /**
  3462. * Returns the dot product (float) between the vectors "left" and "right"
  3463. * @param left defines the left operand
  3464. * @param right defines the right operand
  3465. * @returns the dot product
  3466. */
  3467. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3468. /**
  3469. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3470. * The cross product is then orthogonal to both "left" and "right"
  3471. * @param left defines the left operand
  3472. * @param right defines the right operand
  3473. * @returns the cross product
  3474. */
  3475. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3476. /**
  3477. * Sets the given vector "result" with the cross product of "left" and "right"
  3478. * The cross product is then orthogonal to both "left" and "right"
  3479. * @param left defines the left operand
  3480. * @param right defines the right operand
  3481. * @param result defines the Vector3 where to store the result
  3482. */
  3483. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3484. /**
  3485. * Returns a new Vector3 as the normalization of the given vector
  3486. * @param vector defines the Vector3 to normalize
  3487. * @returns the new Vector3
  3488. */
  3489. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Sets the given vector "result" with the normalization of the given first vector
  3492. * @param vector defines the Vector3 to normalize
  3493. * @param result defines the Vector3 where to store the result
  3494. */
  3495. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3496. /**
  3497. * Project a Vector3 onto screen space
  3498. * @param vector defines the Vector3 to project
  3499. * @param world defines the world matrix to use
  3500. * @param transform defines the transform (view x projection) matrix to use
  3501. * @param viewport defines the screen viewport to use
  3502. * @returns the new Vector3
  3503. */
  3504. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3505. /**
  3506. * Project a Vector3 onto screen space to reference
  3507. * @param vector defines the Vector3 to project
  3508. * @param world defines the world matrix to use
  3509. * @param transform defines the transform (view x projection) matrix to use
  3510. * @param viewport defines the screen viewport to use
  3511. * @param result the vector in which the screen space will be stored
  3512. * @returns the new Vector3
  3513. */
  3514. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3515. /** @hidden */
  3516. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3517. /**
  3518. * Unproject from screen space to object space
  3519. * @param source defines the screen space Vector3 to use
  3520. * @param viewportWidth defines the current width of the viewport
  3521. * @param viewportHeight defines the current height of the viewport
  3522. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3523. * @param transform defines the transform (view x projection) matrix to use
  3524. * @returns the new Vector3
  3525. */
  3526. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3527. /**
  3528. * Unproject from screen space to object space
  3529. * @param source defines the screen space Vector3 to use
  3530. * @param viewportWidth defines the current width of the viewport
  3531. * @param viewportHeight defines the current height of the viewport
  3532. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3533. * @param view defines the view matrix to use
  3534. * @param projection defines the projection matrix to use
  3535. * @returns the new Vector3
  3536. */
  3537. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3538. /**
  3539. * Unproject from screen space to object space
  3540. * @param source defines the screen space Vector3 to use
  3541. * @param viewportWidth defines the current width of the viewport
  3542. * @param viewportHeight defines the current height of the viewport
  3543. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3544. * @param view defines the view matrix to use
  3545. * @param projection defines the projection matrix to use
  3546. * @param result defines the Vector3 where to store the result
  3547. */
  3548. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3549. /**
  3550. * Unproject from screen space to object space
  3551. * @param sourceX defines the screen space x coordinate to use
  3552. * @param sourceY defines the screen space y coordinate to use
  3553. * @param sourceZ defines the screen space z coordinate to use
  3554. * @param viewportWidth defines the current width of the viewport
  3555. * @param viewportHeight defines the current height of the viewport
  3556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3557. * @param view defines the view matrix to use
  3558. * @param projection defines the projection matrix to use
  3559. * @param result defines the Vector3 where to store the result
  3560. */
  3561. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3562. /**
  3563. * Gets the minimal coordinate values between two Vector3
  3564. * @param left defines the first operand
  3565. * @param right defines the second operand
  3566. * @returns the new Vector3
  3567. */
  3568. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3569. /**
  3570. * Gets the maximal coordinate values between two Vector3
  3571. * @param left defines the first operand
  3572. * @param right defines the second operand
  3573. * @returns the new Vector3
  3574. */
  3575. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3576. /**
  3577. * Returns the distance between the vectors "value1" and "value2"
  3578. * @param value1 defines the first operand
  3579. * @param value2 defines the second operand
  3580. * @returns the distance
  3581. */
  3582. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3583. /**
  3584. * Returns the squared distance between the vectors "value1" and "value2"
  3585. * @param value1 defines the first operand
  3586. * @param value2 defines the second operand
  3587. * @returns the squared distance
  3588. */
  3589. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3590. /**
  3591. * Returns a new Vector3 located at the center between "value1" and "value2"
  3592. * @param value1 defines the first operand
  3593. * @param value2 defines the second operand
  3594. * @returns the new Vector3
  3595. */
  3596. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3597. /**
  3598. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3599. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3600. * to something in order to rotate it from its local system to the given target system
  3601. * Note: axis1, axis2 and axis3 are normalized during this operation
  3602. * @param axis1 defines the first axis
  3603. * @param axis2 defines the second axis
  3604. * @param axis3 defines the third axis
  3605. * @returns a new Vector3
  3606. */
  3607. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3608. /**
  3609. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3610. * @param axis1 defines the first axis
  3611. * @param axis2 defines the second axis
  3612. * @param axis3 defines the third axis
  3613. * @param ref defines the Vector3 where to store the result
  3614. */
  3615. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3616. }
  3617. /**
  3618. * Vector4 class created for EulerAngle class conversion to Quaternion
  3619. */
  3620. export class Vector4 {
  3621. /** x value of the vector */
  3622. x: number;
  3623. /** y value of the vector */
  3624. y: number;
  3625. /** z value of the vector */
  3626. z: number;
  3627. /** w value of the vector */
  3628. w: number;
  3629. /**
  3630. * Creates a Vector4 object from the given floats.
  3631. * @param x x value of the vector
  3632. * @param y y value of the vector
  3633. * @param z z value of the vector
  3634. * @param w w value of the vector
  3635. */
  3636. constructor(
  3637. /** x value of the vector */
  3638. x: number,
  3639. /** y value of the vector */
  3640. y: number,
  3641. /** z value of the vector */
  3642. z: number,
  3643. /** w value of the vector */
  3644. w: number);
  3645. /**
  3646. * Returns the string with the Vector4 coordinates.
  3647. * @returns a string containing all the vector values
  3648. */
  3649. toString(): string;
  3650. /**
  3651. * Returns the string "Vector4".
  3652. * @returns "Vector4"
  3653. */
  3654. getClassName(): string;
  3655. /**
  3656. * Returns the Vector4 hash code.
  3657. * @returns a unique hash code
  3658. */
  3659. getHashCode(): number;
  3660. /**
  3661. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3662. * @returns the resulting array
  3663. */
  3664. asArray(): number[];
  3665. /**
  3666. * Populates the given array from the given index with the Vector4 coordinates.
  3667. * @param array array to populate
  3668. * @param index index of the array to start at (default: 0)
  3669. * @returns the Vector4.
  3670. */
  3671. toArray(array: FloatArray, index?: number): Vector4;
  3672. /**
  3673. * Update the current vector from an array
  3674. * @param array defines the destination array
  3675. * @param index defines the offset in the destination array
  3676. * @returns the current Vector3
  3677. */
  3678. fromArray(array: FloatArray, index?: number): Vector4;
  3679. /**
  3680. * Adds the given vector to the current Vector4.
  3681. * @param otherVector the vector to add
  3682. * @returns the updated Vector4.
  3683. */
  3684. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3685. /**
  3686. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3687. * @param otherVector the vector to add
  3688. * @returns the resulting vector
  3689. */
  3690. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3691. /**
  3692. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3693. * @param otherVector the vector to add
  3694. * @param result the vector to store the result
  3695. * @returns the current Vector4.
  3696. */
  3697. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3698. /**
  3699. * Subtract in place the given vector from the current Vector4.
  3700. * @param otherVector the vector to subtract
  3701. * @returns the updated Vector4.
  3702. */
  3703. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3704. /**
  3705. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3706. * @param otherVector the vector to add
  3707. * @returns the new vector with the result
  3708. */
  3709. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3710. /**
  3711. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3712. * @param otherVector the vector to subtract
  3713. * @param result the vector to store the result
  3714. * @returns the current Vector4.
  3715. */
  3716. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3717. /**
  3718. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3719. */
  3720. /**
  3721. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3722. * @param x value to subtract
  3723. * @param y value to subtract
  3724. * @param z value to subtract
  3725. * @param w value to subtract
  3726. * @returns new vector containing the result
  3727. */
  3728. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3729. /**
  3730. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3731. * @param x value to subtract
  3732. * @param y value to subtract
  3733. * @param z value to subtract
  3734. * @param w value to subtract
  3735. * @param result the vector to store the result in
  3736. * @returns the current Vector4.
  3737. */
  3738. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3739. /**
  3740. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3741. * @returns a new vector with the negated values
  3742. */
  3743. negate(): Vector4;
  3744. /**
  3745. * Negate this vector in place
  3746. * @returns this
  3747. */
  3748. negateInPlace(): Vector4;
  3749. /**
  3750. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3751. * @param result defines the Vector3 object where to store the result
  3752. * @returns the current Vector4
  3753. */
  3754. negateToRef(result: Vector4): Vector4;
  3755. /**
  3756. * Multiplies the current Vector4 coordinates by scale (float).
  3757. * @param scale the number to scale with
  3758. * @returns the updated Vector4.
  3759. */
  3760. scaleInPlace(scale: number): Vector4;
  3761. /**
  3762. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3763. * @param scale the number to scale with
  3764. * @returns a new vector with the result
  3765. */
  3766. scale(scale: number): Vector4;
  3767. /**
  3768. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3769. * @param scale the number to scale with
  3770. * @param result a vector to store the result in
  3771. * @returns the current Vector4.
  3772. */
  3773. scaleToRef(scale: number, result: Vector4): Vector4;
  3774. /**
  3775. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3776. * @param scale defines the scale factor
  3777. * @param result defines the Vector4 object where to store the result
  3778. * @returns the unmodified current Vector4
  3779. */
  3780. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3781. /**
  3782. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3783. * @param otherVector the vector to compare against
  3784. * @returns true if they are equal
  3785. */
  3786. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3787. /**
  3788. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3789. * @param otherVector vector to compare against
  3790. * @param epsilon (Default: very small number)
  3791. * @returns true if they are equal
  3792. */
  3793. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3794. /**
  3795. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3796. * @param x x value to compare against
  3797. * @param y y value to compare against
  3798. * @param z z value to compare against
  3799. * @param w w value to compare against
  3800. * @returns true if equal
  3801. */
  3802. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3803. /**
  3804. * Multiplies in place the current Vector4 by the given one.
  3805. * @param otherVector vector to multiple with
  3806. * @returns the updated Vector4.
  3807. */
  3808. multiplyInPlace(otherVector: Vector4): Vector4;
  3809. /**
  3810. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3811. * @param otherVector vector to multiple with
  3812. * @returns resulting new vector
  3813. */
  3814. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3815. /**
  3816. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3817. * @param otherVector vector to multiple with
  3818. * @param result vector to store the result
  3819. * @returns the current Vector4.
  3820. */
  3821. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3822. /**
  3823. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3824. * @param x x value multiply with
  3825. * @param y y value multiply with
  3826. * @param z z value multiply with
  3827. * @param w w value multiply with
  3828. * @returns resulting new vector
  3829. */
  3830. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3831. /**
  3832. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3833. * @param otherVector vector to devide with
  3834. * @returns resulting new vector
  3835. */
  3836. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3837. /**
  3838. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3839. * @param otherVector vector to devide with
  3840. * @param result vector to store the result
  3841. * @returns the current Vector4.
  3842. */
  3843. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3844. /**
  3845. * Divides the current Vector3 coordinates by the given ones.
  3846. * @param otherVector vector to devide with
  3847. * @returns the updated Vector3.
  3848. */
  3849. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3850. /**
  3851. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3852. * @param other defines the second operand
  3853. * @returns the current updated Vector4
  3854. */
  3855. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3856. /**
  3857. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3858. * @param other defines the second operand
  3859. * @returns the current updated Vector4
  3860. */
  3861. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3862. /**
  3863. * Gets a new Vector4 from current Vector4 floored values
  3864. * @returns a new Vector4
  3865. */
  3866. floor(): Vector4;
  3867. /**
  3868. * Gets a new Vector4 from current Vector3 floored values
  3869. * @returns a new Vector4
  3870. */
  3871. fract(): Vector4;
  3872. /**
  3873. * Returns the Vector4 length (float).
  3874. * @returns the length
  3875. */
  3876. length(): number;
  3877. /**
  3878. * Returns the Vector4 squared length (float).
  3879. * @returns the length squared
  3880. */
  3881. lengthSquared(): number;
  3882. /**
  3883. * Normalizes in place the Vector4.
  3884. * @returns the updated Vector4.
  3885. */
  3886. normalize(): Vector4;
  3887. /**
  3888. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3889. * @returns this converted to a new vector3
  3890. */
  3891. toVector3(): Vector3;
  3892. /**
  3893. * Returns a new Vector4 copied from the current one.
  3894. * @returns the new cloned vector
  3895. */
  3896. clone(): Vector4;
  3897. /**
  3898. * Updates the current Vector4 with the given one coordinates.
  3899. * @param source the source vector to copy from
  3900. * @returns the updated Vector4.
  3901. */
  3902. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3903. /**
  3904. * Updates the current Vector4 coordinates with the given floats.
  3905. * @param x float to copy from
  3906. * @param y float to copy from
  3907. * @param z float to copy from
  3908. * @param w float to copy from
  3909. * @returns the updated Vector4.
  3910. */
  3911. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3912. /**
  3913. * Updates the current Vector4 coordinates with the given floats.
  3914. * @param x float to set from
  3915. * @param y float to set from
  3916. * @param z float to set from
  3917. * @param w float to set from
  3918. * @returns the updated Vector4.
  3919. */
  3920. set(x: number, y: number, z: number, w: number): Vector4;
  3921. /**
  3922. * Copies the given float to the current Vector3 coordinates
  3923. * @param v defines the x, y, z and w coordinates of the operand
  3924. * @returns the current updated Vector3
  3925. */
  3926. setAll(v: number): Vector4;
  3927. /**
  3928. * Returns a new Vector4 set from the starting index of the given array.
  3929. * @param array the array to pull values from
  3930. * @param offset the offset into the array to start at
  3931. * @returns the new vector
  3932. */
  3933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3934. /**
  3935. * Updates the given vector "result" from the starting index of the given array.
  3936. * @param array the array to pull values from
  3937. * @param offset the offset into the array to start at
  3938. * @param result the vector to store the result in
  3939. */
  3940. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3941. /**
  3942. * Updates the given vector "result" from the starting index of the given Float32Array.
  3943. * @param array the array to pull values from
  3944. * @param offset the offset into the array to start at
  3945. * @param result the vector to store the result in
  3946. */
  3947. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3948. /**
  3949. * Updates the given vector "result" coordinates from the given floats.
  3950. * @param x float to set from
  3951. * @param y float to set from
  3952. * @param z float to set from
  3953. * @param w float to set from
  3954. * @param result the vector to the floats in
  3955. */
  3956. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3957. /**
  3958. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3959. * @returns the new vector
  3960. */
  3961. static Zero(): Vector4;
  3962. /**
  3963. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3964. * @returns the new vector
  3965. */
  3966. static One(): Vector4;
  3967. /**
  3968. * Returns a new normalized Vector4 from the given one.
  3969. * @param vector the vector to normalize
  3970. * @returns the vector
  3971. */
  3972. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3973. /**
  3974. * Updates the given vector "result" from the normalization of the given one.
  3975. * @param vector the vector to normalize
  3976. * @param result the vector to store the result in
  3977. */
  3978. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3979. /**
  3980. * Returns a vector with the minimum values from the left and right vectors
  3981. * @param left left vector to minimize
  3982. * @param right right vector to minimize
  3983. * @returns a new vector with the minimum of the left and right vector values
  3984. */
  3985. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3986. /**
  3987. * Returns a vector with the maximum values from the left and right vectors
  3988. * @param left left vector to maximize
  3989. * @param right right vector to maximize
  3990. * @returns a new vector with the maximum of the left and right vector values
  3991. */
  3992. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3993. /**
  3994. * Returns the distance (float) between the vectors "value1" and "value2".
  3995. * @param value1 value to calulate the distance between
  3996. * @param value2 value to calulate the distance between
  3997. * @return the distance between the two vectors
  3998. */
  3999. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4000. /**
  4001. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4002. * @param value1 value to calulate the distance between
  4003. * @param value2 value to calulate the distance between
  4004. * @return the distance between the two vectors squared
  4005. */
  4006. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4007. /**
  4008. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4009. * @param value1 value to calulate the center between
  4010. * @param value2 value to calulate the center between
  4011. * @return the center between the two vectors
  4012. */
  4013. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4014. /**
  4015. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4016. * This methods computes transformed normalized direction vectors only.
  4017. * @param vector the vector to transform
  4018. * @param transformation the transformation matrix to apply
  4019. * @returns the new vector
  4020. */
  4021. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4022. /**
  4023. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4024. * This methods computes transformed normalized direction vectors only.
  4025. * @param vector the vector to transform
  4026. * @param transformation the transformation matrix to apply
  4027. * @param result the vector to store the result in
  4028. */
  4029. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4030. /**
  4031. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4032. * This methods computes transformed normalized direction vectors only.
  4033. * @param x value to transform
  4034. * @param y value to transform
  4035. * @param z value to transform
  4036. * @param w value to transform
  4037. * @param transformation the transformation matrix to apply
  4038. * @param result the vector to store the results in
  4039. */
  4040. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4041. /**
  4042. * Creates a new Vector4 from a Vector3
  4043. * @param source defines the source data
  4044. * @param w defines the 4th component (default is 0)
  4045. * @returns a new Vector4
  4046. */
  4047. static FromVector3(source: Vector3, w?: number): Vector4;
  4048. }
  4049. /**
  4050. * Class used to store quaternion data
  4051. * @see https://en.wikipedia.org/wiki/Quaternion
  4052. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4053. */
  4054. export class Quaternion {
  4055. /** @hidden */
  4056. _x: number;
  4057. /** @hidden */
  4058. _y: number;
  4059. /** @hidden */
  4060. _z: number;
  4061. /** @hidden */
  4062. _w: number;
  4063. /** @hidden */
  4064. _isDirty: boolean;
  4065. /** Gets or sets the x coordinate */
  4066. get x(): number;
  4067. set x(value: number);
  4068. /** Gets or sets the y coordinate */
  4069. get y(): number;
  4070. set y(value: number);
  4071. /** Gets or sets the z coordinate */
  4072. get z(): number;
  4073. set z(value: number);
  4074. /** Gets or sets the w coordinate */
  4075. get w(): number;
  4076. set w(value: number);
  4077. /**
  4078. * Creates a new Quaternion from the given floats
  4079. * @param x defines the first component (0 by default)
  4080. * @param y defines the second component (0 by default)
  4081. * @param z defines the third component (0 by default)
  4082. * @param w defines the fourth component (1.0 by default)
  4083. */
  4084. constructor(x?: number, y?: number, z?: number, w?: number);
  4085. /**
  4086. * Gets a string representation for the current quaternion
  4087. * @returns a string with the Quaternion coordinates
  4088. */
  4089. toString(): string;
  4090. /**
  4091. * Gets the class name of the quaternion
  4092. * @returns the string "Quaternion"
  4093. */
  4094. getClassName(): string;
  4095. /**
  4096. * Gets a hash code for this quaternion
  4097. * @returns the quaternion hash code
  4098. */
  4099. getHashCode(): number;
  4100. /**
  4101. * Copy the quaternion to an array
  4102. * @returns a new array populated with 4 elements from the quaternion coordinates
  4103. */
  4104. asArray(): number[];
  4105. /**
  4106. * Check if two quaternions are equals
  4107. * @param otherQuaternion defines the second operand
  4108. * @return true if the current quaternion and the given one coordinates are strictly equals
  4109. */
  4110. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4111. /**
  4112. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4113. * @param otherQuaternion defines the other quaternion
  4114. * @param epsilon defines the minimal distance to consider equality
  4115. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4116. */
  4117. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4118. /**
  4119. * Clone the current quaternion
  4120. * @returns a new quaternion copied from the current one
  4121. */
  4122. clone(): Quaternion;
  4123. /**
  4124. * Copy a quaternion to the current one
  4125. * @param other defines the other quaternion
  4126. * @returns the updated current quaternion
  4127. */
  4128. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4129. /**
  4130. * Updates the current quaternion with the given float coordinates
  4131. * @param x defines the x coordinate
  4132. * @param y defines the y coordinate
  4133. * @param z defines the z coordinate
  4134. * @param w defines the w coordinate
  4135. * @returns the updated current quaternion
  4136. */
  4137. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4138. /**
  4139. * Updates the current quaternion from the given float coordinates
  4140. * @param x defines the x coordinate
  4141. * @param y defines the y coordinate
  4142. * @param z defines the z coordinate
  4143. * @param w defines the w coordinate
  4144. * @returns the updated current quaternion
  4145. */
  4146. set(x: number, y: number, z: number, w: number): Quaternion;
  4147. /**
  4148. * Adds two quaternions
  4149. * @param other defines the second operand
  4150. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4151. */
  4152. add(other: DeepImmutable<Quaternion>): Quaternion;
  4153. /**
  4154. * Add a quaternion to the current one
  4155. * @param other defines the quaternion to add
  4156. * @returns the current quaternion
  4157. */
  4158. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4159. /**
  4160. * Subtract two quaternions
  4161. * @param other defines the second operand
  4162. * @returns a new quaternion as the subtraction result of the given one from the current one
  4163. */
  4164. subtract(other: Quaternion): Quaternion;
  4165. /**
  4166. * Multiplies the current quaternion by a scale factor
  4167. * @param value defines the scale factor
  4168. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4169. */
  4170. scale(value: number): Quaternion;
  4171. /**
  4172. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4173. * @param scale defines the scale factor
  4174. * @param result defines the Quaternion object where to store the result
  4175. * @returns the unmodified current quaternion
  4176. */
  4177. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4178. /**
  4179. * Multiplies in place the current quaternion by a scale factor
  4180. * @param value defines the scale factor
  4181. * @returns the current modified quaternion
  4182. */
  4183. scaleInPlace(value: number): Quaternion;
  4184. /**
  4185. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4186. * @param scale defines the scale factor
  4187. * @param result defines the Quaternion object where to store the result
  4188. * @returns the unmodified current quaternion
  4189. */
  4190. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4191. /**
  4192. * Multiplies two quaternions
  4193. * @param q1 defines the second operand
  4194. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4195. */
  4196. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4197. /**
  4198. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4199. * @param q1 defines the second operand
  4200. * @param result defines the target quaternion
  4201. * @returns the current quaternion
  4202. */
  4203. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4204. /**
  4205. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4206. * @param q1 defines the second operand
  4207. * @returns the currentupdated quaternion
  4208. */
  4209. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4210. /**
  4211. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4212. * @param ref defines the target quaternion
  4213. * @returns the current quaternion
  4214. */
  4215. conjugateToRef(ref: Quaternion): Quaternion;
  4216. /**
  4217. * Conjugates in place (1-q) the current quaternion
  4218. * @returns the current updated quaternion
  4219. */
  4220. conjugateInPlace(): Quaternion;
  4221. /**
  4222. * Conjugates in place (1-q) the current quaternion
  4223. * @returns a new quaternion
  4224. */
  4225. conjugate(): Quaternion;
  4226. /**
  4227. * Gets length of current quaternion
  4228. * @returns the quaternion length (float)
  4229. */
  4230. length(): number;
  4231. /**
  4232. * Normalize in place the current quaternion
  4233. * @returns the current updated quaternion
  4234. */
  4235. normalize(): Quaternion;
  4236. /**
  4237. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4238. * @param order is a reserved parameter and is ignored for now
  4239. * @returns a new Vector3 containing the Euler angles
  4240. */
  4241. toEulerAngles(order?: string): Vector3;
  4242. /**
  4243. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4244. * @param result defines the vector which will be filled with the Euler angles
  4245. * @returns the current unchanged quaternion
  4246. */
  4247. toEulerAnglesToRef(result: Vector3): Quaternion;
  4248. /**
  4249. * Updates the given rotation matrix with the current quaternion values
  4250. * @param result defines the target matrix
  4251. * @returns the current unchanged quaternion
  4252. */
  4253. toRotationMatrix(result: Matrix): Quaternion;
  4254. /**
  4255. * Updates the current quaternion from the given rotation matrix values
  4256. * @param matrix defines the source matrix
  4257. * @returns the current updated quaternion
  4258. */
  4259. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4260. /**
  4261. * Creates a new quaternion from a rotation matrix
  4262. * @param matrix defines the source matrix
  4263. * @returns a new quaternion created from the given rotation matrix values
  4264. */
  4265. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4266. /**
  4267. * Updates the given quaternion with the given rotation matrix values
  4268. * @param matrix defines the source matrix
  4269. * @param result defines the target quaternion
  4270. */
  4271. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4272. /**
  4273. * Returns the dot product (float) between the quaternions "left" and "right"
  4274. * @param left defines the left operand
  4275. * @param right defines the right operand
  4276. * @returns the dot product
  4277. */
  4278. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4279. /**
  4280. * Checks if the two quaternions are close to each other
  4281. * @param quat0 defines the first quaternion to check
  4282. * @param quat1 defines the second quaternion to check
  4283. * @returns true if the two quaternions are close to each other
  4284. */
  4285. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4286. /**
  4287. * Creates an empty quaternion
  4288. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4289. */
  4290. static Zero(): Quaternion;
  4291. /**
  4292. * Inverse a given quaternion
  4293. * @param q defines the source quaternion
  4294. * @returns a new quaternion as the inverted current quaternion
  4295. */
  4296. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4297. /**
  4298. * Inverse a given quaternion
  4299. * @param q defines the source quaternion
  4300. * @param result the quaternion the result will be stored in
  4301. * @returns the result quaternion
  4302. */
  4303. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4304. /**
  4305. * Creates an identity quaternion
  4306. * @returns the identity quaternion
  4307. */
  4308. static Identity(): Quaternion;
  4309. /**
  4310. * Gets a boolean indicating if the given quaternion is identity
  4311. * @param quaternion defines the quaternion to check
  4312. * @returns true if the quaternion is identity
  4313. */
  4314. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4315. /**
  4316. * Creates a quaternion from a rotation around an axis
  4317. * @param axis defines the axis to use
  4318. * @param angle defines the angle to use
  4319. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4320. */
  4321. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4322. /**
  4323. * Creates a rotation around an axis and stores it into the given quaternion
  4324. * @param axis defines the axis to use
  4325. * @param angle defines the angle to use
  4326. * @param result defines the target quaternion
  4327. * @returns the target quaternion
  4328. */
  4329. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4330. /**
  4331. * Creates a new quaternion from data stored into an array
  4332. * @param array defines the data source
  4333. * @param offset defines the offset in the source array where the data starts
  4334. * @returns a new quaternion
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4337. /**
  4338. * Updates the given quaternion "result" from the starting index of the given array.
  4339. * @param array the array to pull values from
  4340. * @param offset the offset into the array to start at
  4341. * @param result the quaternion to store the result in
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4344. /**
  4345. * Create a quaternion from Euler rotation angles
  4346. * @param x Pitch
  4347. * @param y Yaw
  4348. * @param z Roll
  4349. * @returns the new Quaternion
  4350. */
  4351. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4352. /**
  4353. * Updates a quaternion from Euler rotation angles
  4354. * @param x Pitch
  4355. * @param y Yaw
  4356. * @param z Roll
  4357. * @param result the quaternion to store the result
  4358. * @returns the updated quaternion
  4359. */
  4360. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4361. /**
  4362. * Create a quaternion from Euler rotation vector
  4363. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4364. * @returns the new Quaternion
  4365. */
  4366. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4367. /**
  4368. * Updates a quaternion from Euler rotation vector
  4369. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4370. * @param result the quaternion to store the result
  4371. * @returns the updated quaternion
  4372. */
  4373. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4374. /**
  4375. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4376. * @param yaw defines the rotation around Y axis
  4377. * @param pitch defines the rotation around X axis
  4378. * @param roll defines the rotation around Z axis
  4379. * @returns the new quaternion
  4380. */
  4381. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4382. /**
  4383. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4384. * @param yaw defines the rotation around Y axis
  4385. * @param pitch defines the rotation around X axis
  4386. * @param roll defines the rotation around Z axis
  4387. * @param result defines the target quaternion
  4388. */
  4389. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4390. /**
  4391. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4392. * @param alpha defines the rotation around first axis
  4393. * @param beta defines the rotation around second axis
  4394. * @param gamma defines the rotation around third axis
  4395. * @returns the new quaternion
  4396. */
  4397. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4398. /**
  4399. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4400. * @param alpha defines the rotation around first axis
  4401. * @param beta defines the rotation around second axis
  4402. * @param gamma defines the rotation around third axis
  4403. * @param result defines the target quaternion
  4404. */
  4405. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4406. /**
  4407. * 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)
  4408. * @param axis1 defines the first axis
  4409. * @param axis2 defines the second axis
  4410. * @param axis3 defines the third axis
  4411. * @returns the new quaternion
  4412. */
  4413. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4414. /**
  4415. * 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
  4416. * @param axis1 defines the first axis
  4417. * @param axis2 defines the second axis
  4418. * @param axis3 defines the third axis
  4419. * @param ref defines the target quaternion
  4420. */
  4421. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4422. /**
  4423. * Interpolates between two quaternions
  4424. * @param left defines first quaternion
  4425. * @param right defines second quaternion
  4426. * @param amount defines the gradient to use
  4427. * @returns the new interpolated quaternion
  4428. */
  4429. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4430. /**
  4431. * Interpolates between two quaternions and stores it into a target quaternion
  4432. * @param left defines first quaternion
  4433. * @param right defines second quaternion
  4434. * @param amount defines the gradient to use
  4435. * @param result defines the target quaternion
  4436. */
  4437. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4438. /**
  4439. * Interpolate between two quaternions using Hermite interpolation
  4440. * @param value1 defines first quaternion
  4441. * @param tangent1 defines the incoming tangent
  4442. * @param value2 defines second quaternion
  4443. * @param tangent2 defines the outgoing tangent
  4444. * @param amount defines the target quaternion
  4445. * @returns the new interpolated quaternion
  4446. */
  4447. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4448. }
  4449. /**
  4450. * Class used to store matrix data (4x4)
  4451. */
  4452. export class Matrix {
  4453. /**
  4454. * Gets the precision of matrix computations
  4455. */
  4456. static get Use64Bits(): boolean;
  4457. private static _updateFlagSeed;
  4458. private static _identityReadOnly;
  4459. private _isIdentity;
  4460. private _isIdentityDirty;
  4461. private _isIdentity3x2;
  4462. private _isIdentity3x2Dirty;
  4463. /**
  4464. * Gets the update flag of the matrix which is an unique number for the matrix.
  4465. * It will be incremented every time the matrix data change.
  4466. * You can use it to speed the comparison between two versions of the same matrix.
  4467. */
  4468. updateFlag: number;
  4469. private readonly _m;
  4470. /**
  4471. * Gets the internal data of the matrix
  4472. */
  4473. get m(): DeepImmutable<Float32Array | Array<number>>;
  4474. /** @hidden */
  4475. _markAsUpdated(): void;
  4476. /** @hidden */
  4477. private _updateIdentityStatus;
  4478. /**
  4479. * Creates an empty matrix (filled with zeros)
  4480. */
  4481. constructor();
  4482. /**
  4483. * Check if the current matrix is identity
  4484. * @returns true is the matrix is the identity matrix
  4485. */
  4486. isIdentity(): boolean;
  4487. /**
  4488. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4489. * @returns true is the matrix is the identity matrix
  4490. */
  4491. isIdentityAs3x2(): boolean;
  4492. /**
  4493. * Gets the determinant of the matrix
  4494. * @returns the matrix determinant
  4495. */
  4496. determinant(): number;
  4497. /**
  4498. * Returns the matrix as a Float32Array or Array<number>
  4499. * @returns the matrix underlying array
  4500. */
  4501. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4502. /**
  4503. * Returns the matrix as a Float32Array or Array<number>
  4504. * @returns the matrix underlying array.
  4505. */
  4506. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4507. /**
  4508. * Inverts the current matrix in place
  4509. * @returns the current inverted matrix
  4510. */
  4511. invert(): Matrix;
  4512. /**
  4513. * Sets all the matrix elements to zero
  4514. * @returns the current matrix
  4515. */
  4516. reset(): Matrix;
  4517. /**
  4518. * Adds the current matrix with a second one
  4519. * @param other defines the matrix to add
  4520. * @returns a new matrix as the addition of the current matrix and the given one
  4521. */
  4522. add(other: DeepImmutable<Matrix>): Matrix;
  4523. /**
  4524. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4525. * @param other defines the matrix to add
  4526. * @param result defines the target matrix
  4527. * @returns the current matrix
  4528. */
  4529. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4530. /**
  4531. * Adds in place the given matrix to the current matrix
  4532. * @param other defines the second operand
  4533. * @returns the current updated matrix
  4534. */
  4535. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4536. /**
  4537. * Sets the given matrix to the current inverted Matrix
  4538. * @param other defines the target matrix
  4539. * @returns the unmodified current matrix
  4540. */
  4541. invertToRef(other: Matrix): Matrix;
  4542. /**
  4543. * add a value at the specified position in the current Matrix
  4544. * @param index the index of the value within the matrix. between 0 and 15.
  4545. * @param value the value to be added
  4546. * @returns the current updated matrix
  4547. */
  4548. addAtIndex(index: number, value: number): Matrix;
  4549. /**
  4550. * mutiply the specified position in the current Matrix by a value
  4551. * @param index the index of the value within the matrix. between 0 and 15.
  4552. * @param value the value to be added
  4553. * @returns the current updated matrix
  4554. */
  4555. multiplyAtIndex(index: number, value: number): Matrix;
  4556. /**
  4557. * Inserts the translation vector (using 3 floats) in the current matrix
  4558. * @param x defines the 1st component of the translation
  4559. * @param y defines the 2nd component of the translation
  4560. * @param z defines the 3rd component of the translation
  4561. * @returns the current updated matrix
  4562. */
  4563. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4564. /**
  4565. * Adds the translation vector (using 3 floats) in the current matrix
  4566. * @param x defines the 1st component of the translation
  4567. * @param y defines the 2nd component of the translation
  4568. * @param z defines the 3rd component of the translation
  4569. * @returns the current updated matrix
  4570. */
  4571. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4572. /**
  4573. * Inserts the translation vector in the current matrix
  4574. * @param vector3 defines the translation to insert
  4575. * @returns the current updated matrix
  4576. */
  4577. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * Gets the translation value of the current matrix
  4580. * @returns a new Vector3 as the extracted translation from the matrix
  4581. */
  4582. getTranslation(): Vector3;
  4583. /**
  4584. * Fill a Vector3 with the extracted translation from the matrix
  4585. * @param result defines the Vector3 where to store the translation
  4586. * @returns the current matrix
  4587. */
  4588. getTranslationToRef(result: Vector3): Matrix;
  4589. /**
  4590. * Remove rotation and scaling part from the matrix
  4591. * @returns the updated matrix
  4592. */
  4593. removeRotationAndScaling(): Matrix;
  4594. /**
  4595. * Multiply two matrices
  4596. * @param other defines the second operand
  4597. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4598. */
  4599. multiply(other: DeepImmutable<Matrix>): Matrix;
  4600. /**
  4601. * Copy the current matrix from the given one
  4602. * @param other defines the source matrix
  4603. * @returns the current updated matrix
  4604. */
  4605. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4606. /**
  4607. * Populates the given array from the starting index with the current matrix values
  4608. * @param array defines the target array
  4609. * @param offset defines the offset in the target array where to start storing values
  4610. * @returns the current matrix
  4611. */
  4612. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4613. /**
  4614. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4615. * @param other defines the second operand
  4616. * @param result defines the matrix where to store the multiplication
  4617. * @returns the current matrix
  4618. */
  4619. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4620. /**
  4621. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4622. * @param other defines the second operand
  4623. * @param result defines the array where to store the multiplication
  4624. * @param offset defines the offset in the target array where to start storing values
  4625. * @returns the current matrix
  4626. */
  4627. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4628. /**
  4629. * Check equality between this matrix and a second one
  4630. * @param value defines the second matrix to compare
  4631. * @returns true is the current matrix and the given one values are strictly equal
  4632. */
  4633. equals(value: DeepImmutable<Matrix>): boolean;
  4634. /**
  4635. * Clone the current matrix
  4636. * @returns a new matrix from the current matrix
  4637. */
  4638. clone(): Matrix;
  4639. /**
  4640. * Returns the name of the current matrix class
  4641. * @returns the string "Matrix"
  4642. */
  4643. getClassName(): string;
  4644. /**
  4645. * Gets the hash code of the current matrix
  4646. * @returns the hash code
  4647. */
  4648. getHashCode(): number;
  4649. /**
  4650. * Decomposes the current Matrix into a translation, rotation and scaling components
  4651. * @param scale defines the scale vector3 given as a reference to update
  4652. * @param rotation defines the rotation quaternion given as a reference to update
  4653. * @param translation defines the translation vector3 given as a reference to update
  4654. * @returns true if operation was successful
  4655. */
  4656. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4657. /**
  4658. * Gets specific row of the matrix
  4659. * @param index defines the number of the row to get
  4660. * @returns the index-th row of the current matrix as a new Vector4
  4661. */
  4662. getRow(index: number): Nullable<Vector4>;
  4663. /**
  4664. * Sets the index-th row of the current matrix to the vector4 values
  4665. * @param index defines the number of the row to set
  4666. * @param row defines the target vector4
  4667. * @returns the updated current matrix
  4668. */
  4669. setRow(index: number, row: Vector4): Matrix;
  4670. /**
  4671. * Compute the transpose of the matrix
  4672. * @returns the new transposed matrix
  4673. */
  4674. transpose(): Matrix;
  4675. /**
  4676. * Compute the transpose of the matrix and store it in a given matrix
  4677. * @param result defines the target matrix
  4678. * @returns the current matrix
  4679. */
  4680. transposeToRef(result: Matrix): Matrix;
  4681. /**
  4682. * Sets the index-th row of the current matrix with the given 4 x float values
  4683. * @param index defines the row index
  4684. * @param x defines the x component to set
  4685. * @param y defines the y component to set
  4686. * @param z defines the z component to set
  4687. * @param w defines the w component to set
  4688. * @returns the updated current matrix
  4689. */
  4690. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4691. /**
  4692. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4693. * @param scale defines the scale factor
  4694. * @returns a new matrix
  4695. */
  4696. scale(scale: number): Matrix;
  4697. /**
  4698. * Scale the current matrix values by a factor to a given result matrix
  4699. * @param scale defines the scale factor
  4700. * @param result defines the matrix to store the result
  4701. * @returns the current matrix
  4702. */
  4703. scaleToRef(scale: number, result: Matrix): Matrix;
  4704. /**
  4705. * Scale the current matrix values by a factor and add the result to a given matrix
  4706. * @param scale defines the scale factor
  4707. * @param result defines the Matrix to store the result
  4708. * @returns the current matrix
  4709. */
  4710. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4711. /**
  4712. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4713. * @param ref matrix to store the result
  4714. */
  4715. toNormalMatrix(ref: Matrix): void;
  4716. /**
  4717. * Gets only rotation part of the current matrix
  4718. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4719. */
  4720. getRotationMatrix(): Matrix;
  4721. /**
  4722. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4723. * @param result defines the target matrix to store data to
  4724. * @returns the current matrix
  4725. */
  4726. getRotationMatrixToRef(result: Matrix): Matrix;
  4727. /**
  4728. * Toggles model matrix from being right handed to left handed in place and vice versa
  4729. */
  4730. toggleModelMatrixHandInPlace(): void;
  4731. /**
  4732. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4733. */
  4734. toggleProjectionMatrixHandInPlace(): void;
  4735. /**
  4736. * Creates a matrix from an array
  4737. * @param array defines the source array
  4738. * @param offset defines an offset in the source array
  4739. * @returns a new Matrix set from the starting index of the given array
  4740. */
  4741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4742. /**
  4743. * Copy the content of an array into a given matrix
  4744. * @param array defines the source array
  4745. * @param offset defines an offset in the source array
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4749. /**
  4750. * Stores an array into a matrix after having multiplied each component by a given factor
  4751. * @param array defines the source array
  4752. * @param offset defines the offset in the source array
  4753. * @param scale defines the scaling factor
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4757. /**
  4758. * Gets an identity matrix that must not be updated
  4759. */
  4760. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4761. /**
  4762. * Stores a list of values (16) inside a given matrix
  4763. * @param initialM11 defines 1st value of 1st row
  4764. * @param initialM12 defines 2nd value of 1st row
  4765. * @param initialM13 defines 3rd value of 1st row
  4766. * @param initialM14 defines 4th value of 1st row
  4767. * @param initialM21 defines 1st value of 2nd row
  4768. * @param initialM22 defines 2nd value of 2nd row
  4769. * @param initialM23 defines 3rd value of 2nd row
  4770. * @param initialM24 defines 4th value of 2nd row
  4771. * @param initialM31 defines 1st value of 3rd row
  4772. * @param initialM32 defines 2nd value of 3rd row
  4773. * @param initialM33 defines 3rd value of 3rd row
  4774. * @param initialM34 defines 4th value of 3rd row
  4775. * @param initialM41 defines 1st value of 4th row
  4776. * @param initialM42 defines 2nd value of 4th row
  4777. * @param initialM43 defines 3rd value of 4th row
  4778. * @param initialM44 defines 4th value of 4th row
  4779. * @param result defines the target matrix
  4780. */
  4781. 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;
  4782. /**
  4783. * Creates new matrix from a list of values (16)
  4784. * @param initialM11 defines 1st value of 1st row
  4785. * @param initialM12 defines 2nd value of 1st row
  4786. * @param initialM13 defines 3rd value of 1st row
  4787. * @param initialM14 defines 4th value of 1st row
  4788. * @param initialM21 defines 1st value of 2nd row
  4789. * @param initialM22 defines 2nd value of 2nd row
  4790. * @param initialM23 defines 3rd value of 2nd row
  4791. * @param initialM24 defines 4th value of 2nd row
  4792. * @param initialM31 defines 1st value of 3rd row
  4793. * @param initialM32 defines 2nd value of 3rd row
  4794. * @param initialM33 defines 3rd value of 3rd row
  4795. * @param initialM34 defines 4th value of 3rd row
  4796. * @param initialM41 defines 1st value of 4th row
  4797. * @param initialM42 defines 2nd value of 4th row
  4798. * @param initialM43 defines 3rd value of 4th row
  4799. * @param initialM44 defines 4th value of 4th row
  4800. * @returns the new matrix
  4801. */
  4802. 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;
  4803. /**
  4804. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4805. * @param scale defines the scale vector3
  4806. * @param rotation defines the rotation quaternion
  4807. * @param translation defines the translation vector3
  4808. * @returns a new matrix
  4809. */
  4810. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4811. /**
  4812. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4813. * @param scale defines the scale vector3
  4814. * @param rotation defines the rotation quaternion
  4815. * @param translation defines the translation vector3
  4816. * @param result defines the target matrix
  4817. */
  4818. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4819. /**
  4820. * Creates a new identity matrix
  4821. * @returns a new identity matrix
  4822. */
  4823. static Identity(): Matrix;
  4824. /**
  4825. * Creates a new identity matrix and stores the result in a given matrix
  4826. * @param result defines the target matrix
  4827. */
  4828. static IdentityToRef(result: Matrix): void;
  4829. /**
  4830. * Creates a new zero matrix
  4831. * @returns a new zero matrix
  4832. */
  4833. static Zero(): Matrix;
  4834. /**
  4835. * Creates a new rotation matrix for "angle" radians around the X axis
  4836. * @param angle defines the angle (in radians) to use
  4837. * @return the new matrix
  4838. */
  4839. static RotationX(angle: number): Matrix;
  4840. /**
  4841. * Creates a new matrix as the invert of a given matrix
  4842. * @param source defines the source matrix
  4843. * @returns the new matrix
  4844. */
  4845. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4846. /**
  4847. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4848. * @param angle defines the angle (in radians) to use
  4849. * @param result defines the target matrix
  4850. */
  4851. static RotationXToRef(angle: number, result: Matrix): void;
  4852. /**
  4853. * Creates a new rotation matrix for "angle" radians around the Y axis
  4854. * @param angle defines the angle (in radians) to use
  4855. * @return the new matrix
  4856. */
  4857. static RotationY(angle: number): Matrix;
  4858. /**
  4859. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4860. * @param angle defines the angle (in radians) to use
  4861. * @param result defines the target matrix
  4862. */
  4863. static RotationYToRef(angle: number, result: Matrix): void;
  4864. /**
  4865. * Creates a new rotation matrix for "angle" radians around the Z axis
  4866. * @param angle defines the angle (in radians) to use
  4867. * @return the new matrix
  4868. */
  4869. static RotationZ(angle: number): Matrix;
  4870. /**
  4871. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4872. * @param angle defines the angle (in radians) to use
  4873. * @param result defines the target matrix
  4874. */
  4875. static RotationZToRef(angle: number, result: Matrix): void;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the given axis
  4878. * @param axis defines the axis to use
  4879. * @param angle defines the angle (in radians) to use
  4880. * @return the new matrix
  4881. */
  4882. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4883. /**
  4884. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4885. * @param axis defines the axis to use
  4886. * @param angle defines the angle (in radians) to use
  4887. * @param result defines the target matrix
  4888. */
  4889. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4890. /**
  4891. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4892. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4893. * @param from defines the vector to align
  4894. * @param to defines the vector to align to
  4895. * @param result defines the target matrix
  4896. */
  4897. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4898. /**
  4899. * Creates a rotation matrix
  4900. * @param yaw defines the yaw angle in radians (Y axis)
  4901. * @param pitch defines the pitch angle in radians (X axis)
  4902. * @param roll defines the roll angle in radians (Z axis)
  4903. * @returns the new rotation matrix
  4904. */
  4905. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4906. /**
  4907. * Creates a rotation matrix and stores it in a given matrix
  4908. * @param yaw defines the yaw angle in radians (Y axis)
  4909. * @param pitch defines the pitch angle in radians (X axis)
  4910. * @param roll defines the roll angle in radians (Z axis)
  4911. * @param result defines the target matrix
  4912. */
  4913. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4914. /**
  4915. * Creates a scaling matrix
  4916. * @param x defines the scale factor on X axis
  4917. * @param y defines the scale factor on Y axis
  4918. * @param z defines the scale factor on Z axis
  4919. * @returns the new matrix
  4920. */
  4921. static Scaling(x: number, y: number, z: number): Matrix;
  4922. /**
  4923. * Creates a scaling matrix and stores it in a given matrix
  4924. * @param x defines the scale factor on X axis
  4925. * @param y defines the scale factor on Y axis
  4926. * @param z defines the scale factor on Z axis
  4927. * @param result defines the target matrix
  4928. */
  4929. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4930. /**
  4931. * Creates a translation matrix
  4932. * @param x defines the translation on X axis
  4933. * @param y defines the translation on Y axis
  4934. * @param z defines the translationon Z axis
  4935. * @returns the new matrix
  4936. */
  4937. static Translation(x: number, y: number, z: number): Matrix;
  4938. /**
  4939. * Creates a translation matrix and stores it in a given matrix
  4940. * @param x defines the translation on X axis
  4941. * @param y defines the translation on Y axis
  4942. * @param z defines the translationon Z axis
  4943. * @param result defines the target matrix
  4944. */
  4945. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4946. /**
  4947. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4948. * @param startValue defines the start value
  4949. * @param endValue defines the end value
  4950. * @param gradient defines the gradient factor
  4951. * @returns the new matrix
  4952. */
  4953. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4954. /**
  4955. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4956. * @param startValue defines the start value
  4957. * @param endValue defines the end value
  4958. * @param gradient defines the gradient factor
  4959. * @param result defines the Matrix object where to store data
  4960. */
  4961. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4962. /**
  4963. * Builds a new matrix whose values are computed by:
  4964. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4965. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4966. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4967. * @param startValue defines the first matrix
  4968. * @param endValue defines the second matrix
  4969. * @param gradient defines the gradient between the two matrices
  4970. * @returns the new matrix
  4971. */
  4972. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4973. /**
  4974. * Update a matrix to values which are computed by:
  4975. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4976. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4977. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4978. * @param startValue defines the first matrix
  4979. * @param endValue defines the second matrix
  4980. * @param gradient defines the gradient between the two matrices
  4981. * @param result defines the target matrix
  4982. */
  4983. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4984. /**
  4985. * 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"
  4986. * This function works in left handed mode
  4987. * @param eye defines the final position of the entity
  4988. * @param target defines where the entity should look at
  4989. * @param up defines the up vector for the entity
  4990. * @returns the new matrix
  4991. */
  4992. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4993. /**
  4994. * 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".
  4995. * This function works in left handed mode
  4996. * @param eye defines the final position of the entity
  4997. * @param target defines where the entity should look at
  4998. * @param up defines the up vector for the entity
  4999. * @param result defines the target matrix
  5000. */
  5001. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5002. /**
  5003. * 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"
  5004. * This function works in right handed mode
  5005. * @param eye defines the final position of the entity
  5006. * @param target defines where the entity should look at
  5007. * @param up defines the up vector for the entity
  5008. * @returns the new matrix
  5009. */
  5010. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5011. /**
  5012. * 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".
  5013. * This function works in right handed mode
  5014. * @param eye defines the final position of the entity
  5015. * @param target defines where the entity should look at
  5016. * @param up defines the up vector for the entity
  5017. * @param result defines the target matrix
  5018. */
  5019. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5020. /**
  5021. * Create a left-handed orthographic projection matrix
  5022. * @param width defines the viewport width
  5023. * @param height defines the viewport height
  5024. * @param znear defines the near clip plane
  5025. * @param zfar defines the far clip plane
  5026. * @returns a new matrix as a left-handed orthographic projection matrix
  5027. */
  5028. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5029. /**
  5030. * Store a left-handed orthographic projection to a given matrix
  5031. * @param width defines the viewport width
  5032. * @param height defines the viewport height
  5033. * @param znear defines the near clip plane
  5034. * @param zfar defines the far clip plane
  5035. * @param result defines the target matrix
  5036. */
  5037. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5038. /**
  5039. * Create a left-handed orthographic projection matrix
  5040. * @param left defines the viewport left coordinate
  5041. * @param right defines the viewport right coordinate
  5042. * @param bottom defines the viewport bottom coordinate
  5043. * @param top defines the viewport top coordinate
  5044. * @param znear defines the near clip plane
  5045. * @param zfar defines the far clip plane
  5046. * @returns a new matrix as a left-handed orthographic projection matrix
  5047. */
  5048. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5049. /**
  5050. * Stores a left-handed orthographic projection into a given matrix
  5051. * @param left defines the viewport left coordinate
  5052. * @param right defines the viewport right coordinate
  5053. * @param bottom defines the viewport bottom coordinate
  5054. * @param top defines the viewport top coordinate
  5055. * @param znear defines the near clip plane
  5056. * @param zfar defines the far clip plane
  5057. * @param result defines the target matrix
  5058. */
  5059. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5060. /**
  5061. * Creates a right-handed orthographic projection matrix
  5062. * @param left defines the viewport left coordinate
  5063. * @param right defines the viewport right coordinate
  5064. * @param bottom defines the viewport bottom coordinate
  5065. * @param top defines the viewport top coordinate
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a right-handed orthographic projection matrix
  5069. */
  5070. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Stores a right-handed orthographic projection into a given matrix
  5073. * @param left defines the viewport left coordinate
  5074. * @param right defines the viewport right coordinate
  5075. * @param bottom defines the viewport bottom coordinate
  5076. * @param top defines the viewport top coordinate
  5077. * @param znear defines the near clip plane
  5078. * @param zfar defines the far clip plane
  5079. * @param result defines the target matrix
  5080. */
  5081. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5082. /**
  5083. * Creates a left-handed perspective projection matrix
  5084. * @param width defines the viewport width
  5085. * @param height defines the viewport height
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed perspective projection matrix
  5089. */
  5090. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Creates a left-handed perspective projection matrix
  5093. * @param fov defines the horizontal field of view
  5094. * @param aspect defines the aspect ratio
  5095. * @param znear defines the near clip plane
  5096. * @param zfar defines the far clip plane
  5097. * @returns a new matrix as a left-handed perspective projection matrix
  5098. */
  5099. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5100. /**
  5101. * Stores a left-handed perspective projection into a given matrix
  5102. * @param fov defines the horizontal field of view
  5103. * @param aspect defines the aspect ratio
  5104. * @param znear defines the near clip plane
  5105. * @param zfar defines the far clip plane
  5106. * @param result defines the target matrix
  5107. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5108. */
  5109. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5110. /**
  5111. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5112. * @param fov defines the horizontal field of view
  5113. * @param aspect defines the aspect ratio
  5114. * @param znear defines the near clip plane
  5115. * @param zfar not used as infinity is used as far clip
  5116. * @param result defines the target matrix
  5117. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5118. */
  5119. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5120. /**
  5121. * Creates a right-handed perspective projection matrix
  5122. * @param fov defines the horizontal field of view
  5123. * @param aspect defines the aspect ratio
  5124. * @param znear defines the near clip plane
  5125. * @param zfar defines the far clip plane
  5126. * @returns a new matrix as a right-handed perspective projection matrix
  5127. */
  5128. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5129. /**
  5130. * Stores a right-handed perspective projection into a given matrix
  5131. * @param fov defines the horizontal field of view
  5132. * @param aspect defines the aspect ratio
  5133. * @param znear defines the near clip plane
  5134. * @param zfar defines the far clip plane
  5135. * @param result defines the target matrix
  5136. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5137. */
  5138. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5139. /**
  5140. * Stores a right-handed perspective projection into a given matrix
  5141. * @param fov defines the horizontal field of view
  5142. * @param aspect defines the aspect ratio
  5143. * @param znear defines the near clip plane
  5144. * @param zfar not used as infinity is used as far clip
  5145. * @param result defines the target matrix
  5146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5147. */
  5148. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5149. /**
  5150. * Stores a perspective projection for WebVR info a given matrix
  5151. * @param fov defines the field of view
  5152. * @param znear defines the near clip plane
  5153. * @param zfar defines the far clip plane
  5154. * @param result defines the target matrix
  5155. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5156. */
  5157. static PerspectiveFovWebVRToRef(fov: {
  5158. upDegrees: number;
  5159. downDegrees: number;
  5160. leftDegrees: number;
  5161. rightDegrees: number;
  5162. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5163. /**
  5164. * Computes a complete transformation matrix
  5165. * @param viewport defines the viewport to use
  5166. * @param world defines the world matrix
  5167. * @param view defines the view matrix
  5168. * @param projection defines the projection matrix
  5169. * @param zmin defines the near clip plane
  5170. * @param zmax defines the far clip plane
  5171. * @returns the transformation matrix
  5172. */
  5173. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5174. /**
  5175. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5176. * @param matrix defines the matrix to use
  5177. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5178. */
  5179. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5180. /**
  5181. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5182. * @param matrix defines the matrix to use
  5183. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5184. */
  5185. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5186. /**
  5187. * Compute the transpose of a given matrix
  5188. * @param matrix defines the matrix to transpose
  5189. * @returns the new matrix
  5190. */
  5191. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5192. /**
  5193. * Compute the transpose of a matrix and store it in a target matrix
  5194. * @param matrix defines the matrix to transpose
  5195. * @param result defines the target matrix
  5196. */
  5197. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5198. /**
  5199. * Computes a reflection matrix from a plane
  5200. * @param plane defines the reflection plane
  5201. * @returns a new matrix
  5202. */
  5203. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5204. /**
  5205. * Computes a reflection matrix from a plane
  5206. * @param plane defines the reflection plane
  5207. * @param result defines the target matrix
  5208. */
  5209. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5210. /**
  5211. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5212. * @param xaxis defines the value of the 1st axis
  5213. * @param yaxis defines the value of the 2nd axis
  5214. * @param zaxis defines the value of the 3rd axis
  5215. * @param result defines the target matrix
  5216. */
  5217. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5218. /**
  5219. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5220. * @param quat defines the quaternion to use
  5221. * @param result defines the target matrix
  5222. */
  5223. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5224. }
  5225. /**
  5226. * @hidden
  5227. */
  5228. export class TmpVectors {
  5229. static Vector2: Vector2[];
  5230. static Vector3: Vector3[];
  5231. static Vector4: Vector4[];
  5232. static Quaternion: Quaternion[];
  5233. static Matrix: Matrix[];
  5234. }
  5235. }
  5236. declare module BABYLON {
  5237. /**
  5238. * Defines potential orientation for back face culling
  5239. */
  5240. export enum Orientation {
  5241. /**
  5242. * Clockwise
  5243. */
  5244. CW = 0,
  5245. /** Counter clockwise */
  5246. CCW = 1
  5247. }
  5248. /** Class used to represent a Bezier curve */
  5249. export class BezierCurve {
  5250. /**
  5251. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5252. * @param t defines the time
  5253. * @param x1 defines the left coordinate on X axis
  5254. * @param y1 defines the left coordinate on Y axis
  5255. * @param x2 defines the right coordinate on X axis
  5256. * @param y2 defines the right coordinate on Y axis
  5257. * @returns the interpolated value
  5258. */
  5259. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5260. }
  5261. /**
  5262. * Defines angle representation
  5263. */
  5264. export class Angle {
  5265. private _radians;
  5266. /**
  5267. * Creates an Angle object of "radians" radians (float).
  5268. * @param radians the angle in radians
  5269. */
  5270. constructor(radians: number);
  5271. /**
  5272. * Get value in degrees
  5273. * @returns the Angle value in degrees (float)
  5274. */
  5275. degrees(): number;
  5276. /**
  5277. * Get value in radians
  5278. * @returns the Angle value in radians (float)
  5279. */
  5280. radians(): number;
  5281. /**
  5282. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5283. * @param a defines first point as the origin
  5284. * @param b defines point
  5285. * @returns a new Angle
  5286. */
  5287. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5288. /**
  5289. * Gets a new Angle object from the given float in radians
  5290. * @param radians defines the angle value in radians
  5291. * @returns a new Angle
  5292. */
  5293. static FromRadians(radians: number): Angle;
  5294. /**
  5295. * Gets a new Angle object from the given float in degrees
  5296. * @param degrees defines the angle value in degrees
  5297. * @returns a new Angle
  5298. */
  5299. static FromDegrees(degrees: number): Angle;
  5300. }
  5301. /**
  5302. * This represents an arc in a 2d space.
  5303. */
  5304. export class Arc2 {
  5305. /** Defines the start point of the arc */
  5306. startPoint: Vector2;
  5307. /** Defines the mid point of the arc */
  5308. midPoint: Vector2;
  5309. /** Defines the end point of the arc */
  5310. endPoint: Vector2;
  5311. /**
  5312. * Defines the center point of the arc.
  5313. */
  5314. centerPoint: Vector2;
  5315. /**
  5316. * Defines the radius of the arc.
  5317. */
  5318. radius: number;
  5319. /**
  5320. * Defines the angle of the arc (from mid point to end point).
  5321. */
  5322. angle: Angle;
  5323. /**
  5324. * Defines the start angle of the arc (from start point to middle point).
  5325. */
  5326. startAngle: Angle;
  5327. /**
  5328. * Defines the orientation of the arc (clock wise/counter clock wise).
  5329. */
  5330. orientation: Orientation;
  5331. /**
  5332. * Creates an Arc object from the three given points : start, middle and end.
  5333. * @param startPoint Defines the start point of the arc
  5334. * @param midPoint Defines the midlle point of the arc
  5335. * @param endPoint Defines the end point of the arc
  5336. */
  5337. constructor(
  5338. /** Defines the start point of the arc */
  5339. startPoint: Vector2,
  5340. /** Defines the mid point of the arc */
  5341. midPoint: Vector2,
  5342. /** Defines the end point of the arc */
  5343. endPoint: Vector2);
  5344. }
  5345. /**
  5346. * Represents a 2D path made up of multiple 2D points
  5347. */
  5348. export class Path2 {
  5349. private _points;
  5350. private _length;
  5351. /**
  5352. * If the path start and end point are the same
  5353. */
  5354. closed: boolean;
  5355. /**
  5356. * Creates a Path2 object from the starting 2D coordinates x and y.
  5357. * @param x the starting points x value
  5358. * @param y the starting points y value
  5359. */
  5360. constructor(x: number, y: number);
  5361. /**
  5362. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5363. * @param x the added points x value
  5364. * @param y the added points y value
  5365. * @returns the updated Path2.
  5366. */
  5367. addLineTo(x: number, y: number): Path2;
  5368. /**
  5369. * 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.
  5370. * @param midX middle point x value
  5371. * @param midY middle point y value
  5372. * @param endX end point x value
  5373. * @param endY end point y value
  5374. * @param numberOfSegments (default: 36)
  5375. * @returns the updated Path2.
  5376. */
  5377. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5378. /**
  5379. * Closes the Path2.
  5380. * @returns the Path2.
  5381. */
  5382. close(): Path2;
  5383. /**
  5384. * Gets the sum of the distance between each sequential point in the path
  5385. * @returns the Path2 total length (float).
  5386. */
  5387. length(): number;
  5388. /**
  5389. * Gets the points which construct the path
  5390. * @returns the Path2 internal array of points.
  5391. */
  5392. getPoints(): Vector2[];
  5393. /**
  5394. * Retreives the point at the distance aways from the starting point
  5395. * @param normalizedLengthPosition the length along the path to retreive the point from
  5396. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5397. */
  5398. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5399. /**
  5400. * Creates a new path starting from an x and y position
  5401. * @param x starting x value
  5402. * @param y starting y value
  5403. * @returns a new Path2 starting at the coordinates (x, y).
  5404. */
  5405. static StartingAt(x: number, y: number): Path2;
  5406. }
  5407. /**
  5408. * Represents a 3D path made up of multiple 3D points
  5409. */
  5410. export class Path3D {
  5411. /**
  5412. * an array of Vector3, the curve axis of the Path3D
  5413. */
  5414. path: Vector3[];
  5415. private _curve;
  5416. private _distances;
  5417. private _tangents;
  5418. private _normals;
  5419. private _binormals;
  5420. private _raw;
  5421. private _alignTangentsWithPath;
  5422. private readonly _pointAtData;
  5423. /**
  5424. * new Path3D(path, normal, raw)
  5425. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5426. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5427. * @param path an array of Vector3, the curve axis of the Path3D
  5428. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5429. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5430. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5431. */
  5432. constructor(
  5433. /**
  5434. * an array of Vector3, the curve axis of the Path3D
  5435. */
  5436. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5437. /**
  5438. * Returns the Path3D array of successive Vector3 designing its curve.
  5439. * @returns the Path3D array of successive Vector3 designing its curve.
  5440. */
  5441. getCurve(): Vector3[];
  5442. /**
  5443. * Returns the Path3D array of successive Vector3 designing its curve.
  5444. * @returns the Path3D array of successive Vector3 designing its curve.
  5445. */
  5446. getPoints(): Vector3[];
  5447. /**
  5448. * @returns the computed length (float) of the path.
  5449. */
  5450. length(): number;
  5451. /**
  5452. * Returns an array populated with tangent vectors on each Path3D curve point.
  5453. * @returns an array populated with tangent vectors on each Path3D curve point.
  5454. */
  5455. getTangents(): Vector3[];
  5456. /**
  5457. * Returns an array populated with normal vectors on each Path3D curve point.
  5458. * @returns an array populated with normal vectors on each Path3D curve point.
  5459. */
  5460. getNormals(): Vector3[];
  5461. /**
  5462. * Returns an array populated with binormal vectors on each Path3D curve point.
  5463. * @returns an array populated with binormal vectors on each Path3D curve point.
  5464. */
  5465. getBinormals(): Vector3[];
  5466. /**
  5467. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5469. */
  5470. getDistances(): number[];
  5471. /**
  5472. * Returns an interpolated point along this path
  5473. * @param position the position of the point along this path, from 0.0 to 1.0
  5474. * @returns a new Vector3 as the point
  5475. */
  5476. getPointAt(position: number): Vector3;
  5477. /**
  5478. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5479. * @param position the position of the point along this path, from 0.0 to 1.0
  5480. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5481. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5482. */
  5483. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5484. /**
  5485. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5486. * @param position the position of the point along this path, from 0.0 to 1.0
  5487. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5488. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5489. */
  5490. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5491. /**
  5492. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5493. * @param position the position of the point along this path, from 0.0 to 1.0
  5494. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5495. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5496. */
  5497. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5498. /**
  5499. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5500. * @param position the position of the point along this path, from 0.0 to 1.0
  5501. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5502. */
  5503. getDistanceAt(position: number): number;
  5504. /**
  5505. * Returns the array index of the previous point of an interpolated point along this path
  5506. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5507. * @returns the array index
  5508. */
  5509. getPreviousPointIndexAt(position: number): number;
  5510. /**
  5511. * 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)
  5512. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5513. * @returns the sub position
  5514. */
  5515. getSubPositionAt(position: number): number;
  5516. /**
  5517. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5518. * @param target the vector of which to get the closest position to
  5519. * @returns the position of the closest virtual point on this path to the target vector
  5520. */
  5521. getClosestPositionTo(target: Vector3): number;
  5522. /**
  5523. * Returns a sub path (slice) of this path
  5524. * @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
  5525. * @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
  5526. * @returns a sub path (slice) of this path
  5527. */
  5528. slice(start?: number, end?: number): Path3D;
  5529. /**
  5530. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5531. * @param path path which all values are copied into the curves points
  5532. * @param firstNormal which should be projected onto the curve
  5533. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5534. * @returns the same object updated.
  5535. */
  5536. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5537. private _compute;
  5538. private _getFirstNonNullVector;
  5539. private _getLastNonNullVector;
  5540. private _normalVector;
  5541. /**
  5542. * Updates the point at data for an interpolated point along this curve
  5543. * @param position the position of the point along this curve, from 0.0 to 1.0
  5544. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5545. * @returns the (updated) point at data
  5546. */
  5547. private _updatePointAtData;
  5548. /**
  5549. * Updates the point at data from the specified parameters
  5550. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5551. * @param point the interpolated point
  5552. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5553. */
  5554. private _setPointAtData;
  5555. /**
  5556. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5557. */
  5558. private _updateInterpolationMatrix;
  5559. }
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5564. */
  5565. export class Curve3 {
  5566. private _points;
  5567. private _length;
  5568. /**
  5569. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5570. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5571. * @param v1 (Vector3) the control point
  5572. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5573. * @param nbPoints (integer) the wanted number of points in the curve
  5574. * @returns the created Curve3
  5575. */
  5576. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5577. /**
  5578. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5579. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5580. * @param v1 (Vector3) the first control point
  5581. * @param v2 (Vector3) the second control point
  5582. * @param v3 (Vector3) the end point of the Cubic Bezier
  5583. * @param nbPoints (integer) the wanted number of points in the curve
  5584. * @returns the created Curve3
  5585. */
  5586. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5587. /**
  5588. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5589. * @param p1 (Vector3) the origin point of the Hermite Spline
  5590. * @param t1 (Vector3) the tangent vector at the origin point
  5591. * @param p2 (Vector3) the end point of the Hermite Spline
  5592. * @param t2 (Vector3) the tangent vector at the end point
  5593. * @param nbPoints (integer) the wanted number of points in the curve
  5594. * @returns the created Curve3
  5595. */
  5596. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5597. /**
  5598. * Returns a Curve3 object along a CatmullRom Spline curve :
  5599. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5600. * @param nbPoints (integer) the wanted number of points between each curve control points
  5601. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5602. * @returns the created Curve3
  5603. */
  5604. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5605. /**
  5606. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5607. * A Curve3 is designed from a series of successive Vector3.
  5608. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5609. * @param points points which make up the curve
  5610. */
  5611. constructor(points: Vector3[]);
  5612. /**
  5613. * @returns the Curve3 stored array of successive Vector3
  5614. */
  5615. getPoints(): Vector3[];
  5616. /**
  5617. * @returns the computed length (float) of the curve.
  5618. */
  5619. length(): number;
  5620. /**
  5621. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5622. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5623. * curveA and curveB keep unchanged.
  5624. * @param curve the curve to continue from this curve
  5625. * @returns the newly constructed curve
  5626. */
  5627. continue(curve: DeepImmutable<Curve3>): Curve3;
  5628. private _computeLength;
  5629. }
  5630. }
  5631. declare module BABYLON {
  5632. /**
  5633. * This represents the main contract an easing function should follow.
  5634. * Easing functions are used throughout the animation system.
  5635. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5636. */
  5637. export interface IEasingFunction {
  5638. /**
  5639. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5640. * of the easing function.
  5641. * The link below provides some of the most common examples of easing functions.
  5642. * @see https://easings.net/
  5643. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5644. * @returns the corresponding value on the curve defined by the easing function
  5645. */
  5646. ease(gradient: number): number;
  5647. }
  5648. /**
  5649. * Base class used for every default easing function.
  5650. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5651. */
  5652. export class EasingFunction implements IEasingFunction {
  5653. /**
  5654. * Interpolation follows the mathematical formula associated with the easing function.
  5655. */
  5656. static readonly EASINGMODE_EASEIN: number;
  5657. /**
  5658. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5659. */
  5660. static readonly EASINGMODE_EASEOUT: number;
  5661. /**
  5662. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5663. */
  5664. static readonly EASINGMODE_EASEINOUT: number;
  5665. private _easingMode;
  5666. /**
  5667. * Sets the easing mode of the current function.
  5668. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5669. */
  5670. setEasingMode(easingMode: number): void;
  5671. /**
  5672. * Gets the current easing mode.
  5673. * @returns the easing mode
  5674. */
  5675. getEasingMode(): number;
  5676. /**
  5677. * @hidden
  5678. */
  5679. easeInCore(gradient: number): number;
  5680. /**
  5681. * Given an input gradient between 0 and 1, this returns the corresponding value
  5682. * of the easing function.
  5683. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5684. * @returns the corresponding value on the curve defined by the easing function
  5685. */
  5686. ease(gradient: number): number;
  5687. }
  5688. /**
  5689. * Easing function with a circle shape (see link below).
  5690. * @see https://easings.net/#easeInCirc
  5691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5692. */
  5693. export class CircleEase extends EasingFunction implements IEasingFunction {
  5694. /** @hidden */
  5695. easeInCore(gradient: number): number;
  5696. }
  5697. /**
  5698. * Easing function with a ease back shape (see link below).
  5699. * @see https://easings.net/#easeInBack
  5700. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5701. */
  5702. export class BackEase extends EasingFunction implements IEasingFunction {
  5703. /** Defines the amplitude of the function */
  5704. amplitude: number;
  5705. /**
  5706. * Instantiates a back ease easing
  5707. * @see https://easings.net/#easeInBack
  5708. * @param amplitude Defines the amplitude of the function
  5709. */
  5710. constructor(
  5711. /** Defines the amplitude of the function */
  5712. amplitude?: number);
  5713. /** @hidden */
  5714. easeInCore(gradient: number): number;
  5715. }
  5716. /**
  5717. * Easing function with a bouncing shape (see link below).
  5718. * @see https://easings.net/#easeInBounce
  5719. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5720. */
  5721. export class BounceEase extends EasingFunction implements IEasingFunction {
  5722. /** Defines the number of bounces */
  5723. bounces: number;
  5724. /** Defines the amplitude of the bounce */
  5725. bounciness: number;
  5726. /**
  5727. * Instantiates a bounce easing
  5728. * @see https://easings.net/#easeInBounce
  5729. * @param bounces Defines the number of bounces
  5730. * @param bounciness Defines the amplitude of the bounce
  5731. */
  5732. constructor(
  5733. /** Defines the number of bounces */
  5734. bounces?: number,
  5735. /** Defines the amplitude of the bounce */
  5736. bounciness?: number);
  5737. /** @hidden */
  5738. easeInCore(gradient: number): number;
  5739. }
  5740. /**
  5741. * Easing function with a power of 3 shape (see link below).
  5742. * @see https://easings.net/#easeInCubic
  5743. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5744. */
  5745. export class CubicEase extends EasingFunction implements IEasingFunction {
  5746. /** @hidden */
  5747. easeInCore(gradient: number): number;
  5748. }
  5749. /**
  5750. * Easing function with an elastic shape (see link below).
  5751. * @see https://easings.net/#easeInElastic
  5752. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5753. */
  5754. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5755. /** Defines the number of oscillations*/
  5756. oscillations: number;
  5757. /** Defines the amplitude of the oscillations*/
  5758. springiness: number;
  5759. /**
  5760. * Instantiates an elastic easing function
  5761. * @see https://easings.net/#easeInElastic
  5762. * @param oscillations Defines the number of oscillations
  5763. * @param springiness Defines the amplitude of the oscillations
  5764. */
  5765. constructor(
  5766. /** Defines the number of oscillations*/
  5767. oscillations?: number,
  5768. /** Defines the amplitude of the oscillations*/
  5769. springiness?: number);
  5770. /** @hidden */
  5771. easeInCore(gradient: number): number;
  5772. }
  5773. /**
  5774. * Easing function with an exponential shape (see link below).
  5775. * @see https://easings.net/#easeInExpo
  5776. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5777. */
  5778. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5779. /** Defines the exponent of the function */
  5780. exponent: number;
  5781. /**
  5782. * Instantiates an exponential easing function
  5783. * @see https://easings.net/#easeInExpo
  5784. * @param exponent Defines the exponent of the function
  5785. */
  5786. constructor(
  5787. /** Defines the exponent of the function */
  5788. exponent?: number);
  5789. /** @hidden */
  5790. easeInCore(gradient: number): number;
  5791. }
  5792. /**
  5793. * Easing function with a power shape (see link below).
  5794. * @see https://easings.net/#easeInQuad
  5795. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5796. */
  5797. export class PowerEase extends EasingFunction implements IEasingFunction {
  5798. /** Defines the power of the function */
  5799. power: number;
  5800. /**
  5801. * Instantiates an power base easing function
  5802. * @see https://easings.net/#easeInQuad
  5803. * @param power Defines the power of the function
  5804. */
  5805. constructor(
  5806. /** Defines the power of the function */
  5807. power?: number);
  5808. /** @hidden */
  5809. easeInCore(gradient: number): number;
  5810. }
  5811. /**
  5812. * Easing function with a power of 2 shape (see link below).
  5813. * @see https://easings.net/#easeInQuad
  5814. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5815. */
  5816. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5817. /** @hidden */
  5818. easeInCore(gradient: number): number;
  5819. }
  5820. /**
  5821. * Easing function with a power of 4 shape (see link below).
  5822. * @see https://easings.net/#easeInQuart
  5823. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5824. */
  5825. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5826. /** @hidden */
  5827. easeInCore(gradient: number): number;
  5828. }
  5829. /**
  5830. * Easing function with a power of 5 shape (see link below).
  5831. * @see https://easings.net/#easeInQuint
  5832. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5833. */
  5834. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5835. /** @hidden */
  5836. easeInCore(gradient: number): number;
  5837. }
  5838. /**
  5839. * Easing function with a sin shape (see link below).
  5840. * @see https://easings.net/#easeInSine
  5841. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5842. */
  5843. export class SineEase extends EasingFunction implements IEasingFunction {
  5844. /** @hidden */
  5845. easeInCore(gradient: number): number;
  5846. }
  5847. /**
  5848. * Easing function with a bezier shape (see link below).
  5849. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5850. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5851. */
  5852. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5853. /** Defines the x component of the start tangent in the bezier curve */
  5854. x1: number;
  5855. /** Defines the y component of the start tangent in the bezier curve */
  5856. y1: number;
  5857. /** Defines the x component of the end tangent in the bezier curve */
  5858. x2: number;
  5859. /** Defines the y component of the end tangent in the bezier curve */
  5860. y2: number;
  5861. /**
  5862. * Instantiates a bezier function
  5863. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5864. * @param x1 Defines the x component of the start tangent in the bezier curve
  5865. * @param y1 Defines the y component of the start tangent in the bezier curve
  5866. * @param x2 Defines the x component of the end tangent in the bezier curve
  5867. * @param y2 Defines the y component of the end tangent in the bezier curve
  5868. */
  5869. constructor(
  5870. /** Defines the x component of the start tangent in the bezier curve */
  5871. x1?: number,
  5872. /** Defines the y component of the start tangent in the bezier curve */
  5873. y1?: number,
  5874. /** Defines the x component of the end tangent in the bezier curve */
  5875. x2?: number,
  5876. /** Defines the y component of the end tangent in the bezier curve */
  5877. y2?: number);
  5878. /** @hidden */
  5879. easeInCore(gradient: number): number;
  5880. }
  5881. }
  5882. declare module BABYLON {
  5883. /**
  5884. * Class used to hold a RBG color
  5885. */
  5886. export class Color3 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5901. * @param r defines the red component (between 0 and 1, default is 0)
  5902. * @param g defines the green component (between 0 and 1, default is 0)
  5903. * @param b defines the blue component (between 0 and 1, default is 0)
  5904. */
  5905. constructor(
  5906. /**
  5907. * Defines the red component (between 0 and 1, default is 0)
  5908. */
  5909. r?: number,
  5910. /**
  5911. * Defines the green component (between 0 and 1, default is 0)
  5912. */
  5913. g?: number,
  5914. /**
  5915. * Defines the blue component (between 0 and 1, default is 0)
  5916. */
  5917. b?: number);
  5918. /**
  5919. * Creates a string with the Color3 current values
  5920. * @returns the string representation of the Color3 object
  5921. */
  5922. toString(): string;
  5923. /**
  5924. * Returns the string "Color3"
  5925. * @returns "Color3"
  5926. */
  5927. getClassName(): string;
  5928. /**
  5929. * Compute the Color3 hash code
  5930. * @returns an unique number that can be used to hash Color3 objects
  5931. */
  5932. getHashCode(): number;
  5933. /**
  5934. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5935. * @param array defines the array where to store the r,g,b components
  5936. * @param index defines an optional index in the target array to define where to start storing values
  5937. * @returns the current Color3 object
  5938. */
  5939. toArray(array: FloatArray, index?: number): Color3;
  5940. /**
  5941. * Update the current color with values stored in an array from the starting index of the given array
  5942. * @param array defines the source array
  5943. * @param offset defines an offset in the source array
  5944. * @returns the current Color3 object
  5945. */
  5946. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5947. /**
  5948. * Returns a new Color4 object from the current Color3 and the given alpha
  5949. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5950. * @returns a new Color4 object
  5951. */
  5952. toColor4(alpha?: number): Color4;
  5953. /**
  5954. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5955. * @returns the new array
  5956. */
  5957. asArray(): number[];
  5958. /**
  5959. * Returns the luminance value
  5960. * @returns a float value
  5961. */
  5962. toLuminance(): number;
  5963. /**
  5964. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5965. * @param otherColor defines the second operand
  5966. * @returns the new Color3 object
  5967. */
  5968. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5969. /**
  5970. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5971. * @param otherColor defines the second operand
  5972. * @param result defines the Color3 object where to store the result
  5973. * @returns the current Color3
  5974. */
  5975. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5976. /**
  5977. * Determines equality between Color3 objects
  5978. * @param otherColor defines the second operand
  5979. * @returns true if the rgb values are equal to the given ones
  5980. */
  5981. equals(otherColor: DeepImmutable<Color3>): boolean;
  5982. /**
  5983. * Determines equality between the current Color3 object and a set of r,b,g values
  5984. * @param r defines the red component to check
  5985. * @param g defines the green component to check
  5986. * @param b defines the blue component to check
  5987. * @returns true if the rgb values are equal to the given ones
  5988. */
  5989. equalsFloats(r: number, g: number, b: number): boolean;
  5990. /**
  5991. * Multiplies in place each rgb value by scale
  5992. * @param scale defines the scaling factor
  5993. * @returns the updated Color3
  5994. */
  5995. scale(scale: number): Color3;
  5996. /**
  5997. * Multiplies the rgb values by scale and stores the result into "result"
  5998. * @param scale defines the scaling factor
  5999. * @param result defines the Color3 object where to store the result
  6000. * @returns the unmodified current Color3
  6001. */
  6002. scaleToRef(scale: number, result: Color3): Color3;
  6003. /**
  6004. * Scale the current Color3 values by a factor and add the result to a given Color3
  6005. * @param scale defines the scale factor
  6006. * @param result defines color to store the result into
  6007. * @returns the unmodified current Color3
  6008. */
  6009. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6010. /**
  6011. * Clamps the rgb values by the min and max values and stores the result into "result"
  6012. * @param min defines minimum clamping value (default is 0)
  6013. * @param max defines maximum clamping value (default is 1)
  6014. * @param result defines color to store the result into
  6015. * @returns the original Color3
  6016. */
  6017. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6018. /**
  6019. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6020. * @param otherColor defines the second operand
  6021. * @returns the new Color3
  6022. */
  6023. add(otherColor: DeepImmutable<Color3>): Color3;
  6024. /**
  6025. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6026. * @param otherColor defines the second operand
  6027. * @param result defines Color3 object to store the result into
  6028. * @returns the unmodified current Color3
  6029. */
  6030. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6031. /**
  6032. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6033. * @param otherColor defines the second operand
  6034. * @returns the new Color3
  6035. */
  6036. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6037. /**
  6038. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6039. * @param otherColor defines the second operand
  6040. * @param result defines Color3 object to store the result into
  6041. * @returns the unmodified current Color3
  6042. */
  6043. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6044. /**
  6045. * Copy the current object
  6046. * @returns a new Color3 copied the current one
  6047. */
  6048. clone(): Color3;
  6049. /**
  6050. * Copies the rgb values from the source in the current Color3
  6051. * @param source defines the source Color3 object
  6052. * @returns the updated Color3 object
  6053. */
  6054. copyFrom(source: DeepImmutable<Color3>): Color3;
  6055. /**
  6056. * Updates the Color3 rgb values from the given floats
  6057. * @param r defines the red component to read from
  6058. * @param g defines the green component to read from
  6059. * @param b defines the blue component to read from
  6060. * @returns the current Color3 object
  6061. */
  6062. copyFromFloats(r: number, g: number, b: number): Color3;
  6063. /**
  6064. * Updates the Color3 rgb values from the given floats
  6065. * @param r defines the red component to read from
  6066. * @param g defines the green component to read from
  6067. * @param b defines the blue component to read from
  6068. * @returns the current Color3 object
  6069. */
  6070. set(r: number, g: number, b: number): Color3;
  6071. /**
  6072. * Compute the Color3 hexadecimal code as a string
  6073. * @returns a string containing the hexadecimal representation of the Color3 object
  6074. */
  6075. toHexString(): string;
  6076. /**
  6077. * Computes a new Color3 converted from the current one to linear space
  6078. * @returns a new Color3 object
  6079. */
  6080. toLinearSpace(): Color3;
  6081. /**
  6082. * Converts current color in rgb space to HSV values
  6083. * @returns a new color3 representing the HSV values
  6084. */
  6085. toHSV(): Color3;
  6086. /**
  6087. * Converts current color in rgb space to HSV values
  6088. * @param result defines the Color3 where to store the HSV values
  6089. */
  6090. toHSVToRef(result: Color3): void;
  6091. /**
  6092. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6093. * @param convertedColor defines the Color3 object where to store the linear space version
  6094. * @returns the unmodified Color3
  6095. */
  6096. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6097. /**
  6098. * Computes a new Color3 converted from the current one to gamma space
  6099. * @returns a new Color3 object
  6100. */
  6101. toGammaSpace(): Color3;
  6102. /**
  6103. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6104. * @param convertedColor defines the Color3 object where to store the gamma space version
  6105. * @returns the unmodified Color3
  6106. */
  6107. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6108. private static _BlackReadOnly;
  6109. /**
  6110. * Convert Hue, saturation and value to a Color3 (RGB)
  6111. * @param hue defines the hue
  6112. * @param saturation defines the saturation
  6113. * @param value defines the value
  6114. * @param result defines the Color3 where to store the RGB values
  6115. */
  6116. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6117. /**
  6118. * Creates a new Color3 from the string containing valid hexadecimal values
  6119. * @param hex defines a string containing valid hexadecimal values
  6120. * @returns a new Color3 object
  6121. */
  6122. static FromHexString(hex: string): Color3;
  6123. /**
  6124. * Creates a new Color3 from the starting index of the given array
  6125. * @param array defines the source array
  6126. * @param offset defines an offset in the source array
  6127. * @returns a new Color3 object
  6128. */
  6129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6130. /**
  6131. * Creates a new Color3 from the starting index element of the given array
  6132. * @param array defines the source array to read from
  6133. * @param offset defines the offset in the source array
  6134. * @param result defines the target Color3 object
  6135. */
  6136. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6137. /**
  6138. * Creates a new Color3 from integer values (< 256)
  6139. * @param r defines the red component to read from (value between 0 and 255)
  6140. * @param g defines the green component to read from (value between 0 and 255)
  6141. * @param b defines the blue component to read from (value between 0 and 255)
  6142. * @returns a new Color3 object
  6143. */
  6144. static FromInts(r: number, g: number, b: number): Color3;
  6145. /**
  6146. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6147. * @param start defines the start Color3 value
  6148. * @param end defines the end Color3 value
  6149. * @param amount defines the gradient value between start and end
  6150. * @returns a new Color3 object
  6151. */
  6152. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6153. /**
  6154. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6155. * @param left defines the start value
  6156. * @param right defines the end value
  6157. * @param amount defines the gradient factor
  6158. * @param result defines the Color3 object where to store the result
  6159. */
  6160. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6161. /**
  6162. * Returns a Color3 value containing a red color
  6163. * @returns a new Color3 object
  6164. */
  6165. static Red(): Color3;
  6166. /**
  6167. * Returns a Color3 value containing a green color
  6168. * @returns a new Color3 object
  6169. */
  6170. static Green(): Color3;
  6171. /**
  6172. * Returns a Color3 value containing a blue color
  6173. * @returns a new Color3 object
  6174. */
  6175. static Blue(): Color3;
  6176. /**
  6177. * Returns a Color3 value containing a black color
  6178. * @returns a new Color3 object
  6179. */
  6180. static Black(): Color3;
  6181. /**
  6182. * Gets a Color3 value containing a black color that must not be updated
  6183. */
  6184. static get BlackReadOnly(): DeepImmutable<Color3>;
  6185. /**
  6186. * Returns a Color3 value containing a white color
  6187. * @returns a new Color3 object
  6188. */
  6189. static White(): Color3;
  6190. /**
  6191. * Returns a Color3 value containing a purple color
  6192. * @returns a new Color3 object
  6193. */
  6194. static Purple(): Color3;
  6195. /**
  6196. * Returns a Color3 value containing a magenta color
  6197. * @returns a new Color3 object
  6198. */
  6199. static Magenta(): Color3;
  6200. /**
  6201. * Returns a Color3 value containing a yellow color
  6202. * @returns a new Color3 object
  6203. */
  6204. static Yellow(): Color3;
  6205. /**
  6206. * Returns a Color3 value containing a gray color
  6207. * @returns a new Color3 object
  6208. */
  6209. static Gray(): Color3;
  6210. /**
  6211. * Returns a Color3 value containing a teal color
  6212. * @returns a new Color3 object
  6213. */
  6214. static Teal(): Color3;
  6215. /**
  6216. * Returns a Color3 value containing a random color
  6217. * @returns a new Color3 object
  6218. */
  6219. static Random(): Color3;
  6220. }
  6221. /**
  6222. * Class used to hold a RBGA color
  6223. */
  6224. export class Color4 {
  6225. /**
  6226. * Defines the red component (between 0 and 1, default is 0)
  6227. */
  6228. r: number;
  6229. /**
  6230. * Defines the green component (between 0 and 1, default is 0)
  6231. */
  6232. g: number;
  6233. /**
  6234. * Defines the blue component (between 0 and 1, default is 0)
  6235. */
  6236. b: number;
  6237. /**
  6238. * Defines the alpha component (between 0 and 1, default is 1)
  6239. */
  6240. a: number;
  6241. /**
  6242. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6243. * @param r defines the red component (between 0 and 1, default is 0)
  6244. * @param g defines the green component (between 0 and 1, default is 0)
  6245. * @param b defines the blue component (between 0 and 1, default is 0)
  6246. * @param a defines the alpha component (between 0 and 1, default is 1)
  6247. */
  6248. constructor(
  6249. /**
  6250. * Defines the red component (between 0 and 1, default is 0)
  6251. */
  6252. r?: number,
  6253. /**
  6254. * Defines the green component (between 0 and 1, default is 0)
  6255. */
  6256. g?: number,
  6257. /**
  6258. * Defines the blue component (between 0 and 1, default is 0)
  6259. */
  6260. b?: number,
  6261. /**
  6262. * Defines the alpha component (between 0 and 1, default is 1)
  6263. */
  6264. a?: number);
  6265. /**
  6266. * Adds in place the given Color4 values to the current Color4 object
  6267. * @param right defines the second operand
  6268. * @returns the current updated Color4 object
  6269. */
  6270. addInPlace(right: DeepImmutable<Color4>): Color4;
  6271. /**
  6272. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6273. * @returns the new array
  6274. */
  6275. asArray(): number[];
  6276. /**
  6277. * Stores from the starting index in the given array the Color4 successive values
  6278. * @param array defines the array where to store the r,g,b components
  6279. * @param index defines an optional index in the target array to define where to start storing values
  6280. * @returns the current Color4 object
  6281. */
  6282. toArray(array: number[], index?: number): Color4;
  6283. /**
  6284. * Update the current color with values stored in an array from the starting index of the given array
  6285. * @param array defines the source array
  6286. * @param offset defines an offset in the source array
  6287. * @returns the current Color4 object
  6288. */
  6289. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6290. /**
  6291. * Determines equality between Color4 objects
  6292. * @param otherColor defines the second operand
  6293. * @returns true if the rgba values are equal to the given ones
  6294. */
  6295. equals(otherColor: DeepImmutable<Color4>): boolean;
  6296. /**
  6297. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6298. * @param right defines the second operand
  6299. * @returns a new Color4 object
  6300. */
  6301. add(right: DeepImmutable<Color4>): Color4;
  6302. /**
  6303. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6304. * @param right defines the second operand
  6305. * @returns a new Color4 object
  6306. */
  6307. subtract(right: DeepImmutable<Color4>): Color4;
  6308. /**
  6309. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6310. * @param right defines the second operand
  6311. * @param result defines the Color4 object where to store the result
  6312. * @returns the current Color4 object
  6313. */
  6314. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6315. /**
  6316. * Creates a new Color4 with the current Color4 values multiplied by scale
  6317. * @param scale defines the scaling factor to apply
  6318. * @returns a new Color4 object
  6319. */
  6320. scale(scale: number): Color4;
  6321. /**
  6322. * Multiplies the current Color4 values by scale and stores the result in "result"
  6323. * @param scale defines the scaling factor to apply
  6324. * @param result defines the Color4 object where to store the result
  6325. * @returns the current unmodified Color4
  6326. */
  6327. scaleToRef(scale: number, result: Color4): Color4;
  6328. /**
  6329. * Scale the current Color4 values by a factor and add the result to a given Color4
  6330. * @param scale defines the scale factor
  6331. * @param result defines the Color4 object where to store the result
  6332. * @returns the unmodified current Color4
  6333. */
  6334. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6335. /**
  6336. * Clamps the rgb values by the min and max values and stores the result into "result"
  6337. * @param min defines minimum clamping value (default is 0)
  6338. * @param max defines maximum clamping value (default is 1)
  6339. * @param result defines color to store the result into.
  6340. * @returns the cuurent Color4
  6341. */
  6342. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6343. /**
  6344. * Multipy an Color4 value by another and return a new Color4 object
  6345. * @param color defines the Color4 value to multiply by
  6346. * @returns a new Color4 object
  6347. */
  6348. multiply(color: Color4): Color4;
  6349. /**
  6350. * Multipy a Color4 value by another and push the result in a reference value
  6351. * @param color defines the Color4 value to multiply by
  6352. * @param result defines the Color4 to fill the result in
  6353. * @returns the result Color4
  6354. */
  6355. multiplyToRef(color: Color4, result: Color4): Color4;
  6356. /**
  6357. * Creates a string with the Color4 current values
  6358. * @returns the string representation of the Color4 object
  6359. */
  6360. toString(): string;
  6361. /**
  6362. * Returns the string "Color4"
  6363. * @returns "Color4"
  6364. */
  6365. getClassName(): string;
  6366. /**
  6367. * Compute the Color4 hash code
  6368. * @returns an unique number that can be used to hash Color4 objects
  6369. */
  6370. getHashCode(): number;
  6371. /**
  6372. * Creates a new Color4 copied from the current one
  6373. * @returns a new Color4 object
  6374. */
  6375. clone(): Color4;
  6376. /**
  6377. * Copies the given Color4 values into the current one
  6378. * @param source defines the source Color4 object
  6379. * @returns the current updated Color4 object
  6380. */
  6381. copyFrom(source: Color4): Color4;
  6382. /**
  6383. * Copies the given float values into the current one
  6384. * @param r defines the red component to read from
  6385. * @param g defines the green component to read from
  6386. * @param b defines the blue component to read from
  6387. * @param a defines the alpha component to read from
  6388. * @returns the current updated Color4 object
  6389. */
  6390. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6391. /**
  6392. * Copies the given float values into the current one
  6393. * @param r defines the red component to read from
  6394. * @param g defines the green component to read from
  6395. * @param b defines the blue component to read from
  6396. * @param a defines the alpha component to read from
  6397. * @returns the current updated Color4 object
  6398. */
  6399. set(r: number, g: number, b: number, a: number): Color4;
  6400. /**
  6401. * Compute the Color4 hexadecimal code as a string
  6402. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6403. * @returns a string containing the hexadecimal representation of the Color4 object
  6404. */
  6405. toHexString(returnAsColor3?: boolean): string;
  6406. /**
  6407. * Computes a new Color4 converted from the current one to linear space
  6408. * @returns a new Color4 object
  6409. */
  6410. toLinearSpace(): Color4;
  6411. /**
  6412. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6413. * @param convertedColor defines the Color4 object where to store the linear space version
  6414. * @returns the unmodified Color4
  6415. */
  6416. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6417. /**
  6418. * Computes a new Color4 converted from the current one to gamma space
  6419. * @returns a new Color4 object
  6420. */
  6421. toGammaSpace(): Color4;
  6422. /**
  6423. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6424. * @param convertedColor defines the Color4 object where to store the gamma space version
  6425. * @returns the unmodified Color4
  6426. */
  6427. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6428. /**
  6429. * Creates a new Color4 from the string containing valid hexadecimal values
  6430. * @param hex defines a string containing valid hexadecimal values
  6431. * @returns a new Color4 object
  6432. */
  6433. static FromHexString(hex: string): Color4;
  6434. /**
  6435. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6436. * @param left defines the start value
  6437. * @param right defines the end value
  6438. * @param amount defines the gradient factor
  6439. * @returns a new Color4 object
  6440. */
  6441. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6442. /**
  6443. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6444. * @param left defines the start value
  6445. * @param right defines the end value
  6446. * @param amount defines the gradient factor
  6447. * @param result defines the Color4 object where to store data
  6448. */
  6449. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6450. /**
  6451. * Creates a new Color4 from a Color3 and an alpha value
  6452. * @param color3 defines the source Color3 to read from
  6453. * @param alpha defines the alpha component (1.0 by default)
  6454. * @returns a new Color4 object
  6455. */
  6456. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6457. /**
  6458. * Creates a new Color4 from the starting index element of the given array
  6459. * @param array defines the source array to read from
  6460. * @param offset defines the offset in the source array
  6461. * @returns a new Color4 object
  6462. */
  6463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6464. /**
  6465. * Creates a new Color4 from the starting index element of the given array
  6466. * @param array defines the source array to read from
  6467. * @param offset defines the offset in the source array
  6468. * @param result defines the target Color4 object
  6469. */
  6470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6471. /**
  6472. * Creates a new Color3 from integer values (< 256)
  6473. * @param r defines the red component to read from (value between 0 and 255)
  6474. * @param g defines the green component to read from (value between 0 and 255)
  6475. * @param b defines the blue component to read from (value between 0 and 255)
  6476. * @param a defines the alpha component to read from (value between 0 and 255)
  6477. * @returns a new Color3 object
  6478. */
  6479. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6480. /**
  6481. * Check the content of a given array and convert it to an array containing RGBA data
  6482. * If the original array was already containing count * 4 values then it is returned directly
  6483. * @param colors defines the array to check
  6484. * @param count defines the number of RGBA data to expect
  6485. * @returns an array containing count * 4 values (RGBA)
  6486. */
  6487. static CheckColors4(colors: number[], count: number): number[];
  6488. }
  6489. /**
  6490. * @hidden
  6491. */
  6492. export class TmpColors {
  6493. static Color3: Color3[];
  6494. static Color4: Color4[];
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Defines an interface which represents an animation key frame
  6500. */
  6501. export interface IAnimationKey {
  6502. /**
  6503. * Frame of the key frame
  6504. */
  6505. frame: number;
  6506. /**
  6507. * Value at the specifies key frame
  6508. */
  6509. value: any;
  6510. /**
  6511. * The input tangent for the cubic hermite spline
  6512. */
  6513. inTangent?: any;
  6514. /**
  6515. * The output tangent for the cubic hermite spline
  6516. */
  6517. outTangent?: any;
  6518. /**
  6519. * The animation interpolation type
  6520. */
  6521. interpolation?: AnimationKeyInterpolation;
  6522. }
  6523. /**
  6524. * Enum for the animation key frame interpolation type
  6525. */
  6526. export enum AnimationKeyInterpolation {
  6527. /**
  6528. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6529. */
  6530. STEP = 1
  6531. }
  6532. }
  6533. declare module BABYLON {
  6534. /**
  6535. * Represents the range of an animation
  6536. */
  6537. export class AnimationRange {
  6538. /**The name of the animation range**/
  6539. name: string;
  6540. /**The starting frame of the animation */
  6541. from: number;
  6542. /**The ending frame of the animation*/
  6543. to: number;
  6544. /**
  6545. * Initializes the range of an animation
  6546. * @param name The name of the animation range
  6547. * @param from The starting frame of the animation
  6548. * @param to The ending frame of the animation
  6549. */
  6550. constructor(
  6551. /**The name of the animation range**/
  6552. name: string,
  6553. /**The starting frame of the animation */
  6554. from: number,
  6555. /**The ending frame of the animation*/
  6556. to: number);
  6557. /**
  6558. * Makes a copy of the animation range
  6559. * @returns A copy of the animation range
  6560. */
  6561. clone(): AnimationRange;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. /**
  6566. * Composed of a frame, and an action function
  6567. */
  6568. export class AnimationEvent {
  6569. /** The frame for which the event is triggered **/
  6570. frame: number;
  6571. /** The event to perform when triggered **/
  6572. action: (currentFrame: number) => void;
  6573. /** Specifies if the event should be triggered only once**/
  6574. onlyOnce?: boolean | undefined;
  6575. /**
  6576. * Specifies if the animation event is done
  6577. */
  6578. isDone: boolean;
  6579. /**
  6580. * Initializes the animation event
  6581. * @param frame The frame for which the event is triggered
  6582. * @param action The event to perform when triggered
  6583. * @param onlyOnce Specifies if the event should be triggered only once
  6584. */
  6585. constructor(
  6586. /** The frame for which the event is triggered **/
  6587. frame: number,
  6588. /** The event to perform when triggered **/
  6589. action: (currentFrame: number) => void,
  6590. /** Specifies if the event should be triggered only once**/
  6591. onlyOnce?: boolean | undefined);
  6592. /** @hidden */
  6593. _clone(): AnimationEvent;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * Interface used to define a behavior
  6599. */
  6600. export interface Behavior<T> {
  6601. /** gets or sets behavior's name */
  6602. name: string;
  6603. /**
  6604. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6605. */
  6606. init(): void;
  6607. /**
  6608. * Called when the behavior is attached to a target
  6609. * @param target defines the target where the behavior is attached to
  6610. */
  6611. attach(target: T): void;
  6612. /**
  6613. * Called when the behavior is detached from its target
  6614. */
  6615. detach(): void;
  6616. }
  6617. /**
  6618. * Interface implemented by classes supporting behaviors
  6619. */
  6620. export interface IBehaviorAware<T> {
  6621. /**
  6622. * Attach a behavior
  6623. * @param behavior defines the behavior to attach
  6624. * @returns the current host
  6625. */
  6626. addBehavior(behavior: Behavior<T>): T;
  6627. /**
  6628. * Remove a behavior from the current object
  6629. * @param behavior defines the behavior to detach
  6630. * @returns the current host
  6631. */
  6632. removeBehavior(behavior: Behavior<T>): T;
  6633. /**
  6634. * Gets a behavior using its name to search
  6635. * @param name defines the name to search
  6636. * @returns the behavior or null if not found
  6637. */
  6638. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Class used to store data that will be store in GPU memory
  6644. */
  6645. export class Buffer {
  6646. private _engine;
  6647. private _buffer;
  6648. /** @hidden */
  6649. _data: Nullable<DataArray>;
  6650. private _updatable;
  6651. private _instanced;
  6652. private _divisor;
  6653. private _isAlreadyOwned;
  6654. /**
  6655. * Gets the byte stride.
  6656. */
  6657. readonly byteStride: number;
  6658. /**
  6659. * Constructor
  6660. * @param engine the engine
  6661. * @param data the data to use for this buffer
  6662. * @param updatable whether the data is updatable
  6663. * @param stride the stride (optional)
  6664. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6665. * @param instanced whether the buffer is instanced (optional)
  6666. * @param useBytes set to true if the stride in in bytes (optional)
  6667. * @param divisor sets an optional divisor for instances (1 by default)
  6668. */
  6669. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6670. /**
  6671. * Create a new VertexBuffer based on the current buffer
  6672. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6673. * @param offset defines offset in the buffer (0 by default)
  6674. * @param size defines the size in floats of attributes (position is 3 for instance)
  6675. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6676. * @param instanced defines if the vertex buffer contains indexed data
  6677. * @param useBytes defines if the offset and stride are in bytes *
  6678. * @param divisor sets an optional divisor for instances (1 by default)
  6679. * @returns the new vertex buffer
  6680. */
  6681. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6682. /**
  6683. * Gets a boolean indicating if the Buffer is updatable?
  6684. * @returns true if the buffer is updatable
  6685. */
  6686. isUpdatable(): boolean;
  6687. /**
  6688. * Gets current buffer's data
  6689. * @returns a DataArray or null
  6690. */
  6691. getData(): Nullable<DataArray>;
  6692. /**
  6693. * Gets underlying native buffer
  6694. * @returns underlying native buffer
  6695. */
  6696. getBuffer(): Nullable<DataBuffer>;
  6697. /**
  6698. * Gets the stride in float32 units (i.e. byte stride / 4).
  6699. * May not be an integer if the byte stride is not divisible by 4.
  6700. * @returns the stride in float32 units
  6701. * @deprecated Please use byteStride instead.
  6702. */
  6703. getStrideSize(): number;
  6704. /**
  6705. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6706. * @param data defines the data to store
  6707. */
  6708. create(data?: Nullable<DataArray>): void;
  6709. /** @hidden */
  6710. _rebuild(): void;
  6711. /**
  6712. * Update current buffer data
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates the data directly.
  6718. * @param data the new data
  6719. * @param offset the new offset
  6720. * @param vertexCount the vertex count (optional)
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6724. /** @hidden */
  6725. _increaseReferences(): void;
  6726. /**
  6727. * Release all resources
  6728. */
  6729. dispose(): void;
  6730. }
  6731. /**
  6732. * Specialized buffer used to store vertex data
  6733. */
  6734. export class VertexBuffer {
  6735. /** @hidden */
  6736. _buffer: Buffer;
  6737. private _kind;
  6738. private _size;
  6739. private _ownsBuffer;
  6740. private _instanced;
  6741. private _instanceDivisor;
  6742. /**
  6743. * The byte type.
  6744. */
  6745. static readonly BYTE: number;
  6746. /**
  6747. * The unsigned byte type.
  6748. */
  6749. static readonly UNSIGNED_BYTE: number;
  6750. /**
  6751. * The short type.
  6752. */
  6753. static readonly SHORT: number;
  6754. /**
  6755. * The unsigned short type.
  6756. */
  6757. static readonly UNSIGNED_SHORT: number;
  6758. /**
  6759. * The integer type.
  6760. */
  6761. static readonly INT: number;
  6762. /**
  6763. * The unsigned integer type.
  6764. */
  6765. static readonly UNSIGNED_INT: number;
  6766. /**
  6767. * The float type.
  6768. */
  6769. static readonly FLOAT: number;
  6770. /**
  6771. * Gets or sets the instance divisor when in instanced mode
  6772. */
  6773. get instanceDivisor(): number;
  6774. set instanceDivisor(value: number);
  6775. /**
  6776. * Gets the byte stride.
  6777. */
  6778. readonly byteStride: number;
  6779. /**
  6780. * Gets the byte offset.
  6781. */
  6782. readonly byteOffset: number;
  6783. /**
  6784. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6785. */
  6786. readonly normalized: boolean;
  6787. /**
  6788. * Gets the data type of each component in the array.
  6789. */
  6790. readonly type: number;
  6791. /**
  6792. * Constructor
  6793. * @param engine the engine
  6794. * @param data the data to use for this vertex buffer
  6795. * @param kind the vertex buffer kind
  6796. * @param updatable whether the data is updatable
  6797. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6798. * @param stride the stride (optional)
  6799. * @param instanced whether the buffer is instanced (optional)
  6800. * @param offset the offset of the data (optional)
  6801. * @param size the number of components (optional)
  6802. * @param type the type of the component (optional)
  6803. * @param normalized whether the data contains normalized data (optional)
  6804. * @param useBytes set to true if stride and offset are in bytes (optional)
  6805. * @param divisor defines the instance divisor to use (1 by default)
  6806. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6807. */
  6808. 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, takeBufferOwnership?: boolean);
  6809. /** @hidden */
  6810. _rebuild(): void;
  6811. /**
  6812. * Returns the kind of the VertexBuffer (string)
  6813. * @returns a string
  6814. */
  6815. getKind(): string;
  6816. /**
  6817. * Gets a boolean indicating if the VertexBuffer is updatable?
  6818. * @returns true if the buffer is updatable
  6819. */
  6820. isUpdatable(): boolean;
  6821. /**
  6822. * Gets current buffer's data
  6823. * @returns a DataArray or null
  6824. */
  6825. getData(): Nullable<DataArray>;
  6826. /**
  6827. * Gets underlying native buffer
  6828. * @returns underlying native buffer
  6829. */
  6830. getBuffer(): Nullable<DataBuffer>;
  6831. /**
  6832. * Gets the stride in float32 units (i.e. byte stride / 4).
  6833. * May not be an integer if the byte stride is not divisible by 4.
  6834. * @returns the stride in float32 units
  6835. * @deprecated Please use byteStride instead.
  6836. */
  6837. getStrideSize(): number;
  6838. /**
  6839. * Returns the offset as a multiple of the type byte length.
  6840. * @returns the offset in bytes
  6841. * @deprecated Please use byteOffset instead.
  6842. */
  6843. getOffset(): number;
  6844. /**
  6845. * Returns the number of components per vertex attribute (integer)
  6846. * @returns the size in float
  6847. */
  6848. getSize(): number;
  6849. /**
  6850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6851. * @returns true if this buffer is instanced
  6852. */
  6853. getIsInstanced(): boolean;
  6854. /**
  6855. * Returns the instancing divisor, zero for non-instanced (integer).
  6856. * @returns a number
  6857. */
  6858. getInstanceDivisor(): number;
  6859. /**
  6860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6861. * @param data defines the data to store
  6862. */
  6863. create(data?: DataArray): void;
  6864. /**
  6865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6866. * This function will create a new buffer if the current one is not updatable
  6867. * @param data defines the data to store
  6868. */
  6869. update(data: DataArray): void;
  6870. /**
  6871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6872. * Returns the directly updated WebGLBuffer.
  6873. * @param data the new data
  6874. * @param offset the new offset
  6875. * @param useBytes set to true if the offset is in bytes
  6876. */
  6877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6878. /**
  6879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6880. */
  6881. dispose(): void;
  6882. /**
  6883. * Enumerates each value of this vertex buffer as numbers.
  6884. * @param count the number of values to enumerate
  6885. * @param callback the callback function called for each value
  6886. */
  6887. forEach(count: number, callback: (value: number, index: number) => void): void;
  6888. /**
  6889. * Positions
  6890. */
  6891. static readonly PositionKind: string;
  6892. /**
  6893. * Normals
  6894. */
  6895. static readonly NormalKind: string;
  6896. /**
  6897. * Tangents
  6898. */
  6899. static readonly TangentKind: string;
  6900. /**
  6901. * Texture coordinates
  6902. */
  6903. static readonly UVKind: string;
  6904. /**
  6905. * Texture coordinates 2
  6906. */
  6907. static readonly UV2Kind: string;
  6908. /**
  6909. * Texture coordinates 3
  6910. */
  6911. static readonly UV3Kind: string;
  6912. /**
  6913. * Texture coordinates 4
  6914. */
  6915. static readonly UV4Kind: string;
  6916. /**
  6917. * Texture coordinates 5
  6918. */
  6919. static readonly UV5Kind: string;
  6920. /**
  6921. * Texture coordinates 6
  6922. */
  6923. static readonly UV6Kind: string;
  6924. /**
  6925. * Colors
  6926. */
  6927. static readonly ColorKind: string;
  6928. /**
  6929. * Matrix indices (for bones)
  6930. */
  6931. static readonly MatricesIndicesKind: string;
  6932. /**
  6933. * Matrix weights (for bones)
  6934. */
  6935. static readonly MatricesWeightsKind: string;
  6936. /**
  6937. * Additional matrix indices (for bones)
  6938. */
  6939. static readonly MatricesIndicesExtraKind: string;
  6940. /**
  6941. * Additional matrix weights (for bones)
  6942. */
  6943. static readonly MatricesWeightsExtraKind: string;
  6944. /**
  6945. * Deduces the stride given a kind.
  6946. * @param kind The kind string to deduce
  6947. * @returns The deduced stride
  6948. */
  6949. static DeduceStride(kind: string): number;
  6950. /**
  6951. * Gets the byte length of the given type.
  6952. * @param type the type
  6953. * @returns the number of bytes
  6954. */
  6955. static GetTypeByteLength(type: number): number;
  6956. /**
  6957. * Enumerates each value of the given parameters as numbers.
  6958. * @param data the data to enumerate
  6959. * @param byteOffset the byte offset of the data
  6960. * @param byteStride the byte stride of the data
  6961. * @param componentCount the number of components per element
  6962. * @param componentType the type of the component
  6963. * @param count the number of values to enumerate
  6964. * @param normalized whether the data is normalized
  6965. * @param callback the callback function called for each value
  6966. */
  6967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6968. private static _GetFloatValue;
  6969. }
  6970. }
  6971. declare module BABYLON {
  6972. /**
  6973. * @hidden
  6974. */
  6975. export class IntersectionInfo {
  6976. bu: Nullable<number>;
  6977. bv: Nullable<number>;
  6978. distance: number;
  6979. faceId: number;
  6980. subMeshId: number;
  6981. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6982. }
  6983. }
  6984. declare module BABYLON {
  6985. /**
  6986. * Class used to store bounding sphere information
  6987. */
  6988. export class BoundingSphere {
  6989. /**
  6990. * Gets the center of the bounding sphere in local space
  6991. */
  6992. readonly center: Vector3;
  6993. /**
  6994. * Radius of the bounding sphere in local space
  6995. */
  6996. radius: number;
  6997. /**
  6998. * Gets the center of the bounding sphere in world space
  6999. */
  7000. readonly centerWorld: Vector3;
  7001. /**
  7002. * Radius of the bounding sphere in world space
  7003. */
  7004. radiusWorld: number;
  7005. /**
  7006. * Gets the minimum vector in local space
  7007. */
  7008. readonly minimum: Vector3;
  7009. /**
  7010. * Gets the maximum vector in local space
  7011. */
  7012. readonly maximum: Vector3;
  7013. private _worldMatrix;
  7014. private static readonly TmpVector3;
  7015. /**
  7016. * Creates a new bounding sphere
  7017. * @param min defines the minimum vector (in local space)
  7018. * @param max defines the maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7022. /**
  7023. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7024. * @param min defines the new minimum vector (in local space)
  7025. * @param max defines the new maximum vector (in local space)
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7029. /**
  7030. * Scale the current bounding sphere by applying a scale factor
  7031. * @param factor defines the scale factor to apply
  7032. * @returns the current bounding box
  7033. */
  7034. scale(factor: number): BoundingSphere;
  7035. /**
  7036. * Gets the world matrix of the bounding box
  7037. * @returns a matrix
  7038. */
  7039. getWorldMatrix(): DeepImmutable<Matrix>;
  7040. /** @hidden */
  7041. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Tests if the bounding sphere is intersecting the frustum planes
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if there is an intersection
  7046. */
  7047. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if the bounding sphere center is in between the frustum planes.
  7050. * Used for optimistic fast inclusion.
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if the sphere center is in between the frustum planes
  7053. */
  7054. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding sphere
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding sphere
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if two sphere intersct
  7063. * @param sphere0 sphere 0
  7064. * @param sphere1 sphere 1
  7065. * @returns true if the speres intersect
  7066. */
  7067. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7068. }
  7069. }
  7070. declare module BABYLON {
  7071. /**
  7072. * Class used to store bounding box information
  7073. */
  7074. export class BoundingBox implements ICullable {
  7075. /**
  7076. * Gets the 8 vectors representing the bounding box in local space
  7077. */
  7078. readonly vectors: Vector3[];
  7079. /**
  7080. * Gets the center of the bounding box in local space
  7081. */
  7082. readonly center: Vector3;
  7083. /**
  7084. * Gets the center of the bounding box in world space
  7085. */
  7086. readonly centerWorld: Vector3;
  7087. /**
  7088. * Gets the extend size in local space
  7089. */
  7090. readonly extendSize: Vector3;
  7091. /**
  7092. * Gets the extend size in world space
  7093. */
  7094. readonly extendSizeWorld: Vector3;
  7095. /**
  7096. * Gets the OBB (object bounding box) directions
  7097. */
  7098. readonly directions: Vector3[];
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in world space
  7101. */
  7102. readonly vectorsWorld: Vector3[];
  7103. /**
  7104. * Gets the minimum vector in world space
  7105. */
  7106. readonly minimumWorld: Vector3;
  7107. /**
  7108. * Gets the maximum vector in world space
  7109. */
  7110. readonly maximumWorld: Vector3;
  7111. /**
  7112. * Gets the minimum vector in local space
  7113. */
  7114. readonly minimum: Vector3;
  7115. /**
  7116. * Gets the maximum vector in local space
  7117. */
  7118. readonly maximum: Vector3;
  7119. private _worldMatrix;
  7120. private static readonly TmpVector3;
  7121. /**
  7122. * @hidden
  7123. */
  7124. _tag: number;
  7125. /**
  7126. * Creates a new bounding box
  7127. * @param min defines the minimum vector (in local space)
  7128. * @param max defines the maximum vector (in local space)
  7129. * @param worldMatrix defines the new world matrix
  7130. */
  7131. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7132. /**
  7133. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7134. * @param min defines the new minimum vector (in local space)
  7135. * @param max defines the new maximum vector (in local space)
  7136. * @param worldMatrix defines the new world matrix
  7137. */
  7138. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7139. /**
  7140. * Scale the current bounding box by applying a scale factor
  7141. * @param factor defines the scale factor to apply
  7142. * @returns the current bounding box
  7143. */
  7144. scale(factor: number): BoundingBox;
  7145. /**
  7146. * Gets the world matrix of the bounding box
  7147. * @returns a matrix
  7148. */
  7149. getWorldMatrix(): DeepImmutable<Matrix>;
  7150. /** @hidden */
  7151. _update(world: DeepImmutable<Matrix>): void;
  7152. /**
  7153. * Tests if the bounding box is intersecting the frustum planes
  7154. * @param frustumPlanes defines the frustum planes to test
  7155. * @returns true if there is an intersection
  7156. */
  7157. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7158. /**
  7159. * Tests if the bounding box is entirely inside the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an inclusion
  7162. */
  7163. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if a point is inside the bounding box
  7166. * @param point defines the point to test
  7167. * @returns true if the point is inside the bounding box
  7168. */
  7169. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7170. /**
  7171. * Tests if the bounding box intersects with a bounding sphere
  7172. * @param sphere defines the sphere to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7176. /**
  7177. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7178. * @param min defines the min vector to use
  7179. * @param max defines the max vector to use
  7180. * @returns true if there is an intersection
  7181. */
  7182. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7183. /**
  7184. * Tests if two bounding boxes are intersections
  7185. * @param box0 defines the first box to test
  7186. * @param box1 defines the second box to test
  7187. * @returns true if there is an intersection
  7188. */
  7189. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7190. /**
  7191. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7192. * @param minPoint defines the minimum vector of the bounding box
  7193. * @param maxPoint defines the maximum vector of the bounding box
  7194. * @param sphereCenter defines the sphere center
  7195. * @param sphereRadius defines the sphere radius
  7196. * @returns true if there is an intersection
  7197. */
  7198. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7199. /**
  7200. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @return true if there is an inclusion
  7204. */
  7205. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. /**
  7207. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7208. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7209. * @param frustumPlanes defines the frustum planes to test
  7210. * @return true if there is an intersection
  7211. */
  7212. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7213. }
  7214. }
  7215. declare module BABYLON {
  7216. /** @hidden */
  7217. export class Collider {
  7218. /** Define if a collision was found */
  7219. collisionFound: boolean;
  7220. /**
  7221. * Define last intersection point in local space
  7222. */
  7223. intersectionPoint: Vector3;
  7224. /**
  7225. * Define last collided mesh
  7226. */
  7227. collidedMesh: Nullable<AbstractMesh>;
  7228. private _collisionPoint;
  7229. private _planeIntersectionPoint;
  7230. private _tempVector;
  7231. private _tempVector2;
  7232. private _tempVector3;
  7233. private _tempVector4;
  7234. private _edge;
  7235. private _baseToVertex;
  7236. private _destinationPoint;
  7237. private _slidePlaneNormal;
  7238. private _displacementVector;
  7239. /** @hidden */
  7240. _radius: Vector3;
  7241. /** @hidden */
  7242. _retry: number;
  7243. private _velocity;
  7244. private _basePoint;
  7245. private _epsilon;
  7246. /** @hidden */
  7247. _velocityWorldLength: number;
  7248. /** @hidden */
  7249. _basePointWorld: Vector3;
  7250. private _velocityWorld;
  7251. private _normalizedVelocity;
  7252. /** @hidden */
  7253. _initialVelocity: Vector3;
  7254. /** @hidden */
  7255. _initialPosition: Vector3;
  7256. private _nearestDistance;
  7257. private _collisionMask;
  7258. get collisionMask(): number;
  7259. set collisionMask(mask: number);
  7260. /**
  7261. * Gets the plane normal used to compute the sliding response (in local space)
  7262. */
  7263. get slidePlaneNormal(): Vector3;
  7264. /** @hidden */
  7265. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7266. /** @hidden */
  7267. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7268. /** @hidden */
  7269. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7270. /** @hidden */
  7271. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7272. /** @hidden */
  7273. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7274. /** @hidden */
  7275. _getResponse(pos: Vector3, vel: Vector3): void;
  7276. }
  7277. }
  7278. declare module BABYLON {
  7279. /**
  7280. * Interface for cullable objects
  7281. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7282. */
  7283. export interface ICullable {
  7284. /**
  7285. * Checks if the object or part of the object is in the frustum
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isInFrustum(frustumPlanes: Plane[]): boolean;
  7290. /**
  7291. * Checks if a cullable object (mesh...) is in the camera frustum
  7292. * Unlike isInFrustum this cheks the full bounding box
  7293. * @param frustumPlanes Camera near/planes
  7294. * @returns true if the object is in frustum otherwise false
  7295. */
  7296. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7297. }
  7298. /**
  7299. * Info for a bounding data of a mesh
  7300. */
  7301. export class BoundingInfo implements ICullable {
  7302. /**
  7303. * Bounding box for the mesh
  7304. */
  7305. readonly boundingBox: BoundingBox;
  7306. /**
  7307. * Bounding sphere for the mesh
  7308. */
  7309. readonly boundingSphere: BoundingSphere;
  7310. private _isLocked;
  7311. private static readonly TmpVector3;
  7312. /**
  7313. * Constructs bounding info
  7314. * @param minimum min vector of the bounding box/sphere
  7315. * @param maximum max vector of the bounding box/sphere
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7319. /**
  7320. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7321. * @param min defines the new minimum vector (in local space)
  7322. * @param max defines the new maximum vector (in local space)
  7323. * @param worldMatrix defines the new world matrix
  7324. */
  7325. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7326. /**
  7327. * min vector of the bounding box/sphere
  7328. */
  7329. get minimum(): Vector3;
  7330. /**
  7331. * max vector of the bounding box/sphere
  7332. */
  7333. get maximum(): Vector3;
  7334. /**
  7335. * If the info is locked and won't be updated to avoid perf overhead
  7336. */
  7337. get isLocked(): boolean;
  7338. set isLocked(value: boolean);
  7339. /**
  7340. * Updates the bounding sphere and box
  7341. * @param world world matrix to be used to update
  7342. */
  7343. update(world: DeepImmutable<Matrix>): void;
  7344. /**
  7345. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7346. * @param center New center of the bounding info
  7347. * @param extend New extend of the bounding info
  7348. * @returns the current bounding info
  7349. */
  7350. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7351. /**
  7352. * Scale the current bounding info by applying a scale factor
  7353. * @param factor defines the scale factor to apply
  7354. * @returns the current bounding info
  7355. */
  7356. scale(factor: number): BoundingInfo;
  7357. /**
  7358. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7359. * @param frustumPlanes defines the frustum to test
  7360. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7361. * @returns true if the bounding info is in the frustum planes
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7364. /**
  7365. * Gets the world distance between the min and max points of the bounding box
  7366. */
  7367. get diagonalLength(): number;
  7368. /**
  7369. * Checks if a cullable object (mesh...) is in the camera frustum
  7370. * Unlike isInFrustum this cheks the full bounding box
  7371. * @param frustumPlanes Camera near/planes
  7372. * @returns true if the object is in frustum otherwise false
  7373. */
  7374. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7375. /** @hidden */
  7376. _checkCollision(collider: Collider): boolean;
  7377. /**
  7378. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param point the point to check intersection with
  7381. * @returns if the point intersects
  7382. */
  7383. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7384. /**
  7385. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7387. * @param boundingInfo the bounding info to check intersection with
  7388. * @param precise if the intersection should be done using OBB
  7389. * @returns if the bounding info intersects
  7390. */
  7391. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7392. }
  7393. }
  7394. declare module BABYLON {
  7395. /**
  7396. * Extracts minimum and maximum values from a list of indexed positions
  7397. * @param positions defines the positions to use
  7398. * @param indices defines the indices to the positions
  7399. * @param indexStart defines the start index
  7400. * @param indexCount defines the end index
  7401. * @param bias defines bias value to add to the result
  7402. * @return minimum and maximum values
  7403. */
  7404. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7405. minimum: Vector3;
  7406. maximum: Vector3;
  7407. };
  7408. /**
  7409. * Extracts minimum and maximum values from a list of positions
  7410. * @param positions defines the positions to use
  7411. * @param start defines the start index in the positions array
  7412. * @param count defines the number of positions to handle
  7413. * @param bias defines bias value to add to the result
  7414. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7415. * @return minimum and maximum values
  7416. */
  7417. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7418. minimum: Vector3;
  7419. maximum: Vector3;
  7420. };
  7421. }
  7422. declare module BABYLON {
  7423. /**
  7424. * Class used to manipulate GUIDs
  7425. */
  7426. export class GUID {
  7427. /**
  7428. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7429. * Be aware Math.random() could cause collisions, but:
  7430. * "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"
  7431. * @returns a pseudo random id
  7432. */
  7433. static RandomId(): string;
  7434. }
  7435. }
  7436. declare module BABYLON {
  7437. /**
  7438. * Base class of all the textures in babylon.
  7439. * It groups all the common properties the materials, post process, lights... might need
  7440. * in order to make a correct use of the texture.
  7441. */
  7442. export class BaseTexture extends ThinTexture implements IAnimatable {
  7443. /**
  7444. * Default anisotropic filtering level for the application.
  7445. * It is set to 4 as a good tradeoff between perf and quality.
  7446. */
  7447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7448. /**
  7449. * Gets or sets the unique id of the texture
  7450. */
  7451. uniqueId: number;
  7452. /**
  7453. * Define the name of the texture.
  7454. */
  7455. name: string;
  7456. /**
  7457. * Gets or sets an object used to store user defined information.
  7458. */
  7459. metadata: any;
  7460. /**
  7461. * For internal use only. Please do not use.
  7462. */
  7463. reservedDataStore: any;
  7464. private _hasAlpha;
  7465. /**
  7466. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7467. */
  7468. set hasAlpha(value: boolean);
  7469. get hasAlpha(): boolean;
  7470. /**
  7471. * Defines if the alpha value should be determined via the rgb values.
  7472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7473. */
  7474. getAlphaFromRGB: boolean;
  7475. /**
  7476. * Intensity or strength of the texture.
  7477. * It is commonly used by materials to fine tune the intensity of the texture
  7478. */
  7479. level: number;
  7480. /**
  7481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7482. * This is part of the texture as textures usually maps to one uv set.
  7483. */
  7484. coordinatesIndex: number;
  7485. protected _coordinatesMode: number;
  7486. /**
  7487. * How a texture is mapped.
  7488. *
  7489. * | Value | Type | Description |
  7490. * | ----- | ----------------------------------- | ----------- |
  7491. * | 0 | EXPLICIT_MODE | |
  7492. * | 1 | SPHERICAL_MODE | |
  7493. * | 2 | PLANAR_MODE | |
  7494. * | 3 | CUBIC_MODE | |
  7495. * | 4 | PROJECTION_MODE | |
  7496. * | 5 | SKYBOX_MODE | |
  7497. * | 6 | INVCUBIC_MODE | |
  7498. * | 7 | EQUIRECTANGULAR_MODE | |
  7499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7501. */
  7502. set coordinatesMode(value: number);
  7503. get coordinatesMode(): number;
  7504. /**
  7505. * | Value | Type | Description |
  7506. * | ----- | ------------------ | ----------- |
  7507. * | 0 | CLAMP_ADDRESSMODE | |
  7508. * | 1 | WRAP_ADDRESSMODE | |
  7509. * | 2 | MIRROR_ADDRESSMODE | |
  7510. */
  7511. get wrapU(): number;
  7512. set wrapU(value: number);
  7513. /**
  7514. * | Value | Type | Description |
  7515. * | ----- | ------------------ | ----------- |
  7516. * | 0 | CLAMP_ADDRESSMODE | |
  7517. * | 1 | WRAP_ADDRESSMODE | |
  7518. * | 2 | MIRROR_ADDRESSMODE | |
  7519. */
  7520. get wrapV(): number;
  7521. set wrapV(value: number);
  7522. /**
  7523. * | Value | Type | Description |
  7524. * | ----- | ------------------ | ----------- |
  7525. * | 0 | CLAMP_ADDRESSMODE | |
  7526. * | 1 | WRAP_ADDRESSMODE | |
  7527. * | 2 | MIRROR_ADDRESSMODE | |
  7528. */
  7529. wrapR: number;
  7530. /**
  7531. * With compliant hardware and browser (supporting anisotropic filtering)
  7532. * this defines the level of anisotropic filtering in the texture.
  7533. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7534. */
  7535. anisotropicFilteringLevel: number;
  7536. private _isCube;
  7537. /**
  7538. * Define if the texture is a cube texture or if false a 2d texture.
  7539. */
  7540. get isCube(): boolean;
  7541. set isCube(value: boolean);
  7542. /**
  7543. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7544. */
  7545. get is3D(): boolean;
  7546. set is3D(value: boolean);
  7547. /**
  7548. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7549. */
  7550. get is2DArray(): boolean;
  7551. set is2DArray(value: boolean);
  7552. private _gammaSpace;
  7553. /**
  7554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7555. * HDR texture are usually stored in linear space.
  7556. * This only impacts the PBR and Background materials
  7557. */
  7558. get gammaSpace(): boolean;
  7559. set gammaSpace(gamma: boolean);
  7560. /**
  7561. * Gets or sets whether or not the texture contains RGBD data.
  7562. */
  7563. get isRGBD(): boolean;
  7564. set isRGBD(value: boolean);
  7565. /**
  7566. * Is Z inverted in the texture (useful in a cube texture).
  7567. */
  7568. invertZ: boolean;
  7569. /**
  7570. * Are mip maps generated for this texture or not.
  7571. */
  7572. get noMipmap(): boolean;
  7573. /**
  7574. * @hidden
  7575. */
  7576. lodLevelInAlpha: boolean;
  7577. /**
  7578. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7579. */
  7580. get lodGenerationOffset(): number;
  7581. set lodGenerationOffset(value: number);
  7582. /**
  7583. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7584. */
  7585. get lodGenerationScale(): number;
  7586. set lodGenerationScale(value: number);
  7587. /**
  7588. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7589. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7590. * average roughness values.
  7591. */
  7592. get linearSpecularLOD(): boolean;
  7593. set linearSpecularLOD(value: boolean);
  7594. /**
  7595. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7596. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7597. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7598. */
  7599. get irradianceTexture(): Nullable<BaseTexture>;
  7600. set irradianceTexture(value: Nullable<BaseTexture>);
  7601. /**
  7602. * Define if the texture is a render target.
  7603. */
  7604. isRenderTarget: boolean;
  7605. /**
  7606. * Define the unique id of the texture in the scene.
  7607. */
  7608. get uid(): string;
  7609. /** @hidden */
  7610. _prefiltered: boolean;
  7611. /**
  7612. * Return a string representation of the texture.
  7613. * @returns the texture as a string
  7614. */
  7615. toString(): string;
  7616. /**
  7617. * Get the class name of the texture.
  7618. * @returns "BaseTexture"
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Define the list of animation attached to the texture.
  7623. */
  7624. animations: Animation[];
  7625. /**
  7626. * An event triggered when the texture is disposed.
  7627. */
  7628. onDisposeObservable: Observable<BaseTexture>;
  7629. private _onDisposeObserver;
  7630. /**
  7631. * Callback triggered when the texture has been disposed.
  7632. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7633. */
  7634. set onDispose(callback: () => void);
  7635. protected _scene: Nullable<Scene>;
  7636. /** @hidden */
  7637. _texture: Nullable<InternalTexture>;
  7638. private _uid;
  7639. /**
  7640. * Define if the texture is preventinga material to render or not.
  7641. * If not and the texture is not ready, the engine will use a default black texture instead.
  7642. */
  7643. get isBlocking(): boolean;
  7644. /**
  7645. * Instantiates a new BaseTexture.
  7646. * Base class of all the textures in babylon.
  7647. * It groups all the common properties the materials, post process, lights... might need
  7648. * in order to make a correct use of the texture.
  7649. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7650. */
  7651. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7652. /**
  7653. * Get the scene the texture belongs to.
  7654. * @returns the scene or null if undefined
  7655. */
  7656. getScene(): Nullable<Scene>;
  7657. /** @hidden */
  7658. protected _getEngine(): Nullable<ThinEngine>;
  7659. /**
  7660. * Checks if the texture has the same transform matrix than another texture
  7661. * @param texture texture to check against
  7662. * @returns true if the transforms are the same, else false
  7663. */
  7664. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7665. /**
  7666. * Get the texture transform matrix used to offset tile the texture for istance.
  7667. * @returns the transformation matrix
  7668. */
  7669. getTextureMatrix(): Matrix;
  7670. /**
  7671. * Get the texture reflection matrix used to rotate/transform the reflection.
  7672. * @returns the reflection matrix
  7673. */
  7674. getReflectionTextureMatrix(): Matrix;
  7675. /**
  7676. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7677. * @returns true if ready or not blocking
  7678. */
  7679. isReadyOrNotBlocking(): boolean;
  7680. /**
  7681. * Scales the texture if is `canRescale()`
  7682. * @param ratio the resize factor we want to use to rescale
  7683. */
  7684. scale(ratio: number): void;
  7685. /**
  7686. * Get if the texture can rescale.
  7687. */
  7688. get canRescale(): boolean;
  7689. /** @hidden */
  7690. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Clones the texture.
  7695. * @returns the cloned texture
  7696. */
  7697. clone(): Nullable<BaseTexture>;
  7698. /**
  7699. * Get the texture underlying type (INT, FLOAT...)
  7700. */
  7701. get textureType(): number;
  7702. /**
  7703. * Get the texture underlying format (RGB, RGBA...)
  7704. */
  7705. get textureFormat(): number;
  7706. /**
  7707. * Indicates that textures need to be re-calculated for all materials
  7708. */
  7709. protected _markAllSubMeshesAsTexturesDirty(): void;
  7710. /**
  7711. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7712. * This will returns an RGBA array buffer containing either in values (0-255) or
  7713. * float values (0-1) depending of the underlying buffer type.
  7714. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7715. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7716. * @param buffer defines a user defined buffer to fill with data (can be null)
  7717. * @returns The Array buffer containing the pixels data.
  7718. */
  7719. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7720. /** @hidden */
  7721. get _lodTextureHigh(): Nullable<BaseTexture>;
  7722. /** @hidden */
  7723. get _lodTextureMid(): Nullable<BaseTexture>;
  7724. /** @hidden */
  7725. get _lodTextureLow(): Nullable<BaseTexture>;
  7726. /**
  7727. * Dispose the texture and release its associated resources.
  7728. */
  7729. dispose(): void;
  7730. /**
  7731. * Serialize the texture into a JSON representation that can be parsed later on.
  7732. * @returns the JSON representation of the texture
  7733. */
  7734. serialize(): any;
  7735. /**
  7736. * Helper function to be called back once a list of texture contains only ready textures.
  7737. * @param textures Define the list of textures to wait for
  7738. * @param callback Define the callback triggered once the entire list will be ready
  7739. */
  7740. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7741. private static _isScene;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /** @hidden */
  7746. export class WebGLDataBuffer extends DataBuffer {
  7747. private _buffer;
  7748. constructor(resource: WebGLBuffer);
  7749. get underlyingResource(): any;
  7750. }
  7751. }
  7752. declare module BABYLON {
  7753. /** @hidden */
  7754. export class WebGLPipelineContext implements IPipelineContext {
  7755. engine: ThinEngine;
  7756. program: Nullable<WebGLProgram>;
  7757. context?: WebGLRenderingContext;
  7758. vertexShader?: WebGLShader;
  7759. fragmentShader?: WebGLShader;
  7760. isParallelCompiled: boolean;
  7761. onCompiled?: () => void;
  7762. transformFeedback?: WebGLTransformFeedback | null;
  7763. vertexCompilationError: Nullable<string>;
  7764. fragmentCompilationError: Nullable<string>;
  7765. programLinkError: Nullable<string>;
  7766. programValidationError: Nullable<string>;
  7767. get isAsync(): boolean;
  7768. get isReady(): boolean;
  7769. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7770. _getVertexShaderCode(): string | null;
  7771. _getFragmentShaderCode(): string | null;
  7772. }
  7773. }
  7774. declare module BABYLON {
  7775. interface ThinEngine {
  7776. /**
  7777. * Create an uniform buffer
  7778. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7779. * @param elements defines the content of the uniform buffer
  7780. * @returns the webGL uniform buffer
  7781. */
  7782. createUniformBuffer(elements: FloatArray): DataBuffer;
  7783. /**
  7784. * Create a dynamic uniform buffer
  7785. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7786. * @param elements defines the content of the uniform buffer
  7787. * @returns the webGL uniform buffer
  7788. */
  7789. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7790. /**
  7791. * Update an existing uniform buffer
  7792. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7793. * @param uniformBuffer defines the target uniform buffer
  7794. * @param elements defines the content to update
  7795. * @param offset defines the offset in the uniform buffer where update should start
  7796. * @param count defines the size of the data to update
  7797. */
  7798. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7799. /**
  7800. * Bind an uniform buffer to the current webGL context
  7801. * @param buffer defines the buffer to bind
  7802. */
  7803. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7804. /**
  7805. * Bind a buffer to the current webGL context at a given location
  7806. * @param buffer defines the buffer to bind
  7807. * @param location defines the index where to bind the buffer
  7808. */
  7809. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7810. /**
  7811. * Bind a specific block at a given index in a specific shader program
  7812. * @param pipelineContext defines the pipeline context to use
  7813. * @param blockName defines the block name
  7814. * @param index defines the index where to bind the block
  7815. */
  7816. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * Uniform buffer objects.
  7822. *
  7823. * Handles blocks of uniform on the GPU.
  7824. *
  7825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7826. *
  7827. * For more information, please refer to :
  7828. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7829. */
  7830. export class UniformBuffer {
  7831. private _engine;
  7832. private _buffer;
  7833. private _data;
  7834. private _bufferData;
  7835. private _dynamic?;
  7836. private _uniformLocations;
  7837. private _uniformSizes;
  7838. private _uniformLocationPointer;
  7839. private _needSync;
  7840. private _noUBO;
  7841. private _currentEffect;
  7842. /** @hidden */
  7843. _alreadyBound: boolean;
  7844. private static _MAX_UNIFORM_SIZE;
  7845. private static _tempBuffer;
  7846. /**
  7847. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7848. * This is dynamic to allow compat with webgl 1 and 2.
  7849. * You will need to pass the name of the uniform as well as the value.
  7850. */
  7851. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7852. /**
  7853. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7854. * This is dynamic to allow compat with webgl 1 and 2.
  7855. * You will need to pass the name of the uniform as well as the value.
  7856. */
  7857. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7858. /**
  7859. * Lambda to Update a single float in a uniform buffer.
  7860. * This is dynamic to allow compat with webgl 1 and 2.
  7861. * You will need to pass the name of the uniform as well as the value.
  7862. */
  7863. updateFloat: (name: string, x: number) => void;
  7864. /**
  7865. * Lambda to Update a vec2 of float in a uniform buffer.
  7866. * This is dynamic to allow compat with webgl 1 and 2.
  7867. * You will need to pass the name of the uniform as well as the value.
  7868. */
  7869. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7870. /**
  7871. * Lambda to Update a vec3 of float in a uniform buffer.
  7872. * This is dynamic to allow compat with webgl 1 and 2.
  7873. * You will need to pass the name of the uniform as well as the value.
  7874. */
  7875. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7876. /**
  7877. * Lambda to Update a vec4 of float in a uniform buffer.
  7878. * This is dynamic to allow compat with webgl 1 and 2.
  7879. * You will need to pass the name of the uniform as well as the value.
  7880. */
  7881. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7882. /**
  7883. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7884. * This is dynamic to allow compat with webgl 1 and 2.
  7885. * You will need to pass the name of the uniform as well as the value.
  7886. */
  7887. updateMatrix: (name: string, mat: Matrix) => void;
  7888. /**
  7889. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7890. * This is dynamic to allow compat with webgl 1 and 2.
  7891. * You will need to pass the name of the uniform as well as the value.
  7892. */
  7893. updateVector3: (name: string, vector: Vector3) => void;
  7894. /**
  7895. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7896. * This is dynamic to allow compat with webgl 1 and 2.
  7897. * You will need to pass the name of the uniform as well as the value.
  7898. */
  7899. updateVector4: (name: string, vector: Vector4) => void;
  7900. /**
  7901. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7902. * This is dynamic to allow compat with webgl 1 and 2.
  7903. * You will need to pass the name of the uniform as well as the value.
  7904. */
  7905. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7906. /**
  7907. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7908. * This is dynamic to allow compat with webgl 1 and 2.
  7909. * You will need to pass the name of the uniform as well as the value.
  7910. */
  7911. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7912. /**
  7913. * Instantiates a new Uniform buffer objects.
  7914. *
  7915. * Handles blocks of uniform on the GPU.
  7916. *
  7917. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7918. *
  7919. * For more information, please refer to :
  7920. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7921. * @param engine Define the engine the buffer is associated with
  7922. * @param data Define the data contained in the buffer
  7923. * @param dynamic Define if the buffer is updatable
  7924. */
  7925. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7926. /**
  7927. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7928. * or just falling back on setUniformXXX calls.
  7929. */
  7930. get useUbo(): boolean;
  7931. /**
  7932. * Indicates if the WebGL underlying uniform buffer is in sync
  7933. * with the javascript cache data.
  7934. */
  7935. get isSync(): boolean;
  7936. /**
  7937. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7938. * Also, a dynamic UniformBuffer will disable cache verification and always
  7939. * update the underlying WebGL uniform buffer to the GPU.
  7940. * @returns if Dynamic, otherwise false
  7941. */
  7942. isDynamic(): boolean;
  7943. /**
  7944. * The data cache on JS side.
  7945. * @returns the underlying data as a float array
  7946. */
  7947. getData(): Float32Array;
  7948. /**
  7949. * The underlying WebGL Uniform buffer.
  7950. * @returns the webgl buffer
  7951. */
  7952. getBuffer(): Nullable<DataBuffer>;
  7953. /**
  7954. * std140 layout specifies how to align data within an UBO structure.
  7955. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7956. * for specs.
  7957. */
  7958. private _fillAlignment;
  7959. /**
  7960. * Adds an uniform in the buffer.
  7961. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7962. * for the layout to be correct !
  7963. * @param name Name of the uniform, as used in the uniform block in the shader.
  7964. * @param size Data size, or data directly.
  7965. */
  7966. addUniform(name: string, size: number | number[]): void;
  7967. /**
  7968. * Adds a Matrix 4x4 to the uniform buffer.
  7969. * @param name Name of the uniform, as used in the uniform block in the shader.
  7970. * @param mat A 4x4 matrix.
  7971. */
  7972. addMatrix(name: string, mat: Matrix): void;
  7973. /**
  7974. * Adds a vec2 to the uniform buffer.
  7975. * @param name Name of the uniform, as used in the uniform block in the shader.
  7976. * @param x Define the x component value of the vec2
  7977. * @param y Define the y component value of the vec2
  7978. */
  7979. addFloat2(name: string, x: number, y: number): void;
  7980. /**
  7981. * Adds a vec3 to the uniform buffer.
  7982. * @param name Name of the uniform, as used in the uniform block in the shader.
  7983. * @param x Define the x component value of the vec3
  7984. * @param y Define the y component value of the vec3
  7985. * @param z Define the z component value of the vec3
  7986. */
  7987. addFloat3(name: string, x: number, y: number, z: number): void;
  7988. /**
  7989. * Adds a vec3 to the uniform buffer.
  7990. * @param name Name of the uniform, as used in the uniform block in the shader.
  7991. * @param color Define the vec3 from a Color
  7992. */
  7993. addColor3(name: string, color: Color3): void;
  7994. /**
  7995. * Adds a vec4 to the uniform buffer.
  7996. * @param name Name of the uniform, as used in the uniform block in the shader.
  7997. * @param color Define the rgb components from a Color
  7998. * @param alpha Define the a component of the vec4
  7999. */
  8000. addColor4(name: string, color: Color3, alpha: number): void;
  8001. /**
  8002. * Adds a vec3 to the uniform buffer.
  8003. * @param name Name of the uniform, as used in the uniform block in the shader.
  8004. * @param vector Define the vec3 components from a Vector
  8005. */
  8006. addVector3(name: string, vector: Vector3): void;
  8007. /**
  8008. * Adds a Matrix 3x3 to the uniform buffer.
  8009. * @param name Name of the uniform, as used in the uniform block in the shader.
  8010. */
  8011. addMatrix3x3(name: string): void;
  8012. /**
  8013. * Adds a Matrix 2x2 to the uniform buffer.
  8014. * @param name Name of the uniform, as used in the uniform block in the shader.
  8015. */
  8016. addMatrix2x2(name: string): void;
  8017. /**
  8018. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8019. */
  8020. create(): void;
  8021. /** @hidden */
  8022. _rebuild(): void;
  8023. /**
  8024. * Updates the WebGL Uniform Buffer on the GPU.
  8025. * If the `dynamic` flag is set to true, no cache comparison is done.
  8026. * Otherwise, the buffer will be updated only if the cache differs.
  8027. */
  8028. update(): void;
  8029. /**
  8030. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8031. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8032. * @param data Define the flattened data
  8033. * @param size Define the size of the data.
  8034. */
  8035. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8036. private _valueCache;
  8037. private _cacheMatrix;
  8038. private _updateMatrix3x3ForUniform;
  8039. private _updateMatrix3x3ForEffect;
  8040. private _updateMatrix2x2ForEffect;
  8041. private _updateMatrix2x2ForUniform;
  8042. private _updateFloatForEffect;
  8043. private _updateFloatForUniform;
  8044. private _updateFloat2ForEffect;
  8045. private _updateFloat2ForUniform;
  8046. private _updateFloat3ForEffect;
  8047. private _updateFloat3ForUniform;
  8048. private _updateFloat4ForEffect;
  8049. private _updateFloat4ForUniform;
  8050. private _updateMatrixForEffect;
  8051. private _updateMatrixForUniform;
  8052. private _updateVector3ForEffect;
  8053. private _updateVector3ForUniform;
  8054. private _updateVector4ForEffect;
  8055. private _updateVector4ForUniform;
  8056. private _updateColor3ForEffect;
  8057. private _updateColor3ForUniform;
  8058. private _updateColor4ForEffect;
  8059. private _updateColor4ForUniform;
  8060. /**
  8061. * Sets a sampler uniform on the effect.
  8062. * @param name Define the name of the sampler.
  8063. * @param texture Define the texture to set in the sampler
  8064. */
  8065. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8066. /**
  8067. * Directly updates the value of the uniform in the cache AND on the GPU.
  8068. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8069. * @param data Define the flattened data
  8070. */
  8071. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8072. /**
  8073. * Binds this uniform buffer to an effect.
  8074. * @param effect Define the effect to bind the buffer to
  8075. * @param name Name of the uniform block in the shader.
  8076. */
  8077. bindToEffect(effect: Effect, name: string): void;
  8078. /**
  8079. * Disposes the uniform buffer.
  8080. */
  8081. dispose(): void;
  8082. }
  8083. }
  8084. declare module BABYLON {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module BABYLON {
  8191. /**
  8192. * Enum that determines the text-wrapping mode to use.
  8193. */
  8194. export enum InspectableType {
  8195. /**
  8196. * Checkbox for booleans
  8197. */
  8198. Checkbox = 0,
  8199. /**
  8200. * Sliders for numbers
  8201. */
  8202. Slider = 1,
  8203. /**
  8204. * Vector3
  8205. */
  8206. Vector3 = 2,
  8207. /**
  8208. * Quaternions
  8209. */
  8210. Quaternion = 3,
  8211. /**
  8212. * Color3
  8213. */
  8214. Color3 = 4,
  8215. /**
  8216. * String
  8217. */
  8218. String = 5
  8219. }
  8220. /**
  8221. * Interface used to define custom inspectable properties.
  8222. * This interface is used by the inspector to display custom property grids
  8223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8224. */
  8225. export interface IInspectable {
  8226. /**
  8227. * Gets the label to display
  8228. */
  8229. label: string;
  8230. /**
  8231. * Gets the name of the property to edit
  8232. */
  8233. propertyName: string;
  8234. /**
  8235. * Gets the type of the editor to use
  8236. */
  8237. type: InspectableType;
  8238. /**
  8239. * Gets the minimum value of the property when using in "slider" mode
  8240. */
  8241. min?: number;
  8242. /**
  8243. * Gets the maximum value of the property when using in "slider" mode
  8244. */
  8245. max?: number;
  8246. /**
  8247. * Gets the setp to use when using in "slider" mode
  8248. */
  8249. step?: number;
  8250. }
  8251. }
  8252. declare module BABYLON {
  8253. /**
  8254. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8255. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8256. * 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.
  8257. */
  8258. export abstract class Light extends Node {
  8259. /**
  8260. * Falloff Default: light is falling off following the material specification:
  8261. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8262. */
  8263. static readonly FALLOFF_DEFAULT: number;
  8264. /**
  8265. * Falloff Physical: light is falling off following the inverse squared distance law.
  8266. */
  8267. static readonly FALLOFF_PHYSICAL: number;
  8268. /**
  8269. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8270. * to enhance interoperability with other engines.
  8271. */
  8272. static readonly FALLOFF_GLTF: number;
  8273. /**
  8274. * Falloff Standard: light is falling off like in the standard material
  8275. * to enhance interoperability with other materials.
  8276. */
  8277. static readonly FALLOFF_STANDARD: number;
  8278. /**
  8279. * If every light affecting the material is in this lightmapMode,
  8280. * material.lightmapTexture adds or multiplies
  8281. * (depends on material.useLightmapAsShadowmap)
  8282. * after every other light calculations.
  8283. */
  8284. static readonly LIGHTMAP_DEFAULT: number;
  8285. /**
  8286. * material.lightmapTexture as only diffuse lighting from this light
  8287. * adds only specular lighting from this light
  8288. * adds dynamic shadows
  8289. */
  8290. static readonly LIGHTMAP_SPECULAR: number;
  8291. /**
  8292. * material.lightmapTexture as only lighting
  8293. * no light calculation from this light
  8294. * only adds dynamic shadows from this light
  8295. */
  8296. static readonly LIGHTMAP_SHADOWSONLY: number;
  8297. /**
  8298. * Each light type uses the default quantity according to its type:
  8299. * point/spot lights use luminous intensity
  8300. * directional lights use illuminance
  8301. */
  8302. static readonly INTENSITYMODE_AUTOMATIC: number;
  8303. /**
  8304. * lumen (lm)
  8305. */
  8306. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8307. /**
  8308. * candela (lm/sr)
  8309. */
  8310. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8311. /**
  8312. * lux (lm/m^2)
  8313. */
  8314. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8315. /**
  8316. * nit (cd/m^2)
  8317. */
  8318. static readonly INTENSITYMODE_LUMINANCE: number;
  8319. /**
  8320. * Light type const id of the point light.
  8321. */
  8322. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8323. /**
  8324. * Light type const id of the directional light.
  8325. */
  8326. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8327. /**
  8328. * Light type const id of the spot light.
  8329. */
  8330. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8331. /**
  8332. * Light type const id of the hemispheric light.
  8333. */
  8334. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8335. /**
  8336. * Diffuse gives the basic color to an object.
  8337. */
  8338. diffuse: Color3;
  8339. /**
  8340. * Specular produces a highlight color on an object.
  8341. * Note: This is note affecting PBR materials.
  8342. */
  8343. specular: Color3;
  8344. /**
  8345. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8346. * falling off base on range or angle.
  8347. * This can be set to any values in Light.FALLOFF_x.
  8348. *
  8349. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8350. * other types of materials.
  8351. */
  8352. falloffType: number;
  8353. /**
  8354. * Strength of the light.
  8355. * Note: By default it is define in the framework own unit.
  8356. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8357. */
  8358. intensity: number;
  8359. private _range;
  8360. protected _inverseSquaredRange: number;
  8361. /**
  8362. * Defines how far from the source the light is impacting in scene units.
  8363. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8364. */
  8365. get range(): number;
  8366. /**
  8367. * Defines how far from the source the light is impacting in scene units.
  8368. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8369. */
  8370. set range(value: number);
  8371. /**
  8372. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8373. * of light.
  8374. */
  8375. private _photometricScale;
  8376. private _intensityMode;
  8377. /**
  8378. * Gets the photometric scale used to interpret the intensity.
  8379. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8380. */
  8381. get intensityMode(): number;
  8382. /**
  8383. * Sets the photometric scale used to interpret the intensity.
  8384. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8385. */
  8386. set intensityMode(value: number);
  8387. private _radius;
  8388. /**
  8389. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8390. */
  8391. get radius(): number;
  8392. /**
  8393. * sets the light radius used by PBR Materials to simulate soft area lights.
  8394. */
  8395. set radius(value: number);
  8396. private _renderPriority;
  8397. /**
  8398. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8399. * exceeding the number allowed of the materials.
  8400. */
  8401. renderPriority: number;
  8402. private _shadowEnabled;
  8403. /**
  8404. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8405. * the current shadow generator.
  8406. */
  8407. get shadowEnabled(): boolean;
  8408. /**
  8409. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8410. * the current shadow generator.
  8411. */
  8412. set shadowEnabled(value: boolean);
  8413. private _includedOnlyMeshes;
  8414. /**
  8415. * Gets the only meshes impacted by this light.
  8416. */
  8417. get includedOnlyMeshes(): AbstractMesh[];
  8418. /**
  8419. * Sets the only meshes impacted by this light.
  8420. */
  8421. set includedOnlyMeshes(value: AbstractMesh[]);
  8422. private _excludedMeshes;
  8423. /**
  8424. * Gets the meshes not impacted by this light.
  8425. */
  8426. get excludedMeshes(): AbstractMesh[];
  8427. /**
  8428. * Sets the meshes not impacted by this light.
  8429. */
  8430. set excludedMeshes(value: AbstractMesh[]);
  8431. private _excludeWithLayerMask;
  8432. /**
  8433. * Gets the layer id use to find what meshes are not impacted by the light.
  8434. * Inactive if 0
  8435. */
  8436. get excludeWithLayerMask(): number;
  8437. /**
  8438. * Sets the layer id use to find what meshes are not impacted by the light.
  8439. * Inactive if 0
  8440. */
  8441. set excludeWithLayerMask(value: number);
  8442. private _includeOnlyWithLayerMask;
  8443. /**
  8444. * Gets the layer id use to find what meshes are impacted by the light.
  8445. * Inactive if 0
  8446. */
  8447. get includeOnlyWithLayerMask(): number;
  8448. /**
  8449. * Sets the layer id use to find what meshes are impacted by the light.
  8450. * Inactive if 0
  8451. */
  8452. set includeOnlyWithLayerMask(value: number);
  8453. private _lightmapMode;
  8454. /**
  8455. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8456. */
  8457. get lightmapMode(): number;
  8458. /**
  8459. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8460. */
  8461. set lightmapMode(value: number);
  8462. /**
  8463. * Shadow generator associted to the light.
  8464. * @hidden Internal use only.
  8465. */
  8466. _shadowGenerator: Nullable<IShadowGenerator>;
  8467. /**
  8468. * @hidden Internal use only.
  8469. */
  8470. _excludedMeshesIds: string[];
  8471. /**
  8472. * @hidden Internal use only.
  8473. */
  8474. _includedOnlyMeshesIds: string[];
  8475. /**
  8476. * The current light unifom buffer.
  8477. * @hidden Internal use only.
  8478. */
  8479. _uniformBuffer: UniformBuffer;
  8480. /** @hidden */
  8481. _renderId: number;
  8482. /**
  8483. * Creates a Light object in the scene.
  8484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8485. * @param name The firendly name of the light
  8486. * @param scene The scene the light belongs too
  8487. */
  8488. constructor(name: string, scene: Scene);
  8489. protected abstract _buildUniformLayout(): void;
  8490. /**
  8491. * Sets the passed Effect "effect" with the Light information.
  8492. * @param effect The effect to update
  8493. * @param lightIndex The index of the light in the effect to update
  8494. * @returns The light
  8495. */
  8496. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8497. /**
  8498. * Sets the passed Effect "effect" with the Light textures.
  8499. * @param effect The effect to update
  8500. * @param lightIndex The index of the light in the effect to update
  8501. * @returns The light
  8502. */
  8503. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8504. /**
  8505. * Binds the lights information from the scene to the effect for the given mesh.
  8506. * @param lightIndex Light index
  8507. * @param scene The scene where the light belongs to
  8508. * @param effect The effect we are binding the data to
  8509. * @param useSpecular Defines if specular is supported
  8510. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8511. */
  8512. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8513. /**
  8514. * Sets the passed Effect "effect" with the Light information.
  8515. * @param effect The effect to update
  8516. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8517. * @returns The light
  8518. */
  8519. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8520. /**
  8521. * Returns the string "Light".
  8522. * @returns the class name
  8523. */
  8524. getClassName(): string;
  8525. /** @hidden */
  8526. readonly _isLight: boolean;
  8527. /**
  8528. * Converts the light information to a readable string for debug purpose.
  8529. * @param fullDetails Supports for multiple levels of logging within scene loading
  8530. * @returns the human readable light info
  8531. */
  8532. toString(fullDetails?: boolean): string;
  8533. /** @hidden */
  8534. protected _syncParentEnabledState(): void;
  8535. /**
  8536. * Set the enabled state of this node.
  8537. * @param value - the new enabled state
  8538. */
  8539. setEnabled(value: boolean): void;
  8540. /**
  8541. * Returns the Light associated shadow generator if any.
  8542. * @return the associated shadow generator.
  8543. */
  8544. getShadowGenerator(): Nullable<IShadowGenerator>;
  8545. /**
  8546. * Returns a Vector3, the absolute light position in the World.
  8547. * @returns the world space position of the light
  8548. */
  8549. getAbsolutePosition(): Vector3;
  8550. /**
  8551. * Specifies if the light will affect the passed mesh.
  8552. * @param mesh The mesh to test against the light
  8553. * @return true the mesh is affected otherwise, false.
  8554. */
  8555. canAffectMesh(mesh: AbstractMesh): boolean;
  8556. /**
  8557. * Sort function to order lights for rendering.
  8558. * @param a First Light object to compare to second.
  8559. * @param b Second Light object to compare first.
  8560. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8561. */
  8562. static CompareLightsPriority(a: Light, b: Light): number;
  8563. /**
  8564. * Releases resources associated with this node.
  8565. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8566. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8567. */
  8568. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8569. /**
  8570. * Returns the light type ID (integer).
  8571. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8572. */
  8573. getTypeID(): number;
  8574. /**
  8575. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8576. * @returns the scaled intensity in intensity mode unit
  8577. */
  8578. getScaledIntensity(): number;
  8579. /**
  8580. * Returns a new Light object, named "name", from the current one.
  8581. * @param name The name of the cloned light
  8582. * @param newParent The parent of this light, if it has one
  8583. * @returns the new created light
  8584. */
  8585. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8586. /**
  8587. * Serializes the current light into a Serialization object.
  8588. * @returns the serialized object.
  8589. */
  8590. serialize(): any;
  8591. /**
  8592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8593. * This new light is named "name" and added to the passed scene.
  8594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8595. * @param name The friendly name of the light
  8596. * @param scene The scene the new light will belong to
  8597. * @returns the constructor function
  8598. */
  8599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8600. /**
  8601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8602. * @param parsedLight The JSON representation of the light
  8603. * @param scene The scene to create the parsed light in
  8604. * @returns the created light after parsing
  8605. */
  8606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8607. private _hookArrayForExcluded;
  8608. private _hookArrayForIncludedOnly;
  8609. private _resyncMeshes;
  8610. /**
  8611. * Forces the meshes to update their light related information in their rendering used effects
  8612. * @hidden Internal Use Only
  8613. */
  8614. _markMeshesAsLightDirty(): void;
  8615. /**
  8616. * Recomputes the cached photometric scale if needed.
  8617. */
  8618. private _computePhotometricScale;
  8619. /**
  8620. * Returns the Photometric Scale according to the light type and intensity mode.
  8621. */
  8622. private _getPhotometricScale;
  8623. /**
  8624. * Reorder the light in the scene according to their defined priority.
  8625. * @hidden Internal Use Only
  8626. */
  8627. _reorderLightsInScene(): void;
  8628. /**
  8629. * Prepares the list of defines specific to the light type.
  8630. * @param defines the list of defines
  8631. * @param lightIndex defines the index of the light for the effect
  8632. */
  8633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8634. }
  8635. }
  8636. declare module BABYLON {
  8637. /** Defines supported spaces */
  8638. export enum Space {
  8639. /** Local (object) space */
  8640. LOCAL = 0,
  8641. /** World space */
  8642. WORLD = 1,
  8643. /** Bone space */
  8644. BONE = 2
  8645. }
  8646. /** Defines the 3 main axes */
  8647. export class Axis {
  8648. /** X axis */
  8649. static X: Vector3;
  8650. /** Y axis */
  8651. static Y: Vector3;
  8652. /** Z axis */
  8653. static Z: Vector3;
  8654. }
  8655. /**
  8656. * Defines cartesian components.
  8657. */
  8658. export enum Coordinate {
  8659. /** X axis */
  8660. X = 0,
  8661. /** Y axis */
  8662. Y = 1,
  8663. /** Z axis */
  8664. Z = 2
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Interface describing all the common properties and methods a shadow light needs to implement.
  8670. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8671. * as well as binding the different shadow properties to the effects.
  8672. */
  8673. export interface IShadowLight extends Light {
  8674. /**
  8675. * The light id in the scene (used in scene.findLighById for instance)
  8676. */
  8677. id: string;
  8678. /**
  8679. * The position the shdow will be casted from.
  8680. */
  8681. position: Vector3;
  8682. /**
  8683. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8684. */
  8685. direction: Vector3;
  8686. /**
  8687. * The transformed position. Position of the light in world space taking parenting in account.
  8688. */
  8689. transformedPosition: Vector3;
  8690. /**
  8691. * The transformed direction. Direction of the light in world space taking parenting in account.
  8692. */
  8693. transformedDirection: Vector3;
  8694. /**
  8695. * The friendly name of the light in the scene.
  8696. */
  8697. name: string;
  8698. /**
  8699. * Defines the shadow projection clipping minimum z value.
  8700. */
  8701. shadowMinZ: number;
  8702. /**
  8703. * Defines the shadow projection clipping maximum z value.
  8704. */
  8705. shadowMaxZ: number;
  8706. /**
  8707. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8708. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8709. */
  8710. computeTransformedInformation(): boolean;
  8711. /**
  8712. * Gets the scene the light belongs to.
  8713. * @returns The scene
  8714. */
  8715. getScene(): Scene;
  8716. /**
  8717. * Callback defining a custom Projection Matrix Builder.
  8718. * This can be used to override the default projection matrix computation.
  8719. */
  8720. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8721. /**
  8722. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8723. * @param matrix The materix to updated with the projection information
  8724. * @param viewMatrix The transform matrix of the light
  8725. * @param renderList The list of mesh to render in the map
  8726. * @returns The current light
  8727. */
  8728. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8729. /**
  8730. * Gets the current depth scale used in ESM.
  8731. * @returns The scale
  8732. */
  8733. getDepthScale(): number;
  8734. /**
  8735. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8736. * @returns true if a cube texture needs to be use
  8737. */
  8738. needCube(): boolean;
  8739. /**
  8740. * Detects if the projection matrix requires to be recomputed this frame.
  8741. * @returns true if it requires to be recomputed otherwise, false.
  8742. */
  8743. needProjectionMatrixCompute(): boolean;
  8744. /**
  8745. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8746. */
  8747. forceProjectionMatrixCompute(): void;
  8748. /**
  8749. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8750. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8751. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8752. */
  8753. getShadowDirection(faceIndex?: number): Vector3;
  8754. /**
  8755. * Gets the minZ used for shadow according to both the scene and the light.
  8756. * @param activeCamera The camera we are returning the min for
  8757. * @returns the depth min z
  8758. */
  8759. getDepthMinZ(activeCamera: Camera): number;
  8760. /**
  8761. * Gets the maxZ used for shadow according to both the scene and the light.
  8762. * @param activeCamera The camera we are returning the max for
  8763. * @returns the depth max z
  8764. */
  8765. getDepthMaxZ(activeCamera: Camera): number;
  8766. }
  8767. /**
  8768. * Base implementation IShadowLight
  8769. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8770. */
  8771. export abstract class ShadowLight extends Light implements IShadowLight {
  8772. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8773. protected _position: Vector3;
  8774. protected _setPosition(value: Vector3): void;
  8775. /**
  8776. * Sets the position the shadow will be casted from. Also use as the light position for both
  8777. * point and spot lights.
  8778. */
  8779. get position(): Vector3;
  8780. /**
  8781. * Sets the position the shadow will be casted from. Also use as the light position for both
  8782. * point and spot lights.
  8783. */
  8784. set position(value: Vector3);
  8785. protected _direction: Vector3;
  8786. protected _setDirection(value: Vector3): void;
  8787. /**
  8788. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8789. * Also use as the light direction on spot and directional lights.
  8790. */
  8791. get direction(): Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8794. * Also use as the light direction on spot and directional lights.
  8795. */
  8796. set direction(value: Vector3);
  8797. protected _shadowMinZ: number;
  8798. /**
  8799. * Gets the shadow projection clipping minimum z value.
  8800. */
  8801. get shadowMinZ(): number;
  8802. /**
  8803. * Sets the shadow projection clipping minimum z value.
  8804. */
  8805. set shadowMinZ(value: number);
  8806. protected _shadowMaxZ: number;
  8807. /**
  8808. * Sets the shadow projection clipping maximum z value.
  8809. */
  8810. get shadowMaxZ(): number;
  8811. /**
  8812. * Gets the shadow projection clipping maximum z value.
  8813. */
  8814. set shadowMaxZ(value: number);
  8815. /**
  8816. * Callback defining a custom Projection Matrix Builder.
  8817. * This can be used to override the default projection matrix computation.
  8818. */
  8819. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8820. /**
  8821. * The transformed position. Position of the light in world space taking parenting in account.
  8822. */
  8823. transformedPosition: Vector3;
  8824. /**
  8825. * The transformed direction. Direction of the light in world space taking parenting in account.
  8826. */
  8827. transformedDirection: Vector3;
  8828. private _needProjectionMatrixCompute;
  8829. /**
  8830. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8831. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8832. */
  8833. computeTransformedInformation(): boolean;
  8834. /**
  8835. * Return the depth scale used for the shadow map.
  8836. * @returns the depth scale.
  8837. */
  8838. getDepthScale(): number;
  8839. /**
  8840. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8841. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8842. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8843. */
  8844. getShadowDirection(faceIndex?: number): Vector3;
  8845. /**
  8846. * Returns the ShadowLight absolute position in the World.
  8847. * @returns the position vector in world space
  8848. */
  8849. getAbsolutePosition(): Vector3;
  8850. /**
  8851. * Sets the ShadowLight direction toward the passed target.
  8852. * @param target The point to target in local space
  8853. * @returns the updated ShadowLight direction
  8854. */
  8855. setDirectionToTarget(target: Vector3): Vector3;
  8856. /**
  8857. * Returns the light rotation in euler definition.
  8858. * @returns the x y z rotation in local space.
  8859. */
  8860. getRotation(): Vector3;
  8861. /**
  8862. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8863. * @returns true if a cube texture needs to be use
  8864. */
  8865. needCube(): boolean;
  8866. /**
  8867. * Detects if the projection matrix requires to be recomputed this frame.
  8868. * @returns true if it requires to be recomputed otherwise, false.
  8869. */
  8870. needProjectionMatrixCompute(): boolean;
  8871. /**
  8872. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8873. */
  8874. forceProjectionMatrixCompute(): void;
  8875. /** @hidden */
  8876. _initCache(): void;
  8877. /** @hidden */
  8878. _isSynchronized(): boolean;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. /**
  8886. * Gets the minZ used for shadow according to both the scene and the light.
  8887. * @param activeCamera The camera we are returning the min for
  8888. * @returns the depth min z
  8889. */
  8890. getDepthMinZ(activeCamera: Camera): number;
  8891. /**
  8892. * Gets the maxZ used for shadow according to both the scene and the light.
  8893. * @param activeCamera The camera we are returning the max for
  8894. * @returns the depth max z
  8895. */
  8896. getDepthMaxZ(activeCamera: Camera): number;
  8897. /**
  8898. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8899. * @param matrix The materix to updated with the projection information
  8900. * @param viewMatrix The transform matrix of the light
  8901. * @param renderList The list of mesh to render in the map
  8902. * @returns The current light
  8903. */
  8904. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8905. }
  8906. }
  8907. declare module BABYLON {
  8908. /**
  8909. * Configuration needed for prepass-capable materials
  8910. */
  8911. export class PrePassConfiguration {
  8912. /**
  8913. * Previous world matrices of meshes carrying this material
  8914. * Used for computing velocity
  8915. */
  8916. previousWorldMatrices: {
  8917. [index: number]: Matrix;
  8918. };
  8919. /**
  8920. * Previous view project matrix
  8921. * Used for computing velocity
  8922. */
  8923. previousViewProjection: Matrix;
  8924. /**
  8925. * Previous bones of meshes carrying this material
  8926. * Used for computing velocity
  8927. */
  8928. previousBones: {
  8929. [index: number]: Float32Array;
  8930. };
  8931. /**
  8932. * Add the required uniforms to the current list.
  8933. * @param uniforms defines the current uniform list.
  8934. */
  8935. static AddUniforms(uniforms: string[]): void;
  8936. /**
  8937. * Add the required samplers to the current list.
  8938. * @param samplers defines the current sampler list.
  8939. */
  8940. static AddSamplers(samplers: string[]): void;
  8941. /**
  8942. * Binds the material data.
  8943. * @param effect defines the effect to update
  8944. * @param scene defines the scene the material belongs to.
  8945. * @param mesh The mesh
  8946. * @param world World matrix of this mesh
  8947. * @param isFrozen Is the material frozen
  8948. */
  8949. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8950. }
  8951. }
  8952. declare module BABYLON {
  8953. /**
  8954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8955. * This is the base of the follow, arc rotate cameras and Free camera
  8956. * @see https://doc.babylonjs.com/features/cameras
  8957. */
  8958. export class TargetCamera extends Camera {
  8959. private static _RigCamTransformMatrix;
  8960. private static _TargetTransformMatrix;
  8961. private static _TargetFocalPoint;
  8962. private _tmpUpVector;
  8963. private _tmpTargetVector;
  8964. /**
  8965. * Define the current direction the camera is moving to
  8966. */
  8967. cameraDirection: Vector3;
  8968. /**
  8969. * Define the current rotation the camera is rotating to
  8970. */
  8971. cameraRotation: Vector2;
  8972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8973. ignoreParentScaling: boolean;
  8974. /**
  8975. * When set, the up vector of the camera will be updated by the rotation of the camera
  8976. */
  8977. updateUpVectorFromRotation: boolean;
  8978. private _tmpQuaternion;
  8979. /**
  8980. * Define the current rotation of the camera
  8981. */
  8982. rotation: Vector3;
  8983. /**
  8984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8985. */
  8986. rotationQuaternion: Quaternion;
  8987. /**
  8988. * Define the current speed of the camera
  8989. */
  8990. speed: number;
  8991. /**
  8992. * Add constraint to the camera to prevent it to move freely in all directions and
  8993. * around all axis.
  8994. */
  8995. noRotationConstraint: boolean;
  8996. /**
  8997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8998. * panning
  8999. */
  9000. invertRotation: boolean;
  9001. /**
  9002. * Speed multiplier for inverse camera panning
  9003. */
  9004. inverseRotationSpeed: number;
  9005. /**
  9006. * Define the current target of the camera as an object or a position.
  9007. */
  9008. lockedTarget: any;
  9009. /** @hidden */
  9010. _currentTarget: Vector3;
  9011. /** @hidden */
  9012. _initialFocalDistance: number;
  9013. /** @hidden */
  9014. _viewMatrix: Matrix;
  9015. /** @hidden */
  9016. _camMatrix: Matrix;
  9017. /** @hidden */
  9018. _cameraTransformMatrix: Matrix;
  9019. /** @hidden */
  9020. _cameraRotationMatrix: Matrix;
  9021. /** @hidden */
  9022. _referencePoint: Vector3;
  9023. /** @hidden */
  9024. _transformedReferencePoint: Vector3;
  9025. /** @hidden */
  9026. _reset: () => void;
  9027. private _defaultUp;
  9028. /**
  9029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9030. * This is the base of the follow, arc rotate cameras and Free camera
  9031. * @see https://doc.babylonjs.com/features/cameras
  9032. * @param name Defines the name of the camera in the scene
  9033. * @param position Defines the start position of the camera in the scene
  9034. * @param scene Defines the scene the camera belongs to
  9035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9036. */
  9037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9038. /**
  9039. * Gets the position in front of the camera at a given distance.
  9040. * @param distance The distance from the camera we want the position to be
  9041. * @returns the position
  9042. */
  9043. getFrontPosition(distance: number): Vector3;
  9044. /** @hidden */
  9045. _getLockedTargetPosition(): Nullable<Vector3>;
  9046. private _storedPosition;
  9047. private _storedRotation;
  9048. private _storedRotationQuaternion;
  9049. /**
  9050. * Store current camera state of the camera (fov, position, rotation, etc..)
  9051. * @returns the camera
  9052. */
  9053. storeState(): Camera;
  9054. /**
  9055. * Restored camera state. You must call storeState() first
  9056. * @returns whether it was successful or not
  9057. * @hidden
  9058. */
  9059. _restoreStateValues(): boolean;
  9060. /** @hidden */
  9061. _initCache(): void;
  9062. /** @hidden */
  9063. _updateCache(ignoreParentClass?: boolean): void;
  9064. /** @hidden */
  9065. _isSynchronizedViewMatrix(): boolean;
  9066. /** @hidden */
  9067. _computeLocalCameraSpeed(): number;
  9068. /**
  9069. * Defines the target the camera should look at.
  9070. * @param target Defines the new target as a Vector or a mesh
  9071. */
  9072. setTarget(target: Vector3): void;
  9073. /**
  9074. * Defines the target point of the camera.
  9075. * The camera looks towards it form the radius distance.
  9076. */
  9077. get target(): Vector3;
  9078. set target(value: Vector3);
  9079. /**
  9080. * Return the current target position of the camera. This value is expressed in local space.
  9081. * @returns the target position
  9082. */
  9083. getTarget(): Vector3;
  9084. /** @hidden */
  9085. _decideIfNeedsToMove(): boolean;
  9086. /** @hidden */
  9087. _updatePosition(): void;
  9088. /** @hidden */
  9089. _checkInputs(): void;
  9090. protected _updateCameraRotationMatrix(): void;
  9091. /**
  9092. * 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)
  9093. * @returns the current camera
  9094. */
  9095. private _rotateUpVectorWithCameraRotationMatrix;
  9096. private _cachedRotationZ;
  9097. private _cachedQuaternionRotationZ;
  9098. /** @hidden */
  9099. _getViewMatrix(): Matrix;
  9100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9101. /**
  9102. * @hidden
  9103. */
  9104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9105. /**
  9106. * @hidden
  9107. */
  9108. _updateRigCameras(): void;
  9109. private _getRigCamPositionAndTarget;
  9110. /**
  9111. * Gets the current object class name.
  9112. * @return the class name
  9113. */
  9114. getClassName(): string;
  9115. }
  9116. }
  9117. declare module BABYLON {
  9118. /**
  9119. * @ignore
  9120. * This is a list of all the different input types that are available in the application.
  9121. * Fo instance: ArcRotateCameraGamepadInput...
  9122. */
  9123. export var CameraInputTypes: {};
  9124. /**
  9125. * This is the contract to implement in order to create a new input class.
  9126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9127. */
  9128. export interface ICameraInput<TCamera extends Camera> {
  9129. /**
  9130. * Defines the camera the input is attached to.
  9131. */
  9132. camera: Nullable<TCamera>;
  9133. /**
  9134. * Gets the class name of the current intput.
  9135. * @returns the class name
  9136. */
  9137. getClassName(): string;
  9138. /**
  9139. * Get the friendly name associated with the input class.
  9140. * @returns the input friendly name
  9141. */
  9142. getSimpleName(): string;
  9143. /**
  9144. * Attach the input controls to a specific dom element to get the input from.
  9145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9146. */
  9147. attachControl(noPreventDefault?: boolean): void;
  9148. /**
  9149. * Detach the current controls from the specified dom element.
  9150. */
  9151. detachControl(): void;
  9152. /**
  9153. * Update the current camera state depending on the inputs that have been used this frame.
  9154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9155. */
  9156. checkInputs?: () => void;
  9157. }
  9158. /**
  9159. * Represents a map of input types to input instance or input index to input instance.
  9160. */
  9161. export interface CameraInputsMap<TCamera extends Camera> {
  9162. /**
  9163. * Accessor to the input by input type.
  9164. */
  9165. [name: string]: ICameraInput<TCamera>;
  9166. /**
  9167. * Accessor to the input by input index.
  9168. */
  9169. [idx: number]: ICameraInput<TCamera>;
  9170. }
  9171. /**
  9172. * This represents the input manager used within a camera.
  9173. * It helps dealing with all the different kind of input attached to a camera.
  9174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9175. */
  9176. export class CameraInputsManager<TCamera extends Camera> {
  9177. /**
  9178. * Defines the list of inputs attahed to the camera.
  9179. */
  9180. attached: CameraInputsMap<TCamera>;
  9181. /**
  9182. * Defines the dom element the camera is collecting inputs from.
  9183. * This is null if the controls have not been attached.
  9184. */
  9185. attachedToElement: boolean;
  9186. /**
  9187. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9188. */
  9189. noPreventDefault: boolean;
  9190. /**
  9191. * Defined the camera the input manager belongs to.
  9192. */
  9193. camera: TCamera;
  9194. /**
  9195. * Update the current camera state depending on the inputs that have been used this frame.
  9196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9197. */
  9198. checkInputs: () => void;
  9199. /**
  9200. * Instantiate a new Camera Input Manager.
  9201. * @param camera Defines the camera the input manager blongs to
  9202. */
  9203. constructor(camera: TCamera);
  9204. /**
  9205. * Add an input method to a camera
  9206. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9207. * @param input camera input method
  9208. */
  9209. add(input: ICameraInput<TCamera>): void;
  9210. /**
  9211. * Remove a specific input method from a camera
  9212. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9213. * @param inputToRemove camera input method
  9214. */
  9215. remove(inputToRemove: ICameraInput<TCamera>): void;
  9216. /**
  9217. * Remove a specific input type from a camera
  9218. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9219. * @param inputType the type of the input to remove
  9220. */
  9221. removeByType(inputType: string): void;
  9222. private _addCheckInputs;
  9223. /**
  9224. * Attach the input controls to the currently attached dom element to listen the events from.
  9225. * @param input Defines the input to attach
  9226. */
  9227. attachInput(input: ICameraInput<TCamera>): void;
  9228. /**
  9229. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9230. * @param element Defines the dom element to collect the events from
  9231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9232. */
  9233. attachElement(noPreventDefault?: boolean): void;
  9234. /**
  9235. * Detach the current manager inputs controls from a specific dom element.
  9236. * @param element Defines the dom element to collect the events from
  9237. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9238. */
  9239. detachElement(disconnect?: boolean): void;
  9240. /**
  9241. * Rebuild the dynamic inputCheck function from the current list of
  9242. * defined inputs in the manager.
  9243. */
  9244. rebuildInputCheck(): void;
  9245. /**
  9246. * Remove all attached input methods from a camera
  9247. */
  9248. clear(): void;
  9249. /**
  9250. * Serialize the current input manager attached to a camera.
  9251. * This ensures than once parsed,
  9252. * the input associated to the camera will be identical to the current ones
  9253. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9254. */
  9255. serialize(serializedCamera: any): void;
  9256. /**
  9257. * Parses an input manager serialized JSON to restore the previous list of inputs
  9258. * and states associated to a camera.
  9259. * @param parsedCamera Defines the JSON to parse
  9260. */
  9261. parse(parsedCamera: any): void;
  9262. }
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * Gather the list of keyboard event types as constants.
  9267. */
  9268. export class KeyboardEventTypes {
  9269. /**
  9270. * The keydown event is fired when a key becomes active (pressed).
  9271. */
  9272. static readonly KEYDOWN: number;
  9273. /**
  9274. * The keyup event is fired when a key has been released.
  9275. */
  9276. static readonly KEYUP: number;
  9277. }
  9278. /**
  9279. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9280. */
  9281. export class KeyboardInfo {
  9282. /**
  9283. * Defines the type of event (KeyboardEventTypes)
  9284. */
  9285. type: number;
  9286. /**
  9287. * Defines the related dom event
  9288. */
  9289. event: KeyboardEvent;
  9290. /**
  9291. * Instantiates a new keyboard info.
  9292. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9293. * @param type Defines the type of event (KeyboardEventTypes)
  9294. * @param event Defines the related dom event
  9295. */
  9296. constructor(
  9297. /**
  9298. * Defines the type of event (KeyboardEventTypes)
  9299. */
  9300. type: number,
  9301. /**
  9302. * Defines the related dom event
  9303. */
  9304. event: KeyboardEvent);
  9305. }
  9306. /**
  9307. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9308. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9309. */
  9310. export class KeyboardInfoPre extends KeyboardInfo {
  9311. /**
  9312. * Defines the type of event (KeyboardEventTypes)
  9313. */
  9314. type: number;
  9315. /**
  9316. * Defines the related dom event
  9317. */
  9318. event: KeyboardEvent;
  9319. /**
  9320. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9321. */
  9322. skipOnPointerObservable: boolean;
  9323. /**
  9324. * Instantiates a new keyboard pre info.
  9325. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9326. * @param type Defines the type of event (KeyboardEventTypes)
  9327. * @param event Defines the related dom event
  9328. */
  9329. constructor(
  9330. /**
  9331. * Defines the type of event (KeyboardEventTypes)
  9332. */
  9333. type: number,
  9334. /**
  9335. * Defines the related dom event
  9336. */
  9337. event: KeyboardEvent);
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /**
  9342. * Manage the keyboard inputs to control the movement of a free camera.
  9343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9344. */
  9345. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9346. /**
  9347. * Defines the camera the input is attached to.
  9348. */
  9349. camera: FreeCamera;
  9350. /**
  9351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9352. */
  9353. keysUp: number[];
  9354. /**
  9355. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9356. */
  9357. keysUpward: number[];
  9358. /**
  9359. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9360. */
  9361. keysDown: number[];
  9362. /**
  9363. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9364. */
  9365. keysDownward: number[];
  9366. /**
  9367. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9368. */
  9369. keysLeft: number[];
  9370. /**
  9371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9372. */
  9373. keysRight: number[];
  9374. private _keys;
  9375. private _onCanvasBlurObserver;
  9376. private _onKeyboardObserver;
  9377. private _engine;
  9378. private _scene;
  9379. /**
  9380. * Attach the input controls to a specific dom element to get the input from.
  9381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9382. */
  9383. attachControl(noPreventDefault?: boolean): void;
  9384. /**
  9385. * Detach the current controls from the specified dom element.
  9386. */
  9387. detachControl(): void;
  9388. /**
  9389. * Update the current camera state depending on the inputs that have been used this frame.
  9390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9391. */
  9392. checkInputs(): void;
  9393. /**
  9394. * Gets the class name of the current intput.
  9395. * @returns the class name
  9396. */
  9397. getClassName(): string;
  9398. /** @hidden */
  9399. _onLostFocus(): void;
  9400. /**
  9401. * Get the friendly name associated with the input class.
  9402. * @returns the input friendly name
  9403. */
  9404. getSimpleName(): string;
  9405. }
  9406. }
  9407. declare module BABYLON {
  9408. /**
  9409. * Interface used to define Action
  9410. */
  9411. export interface IAction {
  9412. /**
  9413. * Trigger for the action
  9414. */
  9415. trigger: number;
  9416. /** Options of the trigger */
  9417. triggerOptions: any;
  9418. /**
  9419. * Gets the trigger parameters
  9420. * @returns the trigger parameters
  9421. */
  9422. getTriggerParameter(): any;
  9423. /**
  9424. * Internal only - executes current action event
  9425. * @hidden
  9426. */
  9427. _executeCurrent(evt?: ActionEvent): void;
  9428. /**
  9429. * Serialize placeholder for child classes
  9430. * @param parent of child
  9431. * @returns the serialized object
  9432. */
  9433. serialize(parent: any): any;
  9434. /**
  9435. * Internal only
  9436. * @hidden
  9437. */
  9438. _prepare(): void;
  9439. /**
  9440. * Internal only - manager for action
  9441. * @hidden
  9442. */
  9443. _actionManager: Nullable<AbstractActionManager>;
  9444. /**
  9445. * Adds action to chain of actions, may be a DoNothingAction
  9446. * @param action defines the next action to execute
  9447. * @returns The action passed in
  9448. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9449. */
  9450. then(action: IAction): IAction;
  9451. }
  9452. /**
  9453. * The action to be carried out following a trigger
  9454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9455. */
  9456. export class Action implements IAction {
  9457. /** the trigger, with or without parameters, for the action */
  9458. triggerOptions: any;
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: ActionManager;
  9468. private _nextActiveAction;
  9469. private _child;
  9470. private _condition?;
  9471. private _triggerParameter;
  9472. /**
  9473. * An event triggered prior to action being executed.
  9474. */
  9475. onBeforeExecuteObservable: Observable<Action>;
  9476. /**
  9477. * Creates a new Action
  9478. * @param triggerOptions the trigger, with or without parameters, for the action
  9479. * @param condition an optional determinant of action
  9480. */
  9481. constructor(
  9482. /** the trigger, with or without parameters, for the action */
  9483. triggerOptions: any, condition?: Condition);
  9484. /**
  9485. * Internal only
  9486. * @hidden
  9487. */
  9488. _prepare(): void;
  9489. /**
  9490. * Gets the trigger parameters
  9491. * @returns the trigger parameters
  9492. */
  9493. getTriggerParameter(): any;
  9494. /**
  9495. * Internal only - executes current action event
  9496. * @hidden
  9497. */
  9498. _executeCurrent(evt?: ActionEvent): void;
  9499. /**
  9500. * Execute placeholder for child classes
  9501. * @param evt optional action event
  9502. */
  9503. execute(evt?: ActionEvent): void;
  9504. /**
  9505. * Skips to next active action
  9506. */
  9507. skipToNextActiveAction(): void;
  9508. /**
  9509. * Adds action to chain of actions, may be a DoNothingAction
  9510. * @param action defines the next action to execute
  9511. * @returns The action passed in
  9512. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9513. */
  9514. then(action: Action): Action;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. _getProperty(propertyPath: string): string;
  9520. /**
  9521. * Internal only
  9522. * @hidden
  9523. */
  9524. _getEffectiveTarget(target: any, propertyPath: string): any;
  9525. /**
  9526. * Serialize placeholder for child classes
  9527. * @param parent of child
  9528. * @returns the serialized object
  9529. */
  9530. serialize(parent: any): any;
  9531. /**
  9532. * Internal only called by serialize
  9533. * @hidden
  9534. */
  9535. protected _serialize(serializedAction: any, parent?: any): any;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. static _SerializeValueAsString: (value: any) => string;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. static _GetTargetProperty: (target: Scene | Node) => {
  9546. name: string;
  9547. targetType: string;
  9548. value: string;
  9549. };
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. /**
  9554. * A Condition applied to an Action
  9555. */
  9556. export class Condition {
  9557. /**
  9558. * Internal only - manager for action
  9559. * @hidden
  9560. */
  9561. _actionManager: ActionManager;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _evaluationId: number;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _currentResult: boolean;
  9572. /**
  9573. * Creates a new Condition
  9574. * @param actionManager the manager of the action the condition is applied to
  9575. */
  9576. constructor(actionManager: ActionManager);
  9577. /**
  9578. * Check if the current condition is valid
  9579. * @returns a boolean
  9580. */
  9581. isValid(): boolean;
  9582. /**
  9583. * Internal only
  9584. * @hidden
  9585. */
  9586. _getProperty(propertyPath: string): string;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. _getEffectiveTarget(target: any, propertyPath: string): any;
  9592. /**
  9593. * Serialize placeholder for child classes
  9594. * @returns the serialized object
  9595. */
  9596. serialize(): any;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. protected _serialize(serializedCondition: any): any;
  9602. }
  9603. /**
  9604. * Defines specific conditional operators as extensions of Condition
  9605. */
  9606. export class ValueCondition extends Condition {
  9607. /** path to specify the property of the target the conditional operator uses */
  9608. propertyPath: string;
  9609. /** the value compared by the conditional operator against the current value of the property */
  9610. value: any;
  9611. /** the conditional operator, default ValueCondition.IsEqual */
  9612. operator: number;
  9613. /**
  9614. * Internal only
  9615. * @hidden
  9616. */
  9617. private static _IsEqual;
  9618. /**
  9619. * Internal only
  9620. * @hidden
  9621. */
  9622. private static _IsDifferent;
  9623. /**
  9624. * Internal only
  9625. * @hidden
  9626. */
  9627. private static _IsGreater;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private static _IsLesser;
  9633. /**
  9634. * returns the number for IsEqual
  9635. */
  9636. static get IsEqual(): number;
  9637. /**
  9638. * Returns the number for IsDifferent
  9639. */
  9640. static get IsDifferent(): number;
  9641. /**
  9642. * Returns the number for IsGreater
  9643. */
  9644. static get IsGreater(): number;
  9645. /**
  9646. * Returns the number for IsLesser
  9647. */
  9648. static get IsLesser(): number;
  9649. /**
  9650. * Internal only The action manager for the condition
  9651. * @hidden
  9652. */
  9653. _actionManager: ActionManager;
  9654. /**
  9655. * Internal only
  9656. * @hidden
  9657. */
  9658. private _target;
  9659. /**
  9660. * Internal only
  9661. * @hidden
  9662. */
  9663. private _effectiveTarget;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. private _property;
  9669. /**
  9670. * Creates a new ValueCondition
  9671. * @param actionManager manager for the action the condition applies to
  9672. * @param target for the action
  9673. * @param propertyPath path to specify the property of the target the conditional operator uses
  9674. * @param value the value compared by the conditional operator against the current value of the property
  9675. * @param operator the conditional operator, default ValueCondition.IsEqual
  9676. */
  9677. constructor(actionManager: ActionManager, target: any,
  9678. /** path to specify the property of the target the conditional operator uses */
  9679. propertyPath: string,
  9680. /** the value compared by the conditional operator against the current value of the property */
  9681. value: any,
  9682. /** the conditional operator, default ValueCondition.IsEqual */
  9683. operator?: number);
  9684. /**
  9685. * Compares the given value with the property value for the specified conditional operator
  9686. * @returns the result of the comparison
  9687. */
  9688. isValid(): boolean;
  9689. /**
  9690. * Serialize the ValueCondition into a JSON compatible object
  9691. * @returns serialization object
  9692. */
  9693. serialize(): any;
  9694. /**
  9695. * Gets the name of the conditional operator for the ValueCondition
  9696. * @param operator the conditional operator
  9697. * @returns the name
  9698. */
  9699. static GetOperatorName(operator: number): string;
  9700. }
  9701. /**
  9702. * Defines a predicate condition as an extension of Condition
  9703. */
  9704. export class PredicateCondition extends Condition {
  9705. /** defines the predicate function used to validate the condition */
  9706. predicate: () => boolean;
  9707. /**
  9708. * Internal only - manager for action
  9709. * @hidden
  9710. */
  9711. _actionManager: ActionManager;
  9712. /**
  9713. * Creates a new PredicateCondition
  9714. * @param actionManager manager for the action the condition applies to
  9715. * @param predicate defines the predicate function used to validate the condition
  9716. */
  9717. constructor(actionManager: ActionManager,
  9718. /** defines the predicate function used to validate the condition */
  9719. predicate: () => boolean);
  9720. /**
  9721. * @returns the validity of the predicate condition
  9722. */
  9723. isValid(): boolean;
  9724. }
  9725. /**
  9726. * Defines a state condition as an extension of Condition
  9727. */
  9728. export class StateCondition extends Condition {
  9729. /** Value to compare with target state */
  9730. value: string;
  9731. /**
  9732. * Internal only - manager for action
  9733. * @hidden
  9734. */
  9735. _actionManager: ActionManager;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. private _target;
  9741. /**
  9742. * Creates a new StateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param target of the condition
  9745. * @param value to compare with target state
  9746. */
  9747. constructor(actionManager: ActionManager, target: any,
  9748. /** Value to compare with target state */
  9749. value: string);
  9750. /**
  9751. * Gets a boolean indicating if the current condition is met
  9752. * @returns the validity of the state
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Serialize the StateCondition into a JSON compatible object
  9757. * @returns serialization object
  9758. */
  9759. serialize(): any;
  9760. }
  9761. }
  9762. declare module BABYLON {
  9763. /**
  9764. * This defines an action responsible to toggle a boolean once triggered.
  9765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9766. */
  9767. export class SwitchBooleanAction extends Action {
  9768. /**
  9769. * The path to the boolean property in the target object
  9770. */
  9771. propertyPath: string;
  9772. private _target;
  9773. private _effectiveTarget;
  9774. private _property;
  9775. /**
  9776. * Instantiate the action
  9777. * @param triggerOptions defines the trigger options
  9778. * @param target defines the object containing the boolean
  9779. * @param propertyPath defines the path to the boolean property in the target object
  9780. * @param condition defines the trigger related conditions
  9781. */
  9782. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9783. /** @hidden */
  9784. _prepare(): void;
  9785. /**
  9786. * Execute the action toggle the boolean value.
  9787. */
  9788. execute(): void;
  9789. /**
  9790. * Serializes the actions and its related information.
  9791. * @param parent defines the object to serialize in
  9792. * @returns the serialized object
  9793. */
  9794. serialize(parent: any): any;
  9795. }
  9796. /**
  9797. * This defines an action responsible to set a the state field of the target
  9798. * to a desired value once triggered.
  9799. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9800. */
  9801. export class SetStateAction extends Action {
  9802. /**
  9803. * The value to store in the state field.
  9804. */
  9805. value: string;
  9806. private _target;
  9807. /**
  9808. * Instantiate the action
  9809. * @param triggerOptions defines the trigger options
  9810. * @param target defines the object containing the state property
  9811. * @param value defines the value to store in the state field
  9812. * @param condition defines the trigger related conditions
  9813. */
  9814. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9815. /**
  9816. * Execute the action and store the value on the target state property.
  9817. */
  9818. execute(): void;
  9819. /**
  9820. * Serializes the actions and its related information.
  9821. * @param parent defines the object to serialize in
  9822. * @returns the serialized object
  9823. */
  9824. serialize(parent: any): any;
  9825. }
  9826. /**
  9827. * This defines an action responsible to set a property of the target
  9828. * to a desired value once triggered.
  9829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9830. */
  9831. export class SetValueAction extends Action {
  9832. /**
  9833. * The path of the property to set in the target.
  9834. */
  9835. propertyPath: string;
  9836. /**
  9837. * The value to set in the property
  9838. */
  9839. value: any;
  9840. private _target;
  9841. private _effectiveTarget;
  9842. private _property;
  9843. /**
  9844. * Instantiate the action
  9845. * @param triggerOptions defines the trigger options
  9846. * @param target defines the object containing the property
  9847. * @param propertyPath defines the path of the property to set in the target
  9848. * @param value defines the value to set in the property
  9849. * @param condition defines the trigger related conditions
  9850. */
  9851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9852. /** @hidden */
  9853. _prepare(): void;
  9854. /**
  9855. * Execute the action and set the targetted property to the desired value.
  9856. */
  9857. execute(): void;
  9858. /**
  9859. * Serializes the actions and its related information.
  9860. * @param parent defines the object to serialize in
  9861. * @returns the serialized object
  9862. */
  9863. serialize(parent: any): any;
  9864. }
  9865. /**
  9866. * This defines an action responsible to increment the target value
  9867. * to a desired value once triggered.
  9868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9869. */
  9870. export class IncrementValueAction extends Action {
  9871. /**
  9872. * The path of the property to increment in the target.
  9873. */
  9874. propertyPath: string;
  9875. /**
  9876. * The value we should increment the property by.
  9877. */
  9878. value: any;
  9879. private _target;
  9880. private _effectiveTarget;
  9881. private _property;
  9882. /**
  9883. * Instantiate the action
  9884. * @param triggerOptions defines the trigger options
  9885. * @param target defines the object containing the property
  9886. * @param propertyPath defines the path of the property to increment in the target
  9887. * @param value defines the value value we should increment the property by
  9888. * @param condition defines the trigger related conditions
  9889. */
  9890. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9891. /** @hidden */
  9892. _prepare(): void;
  9893. /**
  9894. * Execute the action and increment the target of the value amount.
  9895. */
  9896. execute(): void;
  9897. /**
  9898. * Serializes the actions and its related information.
  9899. * @param parent defines the object to serialize in
  9900. * @returns the serialized object
  9901. */
  9902. serialize(parent: any): any;
  9903. }
  9904. /**
  9905. * This defines an action responsible to start an animation once triggered.
  9906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class PlayAnimationAction extends Action {
  9909. /**
  9910. * Where the animation should start (animation frame)
  9911. */
  9912. from: number;
  9913. /**
  9914. * Where the animation should stop (animation frame)
  9915. */
  9916. to: number;
  9917. /**
  9918. * Define if the animation should loop or stop after the first play.
  9919. */
  9920. loop?: boolean;
  9921. private _target;
  9922. /**
  9923. * Instantiate the action
  9924. * @param triggerOptions defines the trigger options
  9925. * @param target defines the target animation or animation name
  9926. * @param from defines from where the animation should start (animation frame)
  9927. * @param end defines where the animation should stop (animation frame)
  9928. * @param loop defines if the animation should loop or stop after the first play
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and play 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 to stop an animation once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class StopAnimationAction extends Action {
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param condition defines the trigger related conditions
  9956. */
  9957. constructor(triggerOptions: any, target: any, condition?: Condition);
  9958. /** @hidden */
  9959. _prepare(): void;
  9960. /**
  9961. * Execute the action and stop the animation.
  9962. */
  9963. execute(): void;
  9964. /**
  9965. * Serializes the actions and its related information.
  9966. * @param parent defines the object to serialize in
  9967. * @returns the serialized object
  9968. */
  9969. serialize(parent: any): any;
  9970. }
  9971. /**
  9972. * This defines an action responsible that does nothing once triggered.
  9973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9974. */
  9975. export class DoNothingAction extends Action {
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions?: any, condition?: Condition);
  9982. /**
  9983. * Execute the action and do nothing.
  9984. */
  9985. execute(): void;
  9986. /**
  9987. * Serializes the actions and its related information.
  9988. * @param parent defines the object to serialize in
  9989. * @returns the serialized object
  9990. */
  9991. serialize(parent: any): any;
  9992. }
  9993. /**
  9994. * This defines an action responsible to trigger several actions once triggered.
  9995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9996. */
  9997. export class CombineAction extends Action {
  9998. /**
  9999. * The list of aggregated animations to run.
  10000. */
  10001. children: Action[];
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param children defines the list of aggregated animations to run
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and executes all the aggregated actions.
  10013. */
  10014. execute(evt: ActionEvent): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to run code (external event) once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class ExecuteCodeAction extends Action {
  10027. /**
  10028. * The callback function to run.
  10029. */
  10030. func: (evt: ActionEvent) => void;
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param func defines the callback function to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10038. /**
  10039. * Execute the action and run the attached code.
  10040. */
  10041. execute(evt: ActionEvent): void;
  10042. }
  10043. /**
  10044. * This defines an action responsible to set the parent property of the target once triggered.
  10045. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10046. */
  10047. export class SetParentAction extends Action {
  10048. private _parent;
  10049. private _target;
  10050. /**
  10051. * Instantiate the action
  10052. * @param triggerOptions defines the trigger options
  10053. * @param target defines the target containing the parent property
  10054. * @param parent defines from where the animation should start (animation frame)
  10055. * @param condition defines the trigger related conditions
  10056. */
  10057. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10058. /** @hidden */
  10059. _prepare(): void;
  10060. /**
  10061. * Execute the action and set the parent property.
  10062. */
  10063. execute(): void;
  10064. /**
  10065. * Serializes the actions and its related information.
  10066. * @param parent defines the object to serialize in
  10067. * @returns the serialized object
  10068. */
  10069. serialize(parent: any): any;
  10070. }
  10071. }
  10072. declare module BABYLON {
  10073. /**
  10074. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10075. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10076. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10077. */
  10078. export class ActionManager extends AbstractActionManager {
  10079. /**
  10080. * Nothing
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10082. */
  10083. static readonly NothingTrigger: number;
  10084. /**
  10085. * On pick
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10087. */
  10088. static readonly OnPickTrigger: number;
  10089. /**
  10090. * On left pick
  10091. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10092. */
  10093. static readonly OnLeftPickTrigger: number;
  10094. /**
  10095. * On right pick
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnRightPickTrigger: number;
  10099. /**
  10100. * On center pick
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnCenterPickTrigger: number;
  10104. /**
  10105. * On pick down
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPickDownTrigger: number;
  10109. /**
  10110. * On double pick
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnDoublePickTrigger: number;
  10114. /**
  10115. * On pick up
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnPickUpTrigger: number;
  10119. /**
  10120. * On pick out.
  10121. * This trigger will only be raised if you also declared a OnPickDown
  10122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10123. */
  10124. static readonly OnPickOutTrigger: number;
  10125. /**
  10126. * On long press
  10127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10128. */
  10129. static readonly OnLongPressTrigger: number;
  10130. /**
  10131. * On pointer over
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10133. */
  10134. static readonly OnPointerOverTrigger: number;
  10135. /**
  10136. * On pointer out
  10137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly OnPointerOutTrigger: number;
  10140. /**
  10141. * On every frame
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnEveryFrameTrigger: number;
  10145. /**
  10146. * On intersection enter
  10147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnIntersectionEnterTrigger: number;
  10150. /**
  10151. * On intersection exit
  10152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnIntersectionExitTrigger: number;
  10155. /**
  10156. * On key down
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnKeyDownTrigger: number;
  10160. /**
  10161. * On key up
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnKeyUpTrigger: number;
  10165. private _scene;
  10166. /**
  10167. * Creates a new action manager
  10168. * @param scene defines the hosting scene
  10169. */
  10170. constructor(scene: Scene);
  10171. /**
  10172. * Releases all associated resources
  10173. */
  10174. dispose(): void;
  10175. /**
  10176. * Gets hosting scene
  10177. * @returns the hosting scene
  10178. */
  10179. getScene(): Scene;
  10180. /**
  10181. * Does this action manager handles actions of any of the given triggers
  10182. * @param triggers defines the triggers to be tested
  10183. * @return a boolean indicating whether one (or more) of the triggers is handled
  10184. */
  10185. hasSpecificTriggers(triggers: number[]): boolean;
  10186. /**
  10187. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10188. * speed.
  10189. * @param triggerA defines the trigger to be tested
  10190. * @param triggerB defines the trigger to be tested
  10191. * @return a boolean indicating whether one (or more) of the triggers is handled
  10192. */
  10193. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10194. /**
  10195. * Does this action manager handles actions of a given trigger
  10196. * @param trigger defines the trigger to be tested
  10197. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10198. * @return whether the trigger is handled
  10199. */
  10200. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10201. /**
  10202. * Does this action manager has pointer triggers
  10203. */
  10204. get hasPointerTriggers(): boolean;
  10205. /**
  10206. * Does this action manager has pick triggers
  10207. */
  10208. get hasPickTriggers(): boolean;
  10209. /**
  10210. * Registers an action to this action manager
  10211. * @param action defines the action to be registered
  10212. * @return the action amended (prepared) after registration
  10213. */
  10214. registerAction(action: IAction): Nullable<IAction>;
  10215. /**
  10216. * Unregisters an action to this action manager
  10217. * @param action defines the action to be unregistered
  10218. * @return a boolean indicating whether the action has been unregistered
  10219. */
  10220. unregisterAction(action: IAction): Boolean;
  10221. /**
  10222. * Process a specific trigger
  10223. * @param trigger defines the trigger to process
  10224. * @param evt defines the event details to be processed
  10225. */
  10226. processTrigger(trigger: number, evt?: IActionEvent): void;
  10227. /** @hidden */
  10228. _getEffectiveTarget(target: any, propertyPath: string): any;
  10229. /** @hidden */
  10230. _getProperty(propertyPath: string): string;
  10231. /**
  10232. * Serialize this manager to a JSON object
  10233. * @param name defines the property name to store this manager
  10234. * @returns a JSON representation of this manager
  10235. */
  10236. serialize(name: string): any;
  10237. /**
  10238. * Creates a new ActionManager from a JSON data
  10239. * @param parsedActions defines the JSON data to read from
  10240. * @param object defines the hosting mesh
  10241. * @param scene defines the hosting scene
  10242. */
  10243. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10244. /**
  10245. * Get a trigger name by index
  10246. * @param trigger defines the trigger index
  10247. * @returns a trigger name
  10248. */
  10249. static GetTriggerName(trigger: number): string;
  10250. }
  10251. }
  10252. declare module BABYLON {
  10253. /**
  10254. * Class representing a ray with position and direction
  10255. */
  10256. export class Ray {
  10257. /** origin point */
  10258. origin: Vector3;
  10259. /** direction */
  10260. direction: Vector3;
  10261. /** length of the ray */
  10262. length: number;
  10263. private static readonly _TmpVector3;
  10264. private _tmpRay;
  10265. /**
  10266. * Creates a new ray
  10267. * @param origin origin point
  10268. * @param direction direction
  10269. * @param length length of the ray
  10270. */
  10271. constructor(
  10272. /** origin point */
  10273. origin: Vector3,
  10274. /** direction */
  10275. direction: Vector3,
  10276. /** length of the ray */
  10277. length?: number);
  10278. /**
  10279. * Checks if the ray intersects a box
  10280. * This does not account for the ray lenght by design to improve perfs.
  10281. * @param minimum bound of the box
  10282. * @param maximum bound of the box
  10283. * @param intersectionTreshold extra extend to be added to the box in all direction
  10284. * @returns if the box was hit
  10285. */
  10286. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10287. /**
  10288. * Checks if the ray intersects a box
  10289. * This does not account for the ray lenght by design to improve perfs.
  10290. * @param box the bounding box to check
  10291. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10292. * @returns if the box was hit
  10293. */
  10294. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10295. /**
  10296. * If the ray hits a sphere
  10297. * @param sphere the bounding sphere to check
  10298. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10299. * @returns true if it hits the sphere
  10300. */
  10301. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10302. /**
  10303. * If the ray hits a triange
  10304. * @param vertex0 triangle vertex
  10305. * @param vertex1 triangle vertex
  10306. * @param vertex2 triangle vertex
  10307. * @returns intersection information if hit
  10308. */
  10309. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10310. /**
  10311. * Checks if ray intersects a plane
  10312. * @param plane the plane to check
  10313. * @returns the distance away it was hit
  10314. */
  10315. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10316. /**
  10317. * Calculate the intercept of a ray on a given axis
  10318. * @param axis to check 'x' | 'y' | 'z'
  10319. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10320. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10321. */
  10322. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10323. /**
  10324. * Checks if ray intersects a mesh
  10325. * @param mesh the mesh to check
  10326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10327. * @returns picking info of the intersecton
  10328. */
  10329. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10330. /**
  10331. * Checks if ray intersects a mesh
  10332. * @param meshes the meshes to check
  10333. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10334. * @param results array to store result in
  10335. * @returns Array of picking infos
  10336. */
  10337. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10338. private _comparePickingInfo;
  10339. private static smallnum;
  10340. private static rayl;
  10341. /**
  10342. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10343. * @param sega the first point of the segment to test the intersection against
  10344. * @param segb the second point of the segment to test the intersection against
  10345. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10346. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10347. */
  10348. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10349. /**
  10350. * Update the ray from viewport position
  10351. * @param x position
  10352. * @param y y position
  10353. * @param viewportWidth viewport width
  10354. * @param viewportHeight viewport height
  10355. * @param world world matrix
  10356. * @param view view matrix
  10357. * @param projection projection matrix
  10358. * @returns this ray updated
  10359. */
  10360. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10361. /**
  10362. * Creates a ray with origin and direction of 0,0,0
  10363. * @returns the new ray
  10364. */
  10365. static Zero(): Ray;
  10366. /**
  10367. * Creates a new ray from screen space and viewport
  10368. * @param x position
  10369. * @param y y position
  10370. * @param viewportWidth viewport width
  10371. * @param viewportHeight viewport height
  10372. * @param world world matrix
  10373. * @param view view matrix
  10374. * @param projection projection matrix
  10375. * @returns new ray
  10376. */
  10377. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10378. /**
  10379. * 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
  10380. * transformed to the given world matrix.
  10381. * @param origin The origin point
  10382. * @param end The end point
  10383. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10384. * @returns the new ray
  10385. */
  10386. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10387. /**
  10388. * Transforms a ray by a matrix
  10389. * @param ray ray to transform
  10390. * @param matrix matrix to apply
  10391. * @returns the resulting new ray
  10392. */
  10393. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10394. /**
  10395. * Transforms a ray by a matrix
  10396. * @param ray ray to transform
  10397. * @param matrix matrix to apply
  10398. * @param result ray to store result in
  10399. */
  10400. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10401. /**
  10402. * Unproject a ray from screen space to object space
  10403. * @param sourceX defines the screen space x coordinate to use
  10404. * @param sourceY defines the screen space y coordinate to use
  10405. * @param viewportWidth defines the current width of the viewport
  10406. * @param viewportHeight defines the current height of the viewport
  10407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10408. * @param view defines the view matrix to use
  10409. * @param projection defines the projection matrix to use
  10410. */
  10411. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10412. }
  10413. /**
  10414. * Type used to define predicate used to select faces when a mesh intersection is detected
  10415. */
  10416. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10417. interface Scene {
  10418. /** @hidden */
  10419. _tempPickingRay: Nullable<Ray>;
  10420. /** @hidden */
  10421. _cachedRayForTransform: Ray;
  10422. /** @hidden */
  10423. _pickWithRayInverseMatrix: Matrix;
  10424. /** @hidden */
  10425. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10426. /** @hidden */
  10427. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10428. /** @hidden */
  10429. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * Groups all the scene component constants in one place to ease maintenance.
  10435. * @hidden
  10436. */
  10437. export class SceneComponentConstants {
  10438. static readonly NAME_EFFECTLAYER: string;
  10439. static readonly NAME_LAYER: string;
  10440. static readonly NAME_LENSFLARESYSTEM: string;
  10441. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10442. static readonly NAME_PARTICLESYSTEM: string;
  10443. static readonly NAME_GAMEPAD: string;
  10444. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10445. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10446. static readonly NAME_PREPASSRENDERER: string;
  10447. static readonly NAME_DEPTHRENDERER: string;
  10448. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10449. static readonly NAME_SPRITE: string;
  10450. static readonly NAME_SUBSURFACE: string;
  10451. static readonly NAME_OUTLINERENDERER: string;
  10452. static readonly NAME_PROCEDURALTEXTURE: string;
  10453. static readonly NAME_SHADOWGENERATOR: string;
  10454. static readonly NAME_OCTREE: string;
  10455. static readonly NAME_PHYSICSENGINE: string;
  10456. static readonly NAME_AUDIO: string;
  10457. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10458. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10459. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10460. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10461. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10462. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10463. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10464. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10465. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10466. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10467. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10468. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10469. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10470. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10471. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10472. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10473. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10474. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10475. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10477. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10478. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10479. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10480. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10481. static readonly STEP_AFTERRENDER_AUDIO: number;
  10482. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10483. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10484. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10485. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10486. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10487. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10488. static readonly STEP_POINTERMOVE_SPRITE: number;
  10489. static readonly STEP_POINTERDOWN_SPRITE: number;
  10490. static readonly STEP_POINTERUP_SPRITE: number;
  10491. }
  10492. /**
  10493. * This represents a scene component.
  10494. *
  10495. * This is used to decouple the dependency the scene is having on the different workloads like
  10496. * layers, post processes...
  10497. */
  10498. export interface ISceneComponent {
  10499. /**
  10500. * The name of the component. Each component must have a unique name.
  10501. */
  10502. name: string;
  10503. /**
  10504. * The scene the component belongs to.
  10505. */
  10506. scene: Scene;
  10507. /**
  10508. * Register the component to one instance of a scene.
  10509. */
  10510. register(): void;
  10511. /**
  10512. * Rebuilds the elements related to this component in case of
  10513. * context lost for instance.
  10514. */
  10515. rebuild(): void;
  10516. /**
  10517. * Disposes the component and the associated ressources.
  10518. */
  10519. dispose(): void;
  10520. }
  10521. /**
  10522. * This represents a SERIALIZABLE scene component.
  10523. *
  10524. * This extends Scene Component to add Serialization methods on top.
  10525. */
  10526. export interface ISceneSerializableComponent extends ISceneComponent {
  10527. /**
  10528. * Adds all the elements from the container to the scene
  10529. * @param container the container holding the elements
  10530. */
  10531. addFromContainer(container: AbstractScene): void;
  10532. /**
  10533. * Removes all the elements in the container from the scene
  10534. * @param container contains the elements to remove
  10535. * @param dispose if the removed element should be disposed (default: false)
  10536. */
  10537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10538. /**
  10539. * Serializes the component data to the specified json object
  10540. * @param serializationObject The object to serialize to
  10541. */
  10542. serialize(serializationObject: any): void;
  10543. }
  10544. /**
  10545. * Strong typing of a Mesh related stage step action
  10546. */
  10547. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10548. /**
  10549. * Strong typing of a Evaluate Sub Mesh related stage step action
  10550. */
  10551. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10552. /**
  10553. * Strong typing of a pre active Mesh related stage step action
  10554. */
  10555. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10556. /**
  10557. * Strong typing of a Camera related stage step action
  10558. */
  10559. export type CameraStageAction = (camera: Camera) => void;
  10560. /**
  10561. * Strong typing of a Camera Frame buffer related stage step action
  10562. */
  10563. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10564. /**
  10565. * Strong typing of a Render Target related stage step action
  10566. */
  10567. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10568. /**
  10569. * Strong typing of a RenderingGroup related stage step action
  10570. */
  10571. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10572. /**
  10573. * Strong typing of a Mesh Render related stage step action
  10574. */
  10575. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10576. /**
  10577. * Strong typing of a simple stage step action
  10578. */
  10579. export type SimpleStageAction = () => void;
  10580. /**
  10581. * Strong typing of a render target action.
  10582. */
  10583. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10584. /**
  10585. * Strong typing of a pointer move action.
  10586. */
  10587. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10588. /**
  10589. * Strong typing of a pointer up/down action.
  10590. */
  10591. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10592. /**
  10593. * Representation of a stage in the scene (Basically a list of ordered steps)
  10594. * @hidden
  10595. */
  10596. export class Stage<T extends Function> extends Array<{
  10597. index: number;
  10598. component: ISceneComponent;
  10599. action: T;
  10600. }> {
  10601. /**
  10602. * Hide ctor from the rest of the world.
  10603. * @param items The items to add.
  10604. */
  10605. private constructor();
  10606. /**
  10607. * Creates a new Stage.
  10608. * @returns A new instance of a Stage
  10609. */
  10610. static Create<T extends Function>(): Stage<T>;
  10611. /**
  10612. * Registers a step in an ordered way in the targeted stage.
  10613. * @param index Defines the position to register the step in
  10614. * @param component Defines the component attached to the step
  10615. * @param action Defines the action to launch during the step
  10616. */
  10617. registerStep(index: number, component: ISceneComponent, action: T): void;
  10618. /**
  10619. * Clears all the steps from the stage.
  10620. */
  10621. clear(): void;
  10622. }
  10623. }
  10624. declare module BABYLON {
  10625. interface Scene {
  10626. /** @hidden */
  10627. _pointerOverSprite: Nullable<Sprite>;
  10628. /** @hidden */
  10629. _pickedDownSprite: Nullable<Sprite>;
  10630. /** @hidden */
  10631. _tempSpritePickingRay: Nullable<Ray>;
  10632. /**
  10633. * All of the sprite managers added to this scene
  10634. * @see https://doc.babylonjs.com/babylon101/sprites
  10635. */
  10636. spriteManagers: Array<ISpriteManager>;
  10637. /**
  10638. * An event triggered when sprites rendering is about to start
  10639. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10640. */
  10641. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10642. /**
  10643. * An event triggered when sprites rendering is done
  10644. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10645. */
  10646. onAfterSpritesRenderingObservable: Observable<Scene>;
  10647. /** @hidden */
  10648. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10649. /** Launch a ray to try to pick a sprite in the scene
  10650. * @param x position on screen
  10651. * @param y position on screen
  10652. * @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
  10653. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10654. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10655. * @returns a PickingInfo
  10656. */
  10657. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10658. /** Use the given ray to pick a sprite in the scene
  10659. * @param ray The ray (in world space) to use to pick meshes
  10660. * @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
  10661. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10662. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10663. * @returns a PickingInfo
  10664. */
  10665. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10666. /** @hidden */
  10667. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10668. /** Launch a ray to try to pick sprites in the scene
  10669. * @param x position on screen
  10670. * @param y position on screen
  10671. * @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
  10672. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10673. * @returns a PickingInfo array
  10674. */
  10675. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10676. /** Use the given ray to pick sprites in the scene
  10677. * @param ray The ray (in world space) to use to pick meshes
  10678. * @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
  10679. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10680. * @returns a PickingInfo array
  10681. */
  10682. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10683. /**
  10684. * Force the sprite under the pointer
  10685. * @param sprite defines the sprite to use
  10686. */
  10687. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10688. /**
  10689. * Gets the sprite under the pointer
  10690. * @returns a Sprite or null if no sprite is under the pointer
  10691. */
  10692. getPointerOverSprite(): Nullable<Sprite>;
  10693. }
  10694. /**
  10695. * Defines the sprite scene component responsible to manage sprites
  10696. * in a given scene.
  10697. */
  10698. export class SpriteSceneComponent implements ISceneComponent {
  10699. /**
  10700. * The component name helpfull to identify the component in the list of scene components.
  10701. */
  10702. readonly name: string;
  10703. /**
  10704. * The scene the component belongs to.
  10705. */
  10706. scene: Scene;
  10707. /** @hidden */
  10708. private _spritePredicate;
  10709. /**
  10710. * Creates a new instance of the component for the given scene
  10711. * @param scene Defines the scene to register the component in
  10712. */
  10713. constructor(scene: Scene);
  10714. /**
  10715. * Registers the component in a given scene
  10716. */
  10717. register(): void;
  10718. /**
  10719. * Rebuilds the elements related to this component in case of
  10720. * context lost for instance.
  10721. */
  10722. rebuild(): void;
  10723. /**
  10724. * Disposes the component and the associated ressources.
  10725. */
  10726. dispose(): void;
  10727. private _pickSpriteButKeepRay;
  10728. private _pointerMove;
  10729. private _pointerDown;
  10730. private _pointerUp;
  10731. }
  10732. }
  10733. declare module BABYLON {
  10734. /**
  10735. * Class used to provide helper for timing
  10736. */
  10737. export class TimingTools {
  10738. /**
  10739. * Polyfill for setImmediate
  10740. * @param action defines the action to execute after the current execution block
  10741. */
  10742. static SetImmediate(action: () => void): void;
  10743. }
  10744. }
  10745. declare module BABYLON {
  10746. /**
  10747. * Class used to enable instatition of objects by class name
  10748. */
  10749. export class InstantiationTools {
  10750. /**
  10751. * Use this object to register external classes like custom textures or material
  10752. * to allow the laoders to instantiate them
  10753. */
  10754. static RegisteredExternalClasses: {
  10755. [key: string]: Object;
  10756. };
  10757. /**
  10758. * Tries to instantiate a new object from a given class name
  10759. * @param className defines the class name to instantiate
  10760. * @returns the new object or null if the system was not able to do the instantiation
  10761. */
  10762. static Instantiate(className: string): any;
  10763. }
  10764. }
  10765. declare module BABYLON {
  10766. /**
  10767. * Class used to host copy specific utilities
  10768. */
  10769. export class CopyTools {
  10770. /**
  10771. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10772. * @param texture defines the texture to read pixels from
  10773. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10774. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10775. * @returns The base64 encoded string or null
  10776. */
  10777. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10778. }
  10779. }
  10780. declare module BABYLON {
  10781. /**
  10782. * Define options used to create a depth texture
  10783. */
  10784. export class DepthTextureCreationOptions {
  10785. /** Specifies whether or not a stencil should be allocated in the texture */
  10786. generateStencil?: boolean;
  10787. /** Specifies whether or not bilinear filtering is enable on the texture */
  10788. bilinearFiltering?: boolean;
  10789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10790. comparisonFunction?: number;
  10791. /** Specifies if the created texture is a cube texture */
  10792. isCube?: boolean;
  10793. }
  10794. }
  10795. declare module BABYLON {
  10796. interface ThinEngine {
  10797. /**
  10798. * Creates a depth stencil cube texture.
  10799. * This is only available in WebGL 2.
  10800. * @param size The size of face edge in the cube texture.
  10801. * @param options The options defining the cube texture.
  10802. * @returns The cube texture
  10803. */
  10804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10805. /**
  10806. * Creates a cube texture
  10807. * @param rootUrl defines the url where the files to load is located
  10808. * @param scene defines the current scene
  10809. * @param files defines the list of files to load (1 per face)
  10810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10811. * @param onLoad defines an optional callback raised when the texture is loaded
  10812. * @param onError defines an optional callback raised if there is an issue to load the texture
  10813. * @param format defines the format of the data
  10814. * @param forcedExtension defines the extension to use to pick the right loader
  10815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10819. * @param loaderOptions options to be passed to the loader
  10820. * @returns the cube texture as an InternalTexture
  10821. */
  10822. 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>, loaderOptions: any): InternalTexture;
  10823. /**
  10824. * Creates a cube texture
  10825. * @param rootUrl defines the url where the files to load is located
  10826. * @param scene defines the current scene
  10827. * @param files defines the list of files to load (1 per face)
  10828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10829. * @param onLoad defines an optional callback raised when the texture is loaded
  10830. * @param onError defines an optional callback raised if there is an issue to load the texture
  10831. * @param format defines the format of the data
  10832. * @param forcedExtension defines the extension to use to pick the right loader
  10833. * @returns the cube texture as an InternalTexture
  10834. */
  10835. 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;
  10836. /**
  10837. * Creates a cube texture
  10838. * @param rootUrl defines the url where the files to load is located
  10839. * @param scene defines the current scene
  10840. * @param files defines the list of files to load (1 per face)
  10841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10842. * @param onLoad defines an optional callback raised when the texture is loaded
  10843. * @param onError defines an optional callback raised if there is an issue to load the texture
  10844. * @param format defines the format of the data
  10845. * @param forcedExtension defines the extension to use to pick the right loader
  10846. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10849. * @returns the cube texture as an InternalTexture
  10850. */
  10851. 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;
  10852. /** @hidden */
  10853. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10854. /** @hidden */
  10855. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10856. /** @hidden */
  10857. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10858. /** @hidden */
  10859. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10860. /**
  10861. * @hidden
  10862. */
  10863. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10864. }
  10865. }
  10866. declare module BABYLON {
  10867. /**
  10868. * Class for creating a cube texture
  10869. */
  10870. export class CubeTexture extends BaseTexture {
  10871. private _delayedOnLoad;
  10872. /**
  10873. * Observable triggered once the texture has been loaded.
  10874. */
  10875. onLoadObservable: Observable<CubeTexture>;
  10876. /**
  10877. * The url of the texture
  10878. */
  10879. url: string;
  10880. /**
  10881. * Gets or sets the center of the bounding box associated with the cube texture.
  10882. * It must define where the camera used to render the texture was set
  10883. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10884. */
  10885. boundingBoxPosition: Vector3;
  10886. private _boundingBoxSize;
  10887. /**
  10888. * Gets or sets the size of the bounding box associated with the cube texture
  10889. * When defined, the cubemap will switch to local mode
  10890. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10891. * @example https://www.babylonjs-playground.com/#RNASML
  10892. */
  10893. set boundingBoxSize(value: Vector3);
  10894. /**
  10895. * Returns the bounding box size
  10896. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10897. */
  10898. get boundingBoxSize(): Vector3;
  10899. protected _rotationY: number;
  10900. /**
  10901. * Sets texture matrix rotation angle around Y axis in radians.
  10902. */
  10903. set rotationY(value: number);
  10904. /**
  10905. * Gets texture matrix rotation angle around Y axis radians.
  10906. */
  10907. get rotationY(): number;
  10908. /**
  10909. * Are mip maps generated for this texture or not.
  10910. */
  10911. get noMipmap(): boolean;
  10912. private _noMipmap;
  10913. private _files;
  10914. protected _forcedExtension: Nullable<string>;
  10915. private _extensions;
  10916. private _textureMatrix;
  10917. private _format;
  10918. private _createPolynomials;
  10919. private _loaderOptions;
  10920. /**
  10921. * Creates a cube texture from an array of image urls
  10922. * @param files defines an array of image urls
  10923. * @param scene defines the hosting scene
  10924. * @param noMipmap specifies if mip maps are not used
  10925. * @returns a cube texture
  10926. */
  10927. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10928. /**
  10929. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10930. * @param url defines the url of the prefiltered texture
  10931. * @param scene defines the scene the texture is attached to
  10932. * @param forcedExtension defines the extension of the file if different from the url
  10933. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10934. * @return the prefiltered texture
  10935. */
  10936. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10937. /**
  10938. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10939. * as prefiltered data.
  10940. * @param rootUrl defines the url of the texture or the root name of the six images
  10941. * @param null defines the scene or engine the texture is attached to
  10942. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10943. * @param noMipmap defines if mipmaps should be created or not
  10944. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10945. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10946. * @param onError defines a callback triggered in case of error during load
  10947. * @param format defines the internal format to use for the texture once loaded
  10948. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10949. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10950. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10953. * @param loaderOptions options to be passed to the loader
  10954. * @return the cube texture
  10955. */
  10956. 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, loaderOptions?: any);
  10957. /**
  10958. * Get the current class name of the texture useful for serialization or dynamic coding.
  10959. * @returns "CubeTexture"
  10960. */
  10961. getClassName(): string;
  10962. /**
  10963. * Update the url (and optional buffer) of this texture if url was null during construction.
  10964. * @param url the url of the texture
  10965. * @param forcedExtension defines the extension to use
  10966. * @param onLoad callback called when the texture is loaded (defaults to null)
  10967. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10968. */
  10969. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10970. /**
  10971. * Delays loading of the cube texture
  10972. * @param forcedExtension defines the extension to use
  10973. */
  10974. delayLoad(forcedExtension?: string): void;
  10975. /**
  10976. * Returns the reflection texture matrix
  10977. * @returns the reflection texture matrix
  10978. */
  10979. getReflectionTextureMatrix(): Matrix;
  10980. /**
  10981. * Sets the reflection texture matrix
  10982. * @param value Reflection texture matrix
  10983. */
  10984. setReflectionTextureMatrix(value: Matrix): void;
  10985. /**
  10986. * Parses text to create a cube texture
  10987. * @param parsedTexture define the serialized text to read from
  10988. * @param scene defines the hosting scene
  10989. * @param rootUrl defines the root url of the cube texture
  10990. * @returns a cube texture
  10991. */
  10992. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  10993. /**
  10994. * Makes a clone, or deep copy, of the cube texture
  10995. * @returns a new cube texture
  10996. */
  10997. clone(): CubeTexture;
  10998. }
  10999. }
  11000. declare module BABYLON {
  11001. /**
  11002. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11003. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11004. * 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;
  11005. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11006. */
  11007. export class ColorCurves {
  11008. private _dirty;
  11009. private _tempColor;
  11010. private _globalCurve;
  11011. private _highlightsCurve;
  11012. private _midtonesCurve;
  11013. private _shadowsCurve;
  11014. private _positiveCurve;
  11015. private _negativeCurve;
  11016. private _globalHue;
  11017. private _globalDensity;
  11018. private _globalSaturation;
  11019. private _globalExposure;
  11020. /**
  11021. * Gets the global Hue value.
  11022. * 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).
  11023. */
  11024. get globalHue(): number;
  11025. /**
  11026. * Sets the global Hue value.
  11027. * 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).
  11028. */
  11029. set globalHue(value: number);
  11030. /**
  11031. * Gets the global Density value.
  11032. * 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.
  11033. * Values less than zero provide a filter of opposite hue.
  11034. */
  11035. get globalDensity(): number;
  11036. /**
  11037. * Sets the global Density value.
  11038. * 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.
  11039. * Values less than zero provide a filter of opposite hue.
  11040. */
  11041. set globalDensity(value: number);
  11042. /**
  11043. * Gets the global Saturation value.
  11044. * 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.
  11045. */
  11046. get globalSaturation(): number;
  11047. /**
  11048. * Sets the global Saturation value.
  11049. * 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.
  11050. */
  11051. set globalSaturation(value: number);
  11052. /**
  11053. * Gets the global Exposure value.
  11054. * 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.
  11055. */
  11056. get globalExposure(): number;
  11057. /**
  11058. * Sets the global Exposure value.
  11059. * 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.
  11060. */
  11061. set globalExposure(value: number);
  11062. private _highlightsHue;
  11063. private _highlightsDensity;
  11064. private _highlightsSaturation;
  11065. private _highlightsExposure;
  11066. /**
  11067. * Gets the highlights Hue value.
  11068. * 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).
  11069. */
  11070. get highlightsHue(): number;
  11071. /**
  11072. * Sets the highlights Hue value.
  11073. * 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).
  11074. */
  11075. set highlightsHue(value: number);
  11076. /**
  11077. * Gets the highlights Density value.
  11078. * 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.
  11079. * Values less than zero provide a filter of opposite hue.
  11080. */
  11081. get highlightsDensity(): number;
  11082. /**
  11083. * Sets the highlights Density value.
  11084. * 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.
  11085. * Values less than zero provide a filter of opposite hue.
  11086. */
  11087. set highlightsDensity(value: number);
  11088. /**
  11089. * Gets the highlights Saturation value.
  11090. * 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.
  11091. */
  11092. get highlightsSaturation(): number;
  11093. /**
  11094. * Sets the highlights Saturation value.
  11095. * 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.
  11096. */
  11097. set highlightsSaturation(value: number);
  11098. /**
  11099. * Gets the highlights Exposure value.
  11100. * 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.
  11101. */
  11102. get highlightsExposure(): number;
  11103. /**
  11104. * Sets the highlights Exposure value.
  11105. * 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.
  11106. */
  11107. set highlightsExposure(value: number);
  11108. private _midtonesHue;
  11109. private _midtonesDensity;
  11110. private _midtonesSaturation;
  11111. private _midtonesExposure;
  11112. /**
  11113. * Gets the midtones Hue value.
  11114. * 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).
  11115. */
  11116. get midtonesHue(): number;
  11117. /**
  11118. * Sets the midtones Hue value.
  11119. * 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).
  11120. */
  11121. set midtonesHue(value: number);
  11122. /**
  11123. * Gets the midtones Density value.
  11124. * 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.
  11125. * Values less than zero provide a filter of opposite hue.
  11126. */
  11127. get midtonesDensity(): number;
  11128. /**
  11129. * Sets the midtones Density value.
  11130. * 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.
  11131. * Values less than zero provide a filter of opposite hue.
  11132. */
  11133. set midtonesDensity(value: number);
  11134. /**
  11135. * Gets the midtones Saturation value.
  11136. * 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.
  11137. */
  11138. get midtonesSaturation(): number;
  11139. /**
  11140. * Sets the midtones Saturation value.
  11141. * 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.
  11142. */
  11143. set midtonesSaturation(value: number);
  11144. /**
  11145. * Gets the midtones Exposure value.
  11146. * 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.
  11147. */
  11148. get midtonesExposure(): number;
  11149. /**
  11150. * Sets the midtones Exposure value.
  11151. * 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.
  11152. */
  11153. set midtonesExposure(value: number);
  11154. private _shadowsHue;
  11155. private _shadowsDensity;
  11156. private _shadowsSaturation;
  11157. private _shadowsExposure;
  11158. /**
  11159. * Gets the shadows Hue value.
  11160. * 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).
  11161. */
  11162. get shadowsHue(): number;
  11163. /**
  11164. * Sets the shadows Hue value.
  11165. * 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).
  11166. */
  11167. set shadowsHue(value: number);
  11168. /**
  11169. * Gets the shadows Density value.
  11170. * 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.
  11171. * Values less than zero provide a filter of opposite hue.
  11172. */
  11173. get shadowsDensity(): number;
  11174. /**
  11175. * Sets the shadows Density value.
  11176. * 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.
  11177. * Values less than zero provide a filter of opposite hue.
  11178. */
  11179. set shadowsDensity(value: number);
  11180. /**
  11181. * Gets the shadows Saturation value.
  11182. * 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.
  11183. */
  11184. get shadowsSaturation(): number;
  11185. /**
  11186. * Sets the shadows Saturation value.
  11187. * 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.
  11188. */
  11189. set shadowsSaturation(value: number);
  11190. /**
  11191. * Gets the shadows Exposure value.
  11192. * 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.
  11193. */
  11194. get shadowsExposure(): number;
  11195. /**
  11196. * Sets the shadows Exposure value.
  11197. * 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.
  11198. */
  11199. set shadowsExposure(value: number);
  11200. /**
  11201. * Returns the class name
  11202. * @returns The class name
  11203. */
  11204. getClassName(): string;
  11205. /**
  11206. * Binds the color curves to the shader.
  11207. * @param colorCurves The color curve to bind
  11208. * @param effect The effect to bind to
  11209. * @param positiveUniform The positive uniform shader parameter
  11210. * @param neutralUniform The neutral uniform shader parameter
  11211. * @param negativeUniform The negative uniform shader parameter
  11212. */
  11213. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11214. /**
  11215. * Prepare the list of uniforms associated with the ColorCurves effects.
  11216. * @param uniformsList The list of uniforms used in the effect
  11217. */
  11218. static PrepareUniforms(uniformsList: string[]): void;
  11219. /**
  11220. * Returns color grading data based on a hue, density, saturation and exposure value.
  11221. * @param filterHue The hue of the color filter.
  11222. * @param filterDensity The density of the color filter.
  11223. * @param saturation The saturation.
  11224. * @param exposure The exposure.
  11225. * @param result The result data container.
  11226. */
  11227. private getColorGradingDataToRef;
  11228. /**
  11229. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11230. * @param value The input slider value in range [-100,100].
  11231. * @returns Adjusted value.
  11232. */
  11233. private static applyColorGradingSliderNonlinear;
  11234. /**
  11235. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11236. * @param hue The hue (H) input.
  11237. * @param saturation The saturation (S) input.
  11238. * @param brightness The brightness (B) input.
  11239. * @result An RGBA color represented as Vector4.
  11240. */
  11241. private static fromHSBToRef;
  11242. /**
  11243. * Returns a value clamped between min and max
  11244. * @param value The value to clamp
  11245. * @param min The minimum of value
  11246. * @param max The maximum of value
  11247. * @returns The clamped value.
  11248. */
  11249. private static clamp;
  11250. /**
  11251. * Clones the current color curve instance.
  11252. * @return The cloned curves
  11253. */
  11254. clone(): ColorCurves;
  11255. /**
  11256. * Serializes the current color curve instance to a json representation.
  11257. * @return a JSON representation
  11258. */
  11259. serialize(): any;
  11260. /**
  11261. * Parses the color curve from a json representation.
  11262. * @param source the JSON source to parse
  11263. * @return The parsed curves
  11264. */
  11265. static Parse(source: any): ColorCurves;
  11266. }
  11267. }
  11268. declare module BABYLON {
  11269. /**
  11270. * Interface to follow in your material defines to integrate easily the
  11271. * Image proccessing functions.
  11272. * @hidden
  11273. */
  11274. export interface IImageProcessingConfigurationDefines {
  11275. IMAGEPROCESSING: boolean;
  11276. VIGNETTE: boolean;
  11277. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11278. VIGNETTEBLENDMODEOPAQUE: boolean;
  11279. TONEMAPPING: boolean;
  11280. TONEMAPPING_ACES: boolean;
  11281. CONTRAST: boolean;
  11282. EXPOSURE: boolean;
  11283. COLORCURVES: boolean;
  11284. COLORGRADING: boolean;
  11285. COLORGRADING3D: boolean;
  11286. SAMPLER3DGREENDEPTH: boolean;
  11287. SAMPLER3DBGRMAP: boolean;
  11288. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11289. }
  11290. /**
  11291. * @hidden
  11292. */
  11293. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11294. IMAGEPROCESSING: boolean;
  11295. VIGNETTE: boolean;
  11296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11297. VIGNETTEBLENDMODEOPAQUE: boolean;
  11298. TONEMAPPING: boolean;
  11299. TONEMAPPING_ACES: boolean;
  11300. CONTRAST: boolean;
  11301. COLORCURVES: boolean;
  11302. COLORGRADING: boolean;
  11303. COLORGRADING3D: boolean;
  11304. SAMPLER3DGREENDEPTH: boolean;
  11305. SAMPLER3DBGRMAP: boolean;
  11306. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11307. EXPOSURE: boolean;
  11308. constructor();
  11309. }
  11310. /**
  11311. * This groups together the common properties used for image processing either in direct forward pass
  11312. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11313. * or not.
  11314. */
  11315. export class ImageProcessingConfiguration {
  11316. /**
  11317. * Default tone mapping applied in BabylonJS.
  11318. */
  11319. static readonly TONEMAPPING_STANDARD: number;
  11320. /**
  11321. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11322. * to other engines rendering to increase portability.
  11323. */
  11324. static readonly TONEMAPPING_ACES: number;
  11325. /**
  11326. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11327. */
  11328. colorCurves: Nullable<ColorCurves>;
  11329. private _colorCurvesEnabled;
  11330. /**
  11331. * Gets wether the color curves effect is enabled.
  11332. */
  11333. get colorCurvesEnabled(): boolean;
  11334. /**
  11335. * Sets wether the color curves effect is enabled.
  11336. */
  11337. set colorCurvesEnabled(value: boolean);
  11338. private _colorGradingTexture;
  11339. /**
  11340. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11341. */
  11342. get colorGradingTexture(): Nullable<BaseTexture>;
  11343. /**
  11344. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11345. */
  11346. set colorGradingTexture(value: Nullable<BaseTexture>);
  11347. private _colorGradingEnabled;
  11348. /**
  11349. * Gets wether the color grading effect is enabled.
  11350. */
  11351. get colorGradingEnabled(): boolean;
  11352. /**
  11353. * Sets wether the color grading effect is enabled.
  11354. */
  11355. set colorGradingEnabled(value: boolean);
  11356. private _colorGradingWithGreenDepth;
  11357. /**
  11358. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11359. */
  11360. get colorGradingWithGreenDepth(): boolean;
  11361. /**
  11362. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11363. */
  11364. set colorGradingWithGreenDepth(value: boolean);
  11365. private _colorGradingBGR;
  11366. /**
  11367. * Gets wether the color grading texture contains BGR values.
  11368. */
  11369. get colorGradingBGR(): boolean;
  11370. /**
  11371. * Sets wether the color grading texture contains BGR values.
  11372. */
  11373. set colorGradingBGR(value: boolean);
  11374. /** @hidden */
  11375. _exposure: number;
  11376. /**
  11377. * Gets the Exposure used in the effect.
  11378. */
  11379. get exposure(): number;
  11380. /**
  11381. * Sets the Exposure used in the effect.
  11382. */
  11383. set exposure(value: number);
  11384. private _toneMappingEnabled;
  11385. /**
  11386. * Gets wether the tone mapping effect is enabled.
  11387. */
  11388. get toneMappingEnabled(): boolean;
  11389. /**
  11390. * Sets wether the tone mapping effect is enabled.
  11391. */
  11392. set toneMappingEnabled(value: boolean);
  11393. private _toneMappingType;
  11394. /**
  11395. * Gets the type of tone mapping effect.
  11396. */
  11397. get toneMappingType(): number;
  11398. /**
  11399. * Sets the type of tone mapping effect used in BabylonJS.
  11400. */
  11401. set toneMappingType(value: number);
  11402. protected _contrast: number;
  11403. /**
  11404. * Gets the contrast used in the effect.
  11405. */
  11406. get contrast(): number;
  11407. /**
  11408. * Sets the contrast used in the effect.
  11409. */
  11410. set contrast(value: number);
  11411. /**
  11412. * Vignette stretch size.
  11413. */
  11414. vignetteStretch: number;
  11415. /**
  11416. * Vignette centre X Offset.
  11417. */
  11418. vignetteCentreX: number;
  11419. /**
  11420. * Vignette centre Y Offset.
  11421. */
  11422. vignetteCentreY: number;
  11423. /**
  11424. * Vignette weight or intensity of the vignette effect.
  11425. */
  11426. vignetteWeight: number;
  11427. /**
  11428. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11429. * if vignetteEnabled is set to true.
  11430. */
  11431. vignetteColor: Color4;
  11432. /**
  11433. * Camera field of view used by the Vignette effect.
  11434. */
  11435. vignetteCameraFov: number;
  11436. private _vignetteBlendMode;
  11437. /**
  11438. * Gets the vignette blend mode allowing different kind of effect.
  11439. */
  11440. get vignetteBlendMode(): number;
  11441. /**
  11442. * Sets the vignette blend mode allowing different kind of effect.
  11443. */
  11444. set vignetteBlendMode(value: number);
  11445. private _vignetteEnabled;
  11446. /**
  11447. * Gets wether the vignette effect is enabled.
  11448. */
  11449. get vignetteEnabled(): boolean;
  11450. /**
  11451. * Sets wether the vignette effect is enabled.
  11452. */
  11453. set vignetteEnabled(value: boolean);
  11454. private _applyByPostProcess;
  11455. /**
  11456. * Gets wether the image processing is applied through a post process or not.
  11457. */
  11458. get applyByPostProcess(): boolean;
  11459. /**
  11460. * Sets wether the image processing is applied through a post process or not.
  11461. */
  11462. set applyByPostProcess(value: boolean);
  11463. private _isEnabled;
  11464. /**
  11465. * Gets wether the image processing is enabled or not.
  11466. */
  11467. get isEnabled(): boolean;
  11468. /**
  11469. * Sets wether the image processing is enabled or not.
  11470. */
  11471. set isEnabled(value: boolean);
  11472. /**
  11473. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11474. */
  11475. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11476. /**
  11477. * Method called each time the image processing information changes requires to recompile the effect.
  11478. */
  11479. protected _updateParameters(): void;
  11480. /**
  11481. * Gets the current class name.
  11482. * @return "ImageProcessingConfiguration"
  11483. */
  11484. getClassName(): string;
  11485. /**
  11486. * Prepare the list of uniforms associated with the Image Processing effects.
  11487. * @param uniforms The list of uniforms used in the effect
  11488. * @param defines the list of defines currently in use
  11489. */
  11490. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11491. /**
  11492. * Prepare the list of samplers associated with the Image Processing effects.
  11493. * @param samplersList The list of uniforms used in the effect
  11494. * @param defines the list of defines currently in use
  11495. */
  11496. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11497. /**
  11498. * Prepare the list of defines associated to the shader.
  11499. * @param defines the list of defines to complete
  11500. * @param forPostProcess Define if we are currently in post process mode or not
  11501. */
  11502. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11503. /**
  11504. * Returns true if all the image processing information are ready.
  11505. * @returns True if ready, otherwise, false
  11506. */
  11507. isReady(): boolean;
  11508. /**
  11509. * Binds the image processing to the shader.
  11510. * @param effect The effect to bind to
  11511. * @param overrideAspectRatio Override the aspect ratio of the effect
  11512. */
  11513. bind(effect: Effect, overrideAspectRatio?: number): void;
  11514. /**
  11515. * Clones the current image processing instance.
  11516. * @return The cloned image processing
  11517. */
  11518. clone(): ImageProcessingConfiguration;
  11519. /**
  11520. * Serializes the current image processing instance to a json representation.
  11521. * @return a JSON representation
  11522. */
  11523. serialize(): any;
  11524. /**
  11525. * Parses the image processing from a json representation.
  11526. * @param source the JSON source to parse
  11527. * @return The parsed image processing
  11528. */
  11529. static Parse(source: any): ImageProcessingConfiguration;
  11530. private static _VIGNETTEMODE_MULTIPLY;
  11531. private static _VIGNETTEMODE_OPAQUE;
  11532. /**
  11533. * Used to apply the vignette as a mix with the pixel color.
  11534. */
  11535. static get VIGNETTEMODE_MULTIPLY(): number;
  11536. /**
  11537. * Used to apply the vignette as a replacement of the pixel color.
  11538. */
  11539. static get VIGNETTEMODE_OPAQUE(): number;
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. /** @hidden */
  11544. export var postprocessVertexShader: {
  11545. name: string;
  11546. shader: string;
  11547. };
  11548. }
  11549. declare module BABYLON {
  11550. /**
  11551. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11552. */
  11553. export type RenderTargetTextureSize = number | {
  11554. width: number;
  11555. height: number;
  11556. layers?: number;
  11557. };
  11558. interface ThinEngine {
  11559. /**
  11560. * Creates a new render target texture
  11561. * @param size defines the size of the texture
  11562. * @param options defines the options used to create the texture
  11563. * @returns a new render target texture stored in an InternalTexture
  11564. */
  11565. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11566. /**
  11567. * Creates a depth stencil texture.
  11568. * This is only available in WebGL 2 or with the depth texture extension available.
  11569. * @param size The size of face edge in the texture.
  11570. * @param options The options defining the texture.
  11571. * @returns The texture
  11572. */
  11573. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11574. /** @hidden */
  11575. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11576. }
  11577. }
  11578. declare module BABYLON {
  11579. /**
  11580. * Defines the kind of connection point for node based material
  11581. */
  11582. export enum NodeMaterialBlockConnectionPointTypes {
  11583. /** Float */
  11584. Float = 1,
  11585. /** Int */
  11586. Int = 2,
  11587. /** Vector2 */
  11588. Vector2 = 4,
  11589. /** Vector3 */
  11590. Vector3 = 8,
  11591. /** Vector4 */
  11592. Vector4 = 16,
  11593. /** Color3 */
  11594. Color3 = 32,
  11595. /** Color4 */
  11596. Color4 = 64,
  11597. /** Matrix */
  11598. Matrix = 128,
  11599. /** Custom object */
  11600. Object = 256,
  11601. /** Detect type based on connection */
  11602. AutoDetect = 1024,
  11603. /** Output type that will be defined by input type */
  11604. BasedOnInput = 2048
  11605. }
  11606. }
  11607. declare module BABYLON {
  11608. /**
  11609. * Enum used to define the target of a block
  11610. */
  11611. export enum NodeMaterialBlockTargets {
  11612. /** Vertex shader */
  11613. Vertex = 1,
  11614. /** Fragment shader */
  11615. Fragment = 2,
  11616. /** Neutral */
  11617. Neutral = 4,
  11618. /** Vertex and Fragment */
  11619. VertexAndFragment = 3
  11620. }
  11621. }
  11622. declare module BABYLON {
  11623. /**
  11624. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11625. */
  11626. export enum NodeMaterialBlockConnectionPointMode {
  11627. /** Value is an uniform */
  11628. Uniform = 0,
  11629. /** Value is a mesh attribute */
  11630. Attribute = 1,
  11631. /** Value is a varying between vertex and fragment shaders */
  11632. Varying = 2,
  11633. /** Mode is undefined */
  11634. Undefined = 3
  11635. }
  11636. }
  11637. declare module BABYLON {
  11638. /**
  11639. * Enum used to define system values e.g. values automatically provided by the system
  11640. */
  11641. export enum NodeMaterialSystemValues {
  11642. /** World */
  11643. World = 1,
  11644. /** View */
  11645. View = 2,
  11646. /** Projection */
  11647. Projection = 3,
  11648. /** ViewProjection */
  11649. ViewProjection = 4,
  11650. /** WorldView */
  11651. WorldView = 5,
  11652. /** WorldViewProjection */
  11653. WorldViewProjection = 6,
  11654. /** CameraPosition */
  11655. CameraPosition = 7,
  11656. /** Fog Color */
  11657. FogColor = 8,
  11658. /** Delta time */
  11659. DeltaTime = 9
  11660. }
  11661. }
  11662. declare module BABYLON {
  11663. /**
  11664. * Represents a camera frustum
  11665. */
  11666. export class Frustum {
  11667. /**
  11668. * Gets the planes representing the frustum
  11669. * @param transform matrix to be applied to the returned planes
  11670. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11671. */
  11672. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11673. /**
  11674. * Gets the near frustum plane transformed by the transform matrix
  11675. * @param transform transformation matrix to be applied to the resulting frustum plane
  11676. * @param frustumPlane the resuling frustum plane
  11677. */
  11678. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11679. /**
  11680. * Gets the far frustum plane transformed by the transform matrix
  11681. * @param transform transformation matrix to be applied to the resulting frustum plane
  11682. * @param frustumPlane the resuling frustum plane
  11683. */
  11684. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11685. /**
  11686. * Gets the left frustum plane transformed by the transform matrix
  11687. * @param transform transformation matrix to be applied to the resulting frustum plane
  11688. * @param frustumPlane the resuling frustum plane
  11689. */
  11690. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11691. /**
  11692. * Gets the right frustum plane transformed by the transform matrix
  11693. * @param transform transformation matrix to be applied to the resulting frustum plane
  11694. * @param frustumPlane the resuling frustum plane
  11695. */
  11696. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11697. /**
  11698. * Gets the top frustum plane transformed by the transform matrix
  11699. * @param transform transformation matrix to be applied to the resulting frustum plane
  11700. * @param frustumPlane the resuling frustum plane
  11701. */
  11702. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11703. /**
  11704. * Gets the bottom frustum plane transformed by the transform matrix
  11705. * @param transform transformation matrix to be applied to the resulting frustum plane
  11706. * @param frustumPlane the resuling frustum plane
  11707. */
  11708. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11709. /**
  11710. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11711. * @param transform transformation matrix to be applied to the resulting frustum planes
  11712. * @param frustumPlanes the resuling frustum planes
  11713. */
  11714. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11715. }
  11716. }
  11717. declare module BABYLON {
  11718. /**
  11719. * Contains position and normal vectors for a vertex
  11720. */
  11721. export class PositionNormalVertex {
  11722. /** the position of the vertex (defaut: 0,0,0) */
  11723. position: Vector3;
  11724. /** the normal of the vertex (defaut: 0,1,0) */
  11725. normal: Vector3;
  11726. /**
  11727. * Creates a PositionNormalVertex
  11728. * @param position the position of the vertex (defaut: 0,0,0)
  11729. * @param normal the normal of the vertex (defaut: 0,1,0)
  11730. */
  11731. constructor(
  11732. /** the position of the vertex (defaut: 0,0,0) */
  11733. position?: Vector3,
  11734. /** the normal of the vertex (defaut: 0,1,0) */
  11735. normal?: Vector3);
  11736. /**
  11737. * Clones the PositionNormalVertex
  11738. * @returns the cloned PositionNormalVertex
  11739. */
  11740. clone(): PositionNormalVertex;
  11741. }
  11742. /**
  11743. * Contains position, normal and uv vectors for a vertex
  11744. */
  11745. export class PositionNormalTextureVertex {
  11746. /** the position of the vertex (defaut: 0,0,0) */
  11747. position: Vector3;
  11748. /** the normal of the vertex (defaut: 0,1,0) */
  11749. normal: Vector3;
  11750. /** the uv of the vertex (default: 0,0) */
  11751. uv: Vector2;
  11752. /**
  11753. * Creates a PositionNormalTextureVertex
  11754. * @param position the position of the vertex (defaut: 0,0,0)
  11755. * @param normal the normal of the vertex (defaut: 0,1,0)
  11756. * @param uv the uv of the vertex (default: 0,0)
  11757. */
  11758. constructor(
  11759. /** the position of the vertex (defaut: 0,0,0) */
  11760. position?: Vector3,
  11761. /** the normal of the vertex (defaut: 0,1,0) */
  11762. normal?: Vector3,
  11763. /** the uv of the vertex (default: 0,0) */
  11764. uv?: Vector2);
  11765. /**
  11766. * Clones the PositionNormalTextureVertex
  11767. * @returns the cloned PositionNormalTextureVertex
  11768. */
  11769. clone(): PositionNormalTextureVertex;
  11770. }
  11771. }
  11772. declare module BABYLON {
  11773. /**
  11774. * Enum defining the type of animations supported by InputBlock
  11775. */
  11776. export enum AnimatedInputBlockTypes {
  11777. /** No animation */
  11778. None = 0,
  11779. /** Time based animation. Will only work for floats */
  11780. Time = 1
  11781. }
  11782. }
  11783. declare module BABYLON {
  11784. /**
  11785. * Block used to expose an input value
  11786. */
  11787. export class InputBlock extends NodeMaterialBlock {
  11788. private _mode;
  11789. private _associatedVariableName;
  11790. private _storedValue;
  11791. private _valueCallback;
  11792. private _type;
  11793. private _animationType;
  11794. /** Gets or set a value used to limit the range of float values */
  11795. min: number;
  11796. /** Gets or set a value used to limit the range of float values */
  11797. max: number;
  11798. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11799. isBoolean: boolean;
  11800. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11801. matrixMode: number;
  11802. /** @hidden */
  11803. _systemValue: Nullable<NodeMaterialSystemValues>;
  11804. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11805. isConstant: boolean;
  11806. /** Gets or sets the group to use to display this block in the Inspector */
  11807. groupInInspector: string;
  11808. /** Gets an observable raised when the value is changed */
  11809. onValueChangedObservable: Observable<InputBlock>;
  11810. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11811. convertToGammaSpace: boolean;
  11812. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11813. convertToLinearSpace: boolean;
  11814. /**
  11815. * Gets or sets the connection point type (default is float)
  11816. */
  11817. get type(): NodeMaterialBlockConnectionPointTypes;
  11818. /**
  11819. * Creates a new InputBlock
  11820. * @param name defines the block name
  11821. * @param target defines the target of that block (Vertex by default)
  11822. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11823. */
  11824. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11825. /**
  11826. * Validates if a name is a reserve word.
  11827. * @param newName the new name to be given to the node.
  11828. * @returns false if the name is a reserve word, else true.
  11829. */
  11830. validateBlockName(newName: string): boolean;
  11831. /**
  11832. * Gets the output component
  11833. */
  11834. get output(): NodeMaterialConnectionPoint;
  11835. /**
  11836. * Set the source of this connection point to a vertex attribute
  11837. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11838. * @returns the current connection point
  11839. */
  11840. setAsAttribute(attributeName?: string): InputBlock;
  11841. /**
  11842. * Set the source of this connection point to a system value
  11843. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11844. * @returns the current connection point
  11845. */
  11846. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11847. /**
  11848. * Gets or sets the value of that point.
  11849. * Please note that this value will be ignored if valueCallback is defined
  11850. */
  11851. get value(): any;
  11852. set value(value: any);
  11853. /**
  11854. * Gets or sets a callback used to get the value of that point.
  11855. * Please note that setting this value will force the connection point to ignore the value property
  11856. */
  11857. get valueCallback(): () => any;
  11858. set valueCallback(value: () => any);
  11859. /**
  11860. * Gets or sets the associated variable name in the shader
  11861. */
  11862. get associatedVariableName(): string;
  11863. set associatedVariableName(value: string);
  11864. /** Gets or sets the type of animation applied to the input */
  11865. get animationType(): AnimatedInputBlockTypes;
  11866. set animationType(value: AnimatedInputBlockTypes);
  11867. /**
  11868. * Gets a boolean indicating that this connection point not defined yet
  11869. */
  11870. get isUndefined(): boolean;
  11871. /**
  11872. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11873. * In this case the connection point name must be the name of the uniform to use.
  11874. * Can only be set on inputs
  11875. */
  11876. get isUniform(): boolean;
  11877. set isUniform(value: boolean);
  11878. /**
  11879. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11880. * In this case the connection point name must be the name of the attribute to use
  11881. * Can only be set on inputs
  11882. */
  11883. get isAttribute(): boolean;
  11884. set isAttribute(value: boolean);
  11885. /**
  11886. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11887. * Can only be set on exit points
  11888. */
  11889. get isVarying(): boolean;
  11890. set isVarying(value: boolean);
  11891. /**
  11892. * Gets a boolean indicating that the current connection point is a system value
  11893. */
  11894. get isSystemValue(): boolean;
  11895. /**
  11896. * Gets or sets the current well known value or null if not defined as a system value
  11897. */
  11898. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11899. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11900. /**
  11901. * Gets the current class name
  11902. * @returns the class name
  11903. */
  11904. getClassName(): string;
  11905. /**
  11906. * Animate the input if animationType !== None
  11907. * @param scene defines the rendering scene
  11908. */
  11909. animate(scene: Scene): void;
  11910. private _emitDefine;
  11911. initialize(state: NodeMaterialBuildState): void;
  11912. /**
  11913. * Set the input block to its default value (based on its type)
  11914. */
  11915. setDefaultValue(): void;
  11916. private _emitConstant;
  11917. /** @hidden */
  11918. get _noContextSwitch(): boolean;
  11919. private _emit;
  11920. /** @hidden */
  11921. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11922. /** @hidden */
  11923. _transmit(effect: Effect, scene: Scene): void;
  11924. protected _buildBlock(state: NodeMaterialBuildState): void;
  11925. protected _dumpPropertiesCode(): string;
  11926. dispose(): void;
  11927. serialize(): any;
  11928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11929. }
  11930. }
  11931. declare module BABYLON {
  11932. /**
  11933. * Enum used to define the compatibility state between two connection points
  11934. */
  11935. export enum NodeMaterialConnectionPointCompatibilityStates {
  11936. /** Points are compatibles */
  11937. Compatible = 0,
  11938. /** Points are incompatible because of their types */
  11939. TypeIncompatible = 1,
  11940. /** Points are incompatible because of their targets (vertex vs fragment) */
  11941. TargetIncompatible = 2
  11942. }
  11943. /**
  11944. * Defines the direction of a connection point
  11945. */
  11946. export enum NodeMaterialConnectionPointDirection {
  11947. /** Input */
  11948. Input = 0,
  11949. /** Output */
  11950. Output = 1
  11951. }
  11952. /**
  11953. * Defines a connection point for a block
  11954. */
  11955. export class NodeMaterialConnectionPoint {
  11956. /**
  11957. * Checks if two types are equivalent
  11958. * @param type1 type 1 to check
  11959. * @param type2 type 2 to check
  11960. * @returns true if both types are equivalent, else false
  11961. */
  11962. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11963. /** @hidden */
  11964. _ownerBlock: NodeMaterialBlock;
  11965. /** @hidden */
  11966. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11967. private _endpoints;
  11968. private _associatedVariableName;
  11969. private _direction;
  11970. /** @hidden */
  11971. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11972. /** @hidden */
  11973. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11974. /** @hidden */
  11975. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  11976. private _type;
  11977. /** @hidden */
  11978. _enforceAssociatedVariableName: boolean;
  11979. /** Gets the direction of the point */
  11980. get direction(): NodeMaterialConnectionPointDirection;
  11981. /** Indicates that this connection point needs dual validation before being connected to another point */
  11982. needDualDirectionValidation: boolean;
  11983. /**
  11984. * Gets or sets the additional types supported by this connection point
  11985. */
  11986. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11987. /**
  11988. * Gets or sets the additional types excluded by this connection point
  11989. */
  11990. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11991. /**
  11992. * Observable triggered when this point is connected
  11993. */
  11994. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  11995. /**
  11996. * Gets or sets the associated variable name in the shader
  11997. */
  11998. get associatedVariableName(): string;
  11999. set associatedVariableName(value: string);
  12000. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12001. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12002. /**
  12003. * Gets or sets the connection point type (default is float)
  12004. */
  12005. get type(): NodeMaterialBlockConnectionPointTypes;
  12006. set type(value: NodeMaterialBlockConnectionPointTypes);
  12007. /**
  12008. * Gets or sets the connection point name
  12009. */
  12010. name: string;
  12011. /**
  12012. * Gets or sets the connection point name
  12013. */
  12014. displayName: string;
  12015. /**
  12016. * Gets or sets a boolean indicating that this connection point can be omitted
  12017. */
  12018. isOptional: boolean;
  12019. /**
  12020. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12021. */
  12022. isExposedOnFrame: boolean;
  12023. /**
  12024. * Gets or sets number indicating the position that the port is exposed to on a frame
  12025. */
  12026. exposedPortPosition: number;
  12027. /**
  12028. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12029. */
  12030. define: string;
  12031. /** @hidden */
  12032. _prioritizeVertex: boolean;
  12033. private _target;
  12034. /** Gets or sets the target of that connection point */
  12035. get target(): NodeMaterialBlockTargets;
  12036. set target(value: NodeMaterialBlockTargets);
  12037. /**
  12038. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12039. */
  12040. get isConnected(): boolean;
  12041. /**
  12042. * Gets a boolean indicating that the current point is connected to an input block
  12043. */
  12044. get isConnectedToInputBlock(): boolean;
  12045. /**
  12046. * Gets a the connected input block (if any)
  12047. */
  12048. get connectInputBlock(): Nullable<InputBlock>;
  12049. /** Get the other side of the connection (if any) */
  12050. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12051. /** Get the block that owns this connection point */
  12052. get ownerBlock(): NodeMaterialBlock;
  12053. /** Get the block connected on the other side of this connection (if any) */
  12054. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12055. /** Get the block connected on the endpoints of this connection (if any) */
  12056. get connectedBlocks(): Array<NodeMaterialBlock>;
  12057. /** Gets the list of connected endpoints */
  12058. get endpoints(): NodeMaterialConnectionPoint[];
  12059. /** Gets a boolean indicating if that output point is connected to at least one input */
  12060. get hasEndpoints(): boolean;
  12061. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12062. get isConnectedInVertexShader(): boolean;
  12063. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12064. get isConnectedInFragmentShader(): boolean;
  12065. /**
  12066. * Creates a block suitable to be used as an input for this input point.
  12067. * If null is returned, a block based on the point type will be created.
  12068. * @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
  12069. */
  12070. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12071. /**
  12072. * Creates a new connection point
  12073. * @param name defines the connection point name
  12074. * @param ownerBlock defines the block hosting this connection point
  12075. * @param direction defines the direction of the connection point
  12076. */
  12077. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12078. /**
  12079. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12080. * @returns the class name
  12081. */
  12082. getClassName(): string;
  12083. /**
  12084. * Gets a boolean indicating if the current point can be connected to another point
  12085. * @param connectionPoint defines the other connection point
  12086. * @returns a boolean
  12087. */
  12088. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12089. /**
  12090. * Gets a number indicating if the current point can be connected to another point
  12091. * @param connectionPoint defines the other connection point
  12092. * @returns a number defining the compatibility state
  12093. */
  12094. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12095. /**
  12096. * Connect this point to another connection point
  12097. * @param connectionPoint defines the other connection point
  12098. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12099. * @returns the current connection point
  12100. */
  12101. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12102. /**
  12103. * Disconnect this point from one of his endpoint
  12104. * @param endpoint defines the other connection point
  12105. * @returns the current connection point
  12106. */
  12107. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12108. /**
  12109. * Serializes this point in a JSON representation
  12110. * @param isInput defines if the connection point is an input (default is true)
  12111. * @returns the serialized point object
  12112. */
  12113. serialize(isInput?: boolean): any;
  12114. /**
  12115. * Release resources
  12116. */
  12117. dispose(): void;
  12118. }
  12119. }
  12120. declare module BABYLON {
  12121. /**
  12122. * Enum used to define the material modes
  12123. */
  12124. export enum NodeMaterialModes {
  12125. /** Regular material */
  12126. Material = 0,
  12127. /** For post process */
  12128. PostProcess = 1,
  12129. /** For particle system */
  12130. Particle = 2,
  12131. /** For procedural texture */
  12132. ProceduralTexture = 3
  12133. }
  12134. }
  12135. declare module BABYLON {
  12136. /** @hidden */
  12137. export var helperFunctions: {
  12138. name: string;
  12139. shader: string;
  12140. };
  12141. }
  12142. declare module BABYLON {
  12143. /**
  12144. * Block used to read a texture from a sampler
  12145. */
  12146. export class TextureBlock extends NodeMaterialBlock {
  12147. private _defineName;
  12148. private _linearDefineName;
  12149. private _gammaDefineName;
  12150. private _tempTextureRead;
  12151. private _samplerName;
  12152. private _transformedUVName;
  12153. private _textureTransformName;
  12154. private _textureInfoName;
  12155. private _mainUVName;
  12156. private _mainUVDefineName;
  12157. private _fragmentOnly;
  12158. /**
  12159. * Gets or sets the texture associated with the node
  12160. */
  12161. texture: Nullable<Texture>;
  12162. /**
  12163. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12164. */
  12165. convertToGammaSpace: boolean;
  12166. /**
  12167. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12168. */
  12169. convertToLinearSpace: boolean;
  12170. /**
  12171. * Create a new TextureBlock
  12172. * @param name defines the block name
  12173. */
  12174. constructor(name: string, fragmentOnly?: boolean);
  12175. /**
  12176. * Gets the current class name
  12177. * @returns the class name
  12178. */
  12179. getClassName(): string;
  12180. /**
  12181. * Gets the uv input component
  12182. */
  12183. get uv(): NodeMaterialConnectionPoint;
  12184. /**
  12185. * Gets the rgba output component
  12186. */
  12187. get rgba(): NodeMaterialConnectionPoint;
  12188. /**
  12189. * Gets the rgb output component
  12190. */
  12191. get rgb(): NodeMaterialConnectionPoint;
  12192. /**
  12193. * Gets the r output component
  12194. */
  12195. get r(): NodeMaterialConnectionPoint;
  12196. /**
  12197. * Gets the g output component
  12198. */
  12199. get g(): NodeMaterialConnectionPoint;
  12200. /**
  12201. * Gets the b output component
  12202. */
  12203. get b(): NodeMaterialConnectionPoint;
  12204. /**
  12205. * Gets the a output component
  12206. */
  12207. get a(): NodeMaterialConnectionPoint;
  12208. get target(): NodeMaterialBlockTargets;
  12209. autoConfigure(material: NodeMaterial): void;
  12210. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12212. isReady(): boolean;
  12213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12214. private get _isMixed();
  12215. private _injectVertexCode;
  12216. private _writeTextureRead;
  12217. private _writeOutput;
  12218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12219. protected _dumpPropertiesCode(): string;
  12220. serialize(): any;
  12221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12222. }
  12223. }
  12224. declare module BABYLON {
  12225. /** @hidden */
  12226. export var reflectionFunction: {
  12227. name: string;
  12228. shader: string;
  12229. };
  12230. }
  12231. declare module BABYLON {
  12232. /**
  12233. * Base block used to read a reflection texture from a sampler
  12234. */
  12235. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12236. /** @hidden */
  12237. _define3DName: string;
  12238. /** @hidden */
  12239. _defineCubicName: string;
  12240. /** @hidden */
  12241. _defineExplicitName: string;
  12242. /** @hidden */
  12243. _defineProjectionName: string;
  12244. /** @hidden */
  12245. _defineLocalCubicName: string;
  12246. /** @hidden */
  12247. _defineSphericalName: string;
  12248. /** @hidden */
  12249. _definePlanarName: string;
  12250. /** @hidden */
  12251. _defineEquirectangularName: string;
  12252. /** @hidden */
  12253. _defineMirroredEquirectangularFixedName: string;
  12254. /** @hidden */
  12255. _defineEquirectangularFixedName: string;
  12256. /** @hidden */
  12257. _defineSkyboxName: string;
  12258. /** @hidden */
  12259. _defineOppositeZ: string;
  12260. /** @hidden */
  12261. _cubeSamplerName: string;
  12262. /** @hidden */
  12263. _2DSamplerName: string;
  12264. protected _positionUVWName: string;
  12265. protected _directionWName: string;
  12266. protected _reflectionVectorName: string;
  12267. /** @hidden */
  12268. _reflectionCoordsName: string;
  12269. /** @hidden */
  12270. _reflectionMatrixName: string;
  12271. protected _reflectionColorName: string;
  12272. /**
  12273. * Gets or sets the texture associated with the node
  12274. */
  12275. texture: Nullable<BaseTexture>;
  12276. /**
  12277. * Create a new ReflectionTextureBaseBlock
  12278. * @param name defines the block name
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Gets the current class name
  12283. * @returns the class name
  12284. */
  12285. getClassName(): string;
  12286. /**
  12287. * Gets the world position input component
  12288. */
  12289. abstract get position(): NodeMaterialConnectionPoint;
  12290. /**
  12291. * Gets the world position input component
  12292. */
  12293. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12294. /**
  12295. * Gets the world normal input component
  12296. */
  12297. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12298. /**
  12299. * Gets the world input component
  12300. */
  12301. abstract get world(): NodeMaterialConnectionPoint;
  12302. /**
  12303. * Gets the camera (or eye) position component
  12304. */
  12305. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12306. /**
  12307. * Gets the view input component
  12308. */
  12309. abstract get view(): NodeMaterialConnectionPoint;
  12310. protected _getTexture(): Nullable<BaseTexture>;
  12311. autoConfigure(material: NodeMaterial): void;
  12312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12313. isReady(): boolean;
  12314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12315. /**
  12316. * Gets the code to inject in the vertex shader
  12317. * @param state current state of the node material building
  12318. * @returns the shader code
  12319. */
  12320. handleVertexSide(state: NodeMaterialBuildState): string;
  12321. /**
  12322. * Handles the inits for the fragment code path
  12323. * @param state node material build state
  12324. */
  12325. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12326. /**
  12327. * Generates the reflection coords code for the fragment code path
  12328. * @param worldNormalVarName name of the world normal variable
  12329. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12330. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12331. * @returns the shader code
  12332. */
  12333. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12334. /**
  12335. * Generates the reflection color code for the fragment code path
  12336. * @param lodVarName name of the lod variable
  12337. * @param swizzleLookupTexture swizzle to use for the final color variable
  12338. * @returns the shader code
  12339. */
  12340. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12341. /**
  12342. * Generates the code corresponding to the connected output points
  12343. * @param state node material build state
  12344. * @param varName name of the variable to output
  12345. * @returns the shader code
  12346. */
  12347. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12348. protected _buildBlock(state: NodeMaterialBuildState): this;
  12349. protected _dumpPropertiesCode(): string;
  12350. serialize(): any;
  12351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12352. }
  12353. }
  12354. declare module BABYLON {
  12355. /**
  12356. * Defines a connection point to be used for points with a custom object type
  12357. */
  12358. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12359. private _blockType;
  12360. private _blockName;
  12361. private _nameForCheking?;
  12362. /**
  12363. * Creates a new connection point
  12364. * @param name defines the connection point name
  12365. * @param ownerBlock defines the block hosting this connection point
  12366. * @param direction defines the direction of the connection point
  12367. */
  12368. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12369. /**
  12370. * Gets a number indicating if the current point can be connected to another point
  12371. * @param connectionPoint defines the other connection point
  12372. * @returns a number defining the compatibility state
  12373. */
  12374. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12375. /**
  12376. * Creates a block suitable to be used as an input for this input point.
  12377. * If null is returned, a block based on the point type will be created.
  12378. * @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
  12379. */
  12380. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Enum defining the type of properties that can be edited in the property pages in the NME
  12386. */
  12387. export enum PropertyTypeForEdition {
  12388. /** property is a boolean */
  12389. Boolean = 0,
  12390. /** property is a float */
  12391. Float = 1,
  12392. /** property is a Vector2 */
  12393. Vector2 = 2,
  12394. /** property is a list of values */
  12395. List = 3
  12396. }
  12397. /**
  12398. * Interface that defines an option in a variable of type list
  12399. */
  12400. export interface IEditablePropertyListOption {
  12401. /** label of the option */
  12402. "label": string;
  12403. /** value of the option */
  12404. "value": number;
  12405. }
  12406. /**
  12407. * Interface that defines the options available for an editable property
  12408. */
  12409. export interface IEditablePropertyOption {
  12410. /** min value */
  12411. "min"?: number;
  12412. /** max value */
  12413. "max"?: number;
  12414. /** notifiers: indicates which actions to take when the property is changed */
  12415. "notifiers"?: {
  12416. /** the material should be rebuilt */
  12417. "rebuild"?: boolean;
  12418. /** the preview should be updated */
  12419. "update"?: boolean;
  12420. };
  12421. /** list of the options for a variable of type list */
  12422. "options"?: IEditablePropertyListOption[];
  12423. }
  12424. /**
  12425. * Interface that describes an editable property
  12426. */
  12427. export interface IPropertyDescriptionForEdition {
  12428. /** name of the property */
  12429. "propertyName": string;
  12430. /** display name of the property */
  12431. "displayName": string;
  12432. /** type of the property */
  12433. "type": PropertyTypeForEdition;
  12434. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12435. "groupName": string;
  12436. /** options for the property */
  12437. "options": IEditablePropertyOption;
  12438. }
  12439. /**
  12440. * Decorator that flags a property in a node material block as being editable
  12441. */
  12442. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Block used to implement the refraction part of the sub surface module of the PBR material
  12447. */
  12448. export class RefractionBlock extends NodeMaterialBlock {
  12449. /** @hidden */
  12450. _define3DName: string;
  12451. /** @hidden */
  12452. _refractionMatrixName: string;
  12453. /** @hidden */
  12454. _defineLODRefractionAlpha: string;
  12455. /** @hidden */
  12456. _defineLinearSpecularRefraction: string;
  12457. /** @hidden */
  12458. _defineOppositeZ: string;
  12459. /** @hidden */
  12460. _cubeSamplerName: string;
  12461. /** @hidden */
  12462. _2DSamplerName: string;
  12463. /** @hidden */
  12464. _vRefractionMicrosurfaceInfosName: string;
  12465. /** @hidden */
  12466. _vRefractionInfosName: string;
  12467. /** @hidden */
  12468. _vRefractionFilteringInfoName: string;
  12469. private _scene;
  12470. /**
  12471. * The properties below are set by the main PBR block prior to calling methods of this class.
  12472. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12473. * It's less burden on the user side in the editor part.
  12474. */
  12475. /** @hidden */
  12476. viewConnectionPoint: NodeMaterialConnectionPoint;
  12477. /** @hidden */
  12478. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12479. /**
  12480. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12481. * Materials half opaque for instance using refraction could benefit from this control.
  12482. */
  12483. linkRefractionWithTransparency: boolean;
  12484. /**
  12485. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12486. */
  12487. invertRefractionY: boolean;
  12488. /**
  12489. * Gets or sets the texture associated with the node
  12490. */
  12491. texture: Nullable<BaseTexture>;
  12492. /**
  12493. * Create a new RefractionBlock
  12494. * @param name defines the block name
  12495. */
  12496. constructor(name: string);
  12497. /**
  12498. * Gets the current class name
  12499. * @returns the class name
  12500. */
  12501. getClassName(): string;
  12502. /**
  12503. * Gets the intensity input component
  12504. */
  12505. get intensity(): NodeMaterialConnectionPoint;
  12506. /**
  12507. * Gets the tint at distance input component
  12508. */
  12509. get tintAtDistance(): NodeMaterialConnectionPoint;
  12510. /**
  12511. * Gets the view input component
  12512. */
  12513. get view(): NodeMaterialConnectionPoint;
  12514. /**
  12515. * Gets the refraction object output component
  12516. */
  12517. get refraction(): NodeMaterialConnectionPoint;
  12518. /**
  12519. * Returns true if the block has a texture
  12520. */
  12521. get hasTexture(): boolean;
  12522. protected _getTexture(): Nullable<BaseTexture>;
  12523. autoConfigure(material: NodeMaterial): void;
  12524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12525. isReady(): boolean;
  12526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12527. /**
  12528. * Gets the main code of the block (fragment side)
  12529. * @param state current state of the node material building
  12530. * @returns the shader code
  12531. */
  12532. getCode(state: NodeMaterialBuildState): string;
  12533. protected _buildBlock(state: NodeMaterialBuildState): this;
  12534. protected _dumpPropertiesCode(): string;
  12535. serialize(): any;
  12536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12537. }
  12538. }
  12539. declare module BABYLON {
  12540. /**
  12541. * Base block used as input for post process
  12542. */
  12543. export class CurrentScreenBlock extends NodeMaterialBlock {
  12544. private _samplerName;
  12545. private _linearDefineName;
  12546. private _gammaDefineName;
  12547. private _mainUVName;
  12548. private _tempTextureRead;
  12549. /**
  12550. * Gets or sets the texture associated with the node
  12551. */
  12552. texture: Nullable<BaseTexture>;
  12553. /**
  12554. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12555. */
  12556. convertToGammaSpace: boolean;
  12557. /**
  12558. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12559. */
  12560. convertToLinearSpace: boolean;
  12561. /**
  12562. * Create a new CurrentScreenBlock
  12563. * @param name defines the block name
  12564. */
  12565. constructor(name: string);
  12566. /**
  12567. * Gets the current class name
  12568. * @returns the class name
  12569. */
  12570. getClassName(): string;
  12571. /**
  12572. * Gets the uv input component
  12573. */
  12574. get uv(): NodeMaterialConnectionPoint;
  12575. /**
  12576. * Gets the rgba output component
  12577. */
  12578. get rgba(): NodeMaterialConnectionPoint;
  12579. /**
  12580. * Gets the rgb output component
  12581. */
  12582. get rgb(): NodeMaterialConnectionPoint;
  12583. /**
  12584. * Gets the r output component
  12585. */
  12586. get r(): NodeMaterialConnectionPoint;
  12587. /**
  12588. * Gets the g output component
  12589. */
  12590. get g(): NodeMaterialConnectionPoint;
  12591. /**
  12592. * Gets the b output component
  12593. */
  12594. get b(): NodeMaterialConnectionPoint;
  12595. /**
  12596. * Gets the a output component
  12597. */
  12598. get a(): NodeMaterialConnectionPoint;
  12599. /**
  12600. * Initialize the block and prepare the context for build
  12601. * @param state defines the state that will be used for the build
  12602. */
  12603. initialize(state: NodeMaterialBuildState): void;
  12604. get target(): NodeMaterialBlockTargets;
  12605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12606. isReady(): boolean;
  12607. private _injectVertexCode;
  12608. private _writeTextureRead;
  12609. private _writeOutput;
  12610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12611. serialize(): any;
  12612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12613. }
  12614. }
  12615. declare module BABYLON {
  12616. /**
  12617. * Base block used for the particle texture
  12618. */
  12619. export class ParticleTextureBlock extends NodeMaterialBlock {
  12620. private _samplerName;
  12621. private _linearDefineName;
  12622. private _gammaDefineName;
  12623. private _tempTextureRead;
  12624. /**
  12625. * Gets or sets the texture associated with the node
  12626. */
  12627. texture: Nullable<BaseTexture>;
  12628. /**
  12629. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12630. */
  12631. convertToGammaSpace: boolean;
  12632. /**
  12633. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12634. */
  12635. convertToLinearSpace: boolean;
  12636. /**
  12637. * Create a new ParticleTextureBlock
  12638. * @param name defines the block name
  12639. */
  12640. constructor(name: string);
  12641. /**
  12642. * Gets the current class name
  12643. * @returns the class name
  12644. */
  12645. getClassName(): string;
  12646. /**
  12647. * Gets the uv input component
  12648. */
  12649. get uv(): NodeMaterialConnectionPoint;
  12650. /**
  12651. * Gets the rgba output component
  12652. */
  12653. get rgba(): NodeMaterialConnectionPoint;
  12654. /**
  12655. * Gets the rgb output component
  12656. */
  12657. get rgb(): NodeMaterialConnectionPoint;
  12658. /**
  12659. * Gets the r output component
  12660. */
  12661. get r(): NodeMaterialConnectionPoint;
  12662. /**
  12663. * Gets the g output component
  12664. */
  12665. get g(): NodeMaterialConnectionPoint;
  12666. /**
  12667. * Gets the b output component
  12668. */
  12669. get b(): NodeMaterialConnectionPoint;
  12670. /**
  12671. * Gets the a output component
  12672. */
  12673. get a(): NodeMaterialConnectionPoint;
  12674. /**
  12675. * Initialize the block and prepare the context for build
  12676. * @param state defines the state that will be used for the build
  12677. */
  12678. initialize(state: NodeMaterialBuildState): void;
  12679. autoConfigure(material: NodeMaterial): void;
  12680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12681. isReady(): boolean;
  12682. private _writeOutput;
  12683. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12684. serialize(): any;
  12685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12686. }
  12687. }
  12688. declare module BABYLON {
  12689. /**
  12690. * Class used to store shared data between 2 NodeMaterialBuildState
  12691. */
  12692. export class NodeMaterialBuildStateSharedData {
  12693. /**
  12694. * Gets the list of emitted varyings
  12695. */
  12696. temps: string[];
  12697. /**
  12698. * Gets the list of emitted varyings
  12699. */
  12700. varyings: string[];
  12701. /**
  12702. * Gets the varying declaration string
  12703. */
  12704. varyingDeclaration: string;
  12705. /**
  12706. * Input blocks
  12707. */
  12708. inputBlocks: InputBlock[];
  12709. /**
  12710. * Input blocks
  12711. */
  12712. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12713. /**
  12714. * Bindable blocks (Blocks that need to set data to the effect)
  12715. */
  12716. bindableBlocks: NodeMaterialBlock[];
  12717. /**
  12718. * List of blocks that can provide a compilation fallback
  12719. */
  12720. blocksWithFallbacks: NodeMaterialBlock[];
  12721. /**
  12722. * List of blocks that can provide a define update
  12723. */
  12724. blocksWithDefines: NodeMaterialBlock[];
  12725. /**
  12726. * List of blocks that can provide a repeatable content
  12727. */
  12728. repeatableContentBlocks: NodeMaterialBlock[];
  12729. /**
  12730. * List of blocks that can provide a dynamic list of uniforms
  12731. */
  12732. dynamicUniformBlocks: NodeMaterialBlock[];
  12733. /**
  12734. * List of blocks that can block the isReady function for the material
  12735. */
  12736. blockingBlocks: NodeMaterialBlock[];
  12737. /**
  12738. * Gets the list of animated inputs
  12739. */
  12740. animatedInputs: InputBlock[];
  12741. /**
  12742. * Build Id used to avoid multiple recompilations
  12743. */
  12744. buildId: number;
  12745. /** List of emitted variables */
  12746. variableNames: {
  12747. [key: string]: number;
  12748. };
  12749. /** List of emitted defines */
  12750. defineNames: {
  12751. [key: string]: number;
  12752. };
  12753. /** Should emit comments? */
  12754. emitComments: boolean;
  12755. /** Emit build activity */
  12756. verbose: boolean;
  12757. /** Gets or sets the hosting scene */
  12758. scene: Scene;
  12759. /**
  12760. * Gets the compilation hints emitted at compilation time
  12761. */
  12762. hints: {
  12763. needWorldViewMatrix: boolean;
  12764. needWorldViewProjectionMatrix: boolean;
  12765. needAlphaBlending: boolean;
  12766. needAlphaTesting: boolean;
  12767. };
  12768. /**
  12769. * List of compilation checks
  12770. */
  12771. checks: {
  12772. emitVertex: boolean;
  12773. emitFragment: boolean;
  12774. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12775. };
  12776. /**
  12777. * Is vertex program allowed to be empty?
  12778. */
  12779. allowEmptyVertexProgram: boolean;
  12780. /** Creates a new shared data */
  12781. constructor();
  12782. /**
  12783. * Emits console errors and exceptions if there is a failing check
  12784. */
  12785. emitErrors(): void;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Class used to store node based material build state
  12791. */
  12792. export class NodeMaterialBuildState {
  12793. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12794. supportUniformBuffers: boolean;
  12795. /**
  12796. * Gets the list of emitted attributes
  12797. */
  12798. attributes: string[];
  12799. /**
  12800. * Gets the list of emitted uniforms
  12801. */
  12802. uniforms: string[];
  12803. /**
  12804. * Gets the list of emitted constants
  12805. */
  12806. constants: string[];
  12807. /**
  12808. * Gets the list of emitted samplers
  12809. */
  12810. samplers: string[];
  12811. /**
  12812. * Gets the list of emitted functions
  12813. */
  12814. functions: {
  12815. [key: string]: string;
  12816. };
  12817. /**
  12818. * Gets the list of emitted extensions
  12819. */
  12820. extensions: {
  12821. [key: string]: string;
  12822. };
  12823. /**
  12824. * Gets the target of the compilation state
  12825. */
  12826. target: NodeMaterialBlockTargets;
  12827. /**
  12828. * Gets the list of emitted counters
  12829. */
  12830. counters: {
  12831. [key: string]: number;
  12832. };
  12833. /**
  12834. * Shared data between multiple NodeMaterialBuildState instances
  12835. */
  12836. sharedData: NodeMaterialBuildStateSharedData;
  12837. /** @hidden */
  12838. _vertexState: NodeMaterialBuildState;
  12839. /** @hidden */
  12840. _attributeDeclaration: string;
  12841. /** @hidden */
  12842. _uniformDeclaration: string;
  12843. /** @hidden */
  12844. _constantDeclaration: string;
  12845. /** @hidden */
  12846. _samplerDeclaration: string;
  12847. /** @hidden */
  12848. _varyingTransfer: string;
  12849. /** @hidden */
  12850. _injectAtEnd: string;
  12851. private _repeatableContentAnchorIndex;
  12852. /** @hidden */
  12853. _builtCompilationString: string;
  12854. /**
  12855. * Gets the emitted compilation strings
  12856. */
  12857. compilationString: string;
  12858. /**
  12859. * Finalize the compilation strings
  12860. * @param state defines the current compilation state
  12861. */
  12862. finalize(state: NodeMaterialBuildState): void;
  12863. /** @hidden */
  12864. get _repeatableContentAnchor(): string;
  12865. /** @hidden */
  12866. _getFreeVariableName(prefix: string): string;
  12867. /** @hidden */
  12868. _getFreeDefineName(prefix: string): string;
  12869. /** @hidden */
  12870. _excludeVariableName(name: string): void;
  12871. /** @hidden */
  12872. _emit2DSampler(name: string): void;
  12873. /** @hidden */
  12874. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12875. /** @hidden */
  12876. _emitExtension(name: string, extension: string, define?: string): void;
  12877. /** @hidden */
  12878. _emitFunction(name: string, code: string, comments: string): void;
  12879. /** @hidden */
  12880. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12881. replaceStrings?: {
  12882. search: RegExp;
  12883. replace: string;
  12884. }[];
  12885. repeatKey?: string;
  12886. }): string;
  12887. /** @hidden */
  12888. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12889. repeatKey?: string;
  12890. removeAttributes?: boolean;
  12891. removeUniforms?: boolean;
  12892. removeVaryings?: boolean;
  12893. removeIfDef?: boolean;
  12894. replaceStrings?: {
  12895. search: RegExp;
  12896. replace: string;
  12897. }[];
  12898. }, storeKey?: string): void;
  12899. /** @hidden */
  12900. _registerTempVariable(name: string): boolean;
  12901. /** @hidden */
  12902. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12903. /** @hidden */
  12904. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12905. /** @hidden */
  12906. _emitFloat(value: number): string;
  12907. }
  12908. }
  12909. declare module BABYLON {
  12910. /**
  12911. * Helper class used to generate session unique ID
  12912. */
  12913. export class UniqueIdGenerator {
  12914. private static _UniqueIdCounter;
  12915. /**
  12916. * Gets an unique (relatively to the current scene) Id
  12917. */
  12918. static get UniqueId(): number;
  12919. }
  12920. }
  12921. declare module BABYLON {
  12922. /**
  12923. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12924. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12925. */
  12926. export class EffectFallbacks implements IEffectFallbacks {
  12927. private _defines;
  12928. private _currentRank;
  12929. private _maxRank;
  12930. private _mesh;
  12931. /**
  12932. * Removes the fallback from the bound mesh.
  12933. */
  12934. unBindMesh(): void;
  12935. /**
  12936. * Adds a fallback on the specified property.
  12937. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12938. * @param define The name of the define in the shader
  12939. */
  12940. addFallback(rank: number, define: string): void;
  12941. /**
  12942. * Sets the mesh to use CPU skinning when needing to fallback.
  12943. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12944. * @param mesh The mesh to use the fallbacks.
  12945. */
  12946. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12947. /**
  12948. * Checks to see if more fallbacks are still availible.
  12949. */
  12950. get hasMoreFallbacks(): boolean;
  12951. /**
  12952. * Removes the defines that should be removed when falling back.
  12953. * @param currentDefines defines the current define statements for the shader.
  12954. * @param effect defines the current effect we try to compile
  12955. * @returns The resulting defines with defines of the current rank removed.
  12956. */
  12957. reduce(currentDefines: string, effect: Effect): string;
  12958. }
  12959. }
  12960. declare module BABYLON {
  12961. /**
  12962. * Defines a block that can be used inside a node based material
  12963. */
  12964. export class NodeMaterialBlock {
  12965. private _buildId;
  12966. private _buildTarget;
  12967. private _target;
  12968. private _isFinalMerger;
  12969. private _isInput;
  12970. private _name;
  12971. protected _isUnique: boolean;
  12972. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12973. inputsAreExclusive: boolean;
  12974. /** @hidden */
  12975. _codeVariableName: string;
  12976. /** @hidden */
  12977. _inputs: NodeMaterialConnectionPoint[];
  12978. /** @hidden */
  12979. _outputs: NodeMaterialConnectionPoint[];
  12980. /** @hidden */
  12981. _preparationId: number;
  12982. /**
  12983. * Gets the name of the block
  12984. */
  12985. get name(): string;
  12986. /**
  12987. * Sets the name of the block. Will check if the name is valid.
  12988. */
  12989. set name(newName: string);
  12990. /**
  12991. * Gets or sets the unique id of the node
  12992. */
  12993. uniqueId: number;
  12994. /**
  12995. * Gets or sets the comments associated with this block
  12996. */
  12997. comments: string;
  12998. /**
  12999. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13000. */
  13001. get isUnique(): boolean;
  13002. /**
  13003. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13004. */
  13005. get isFinalMerger(): boolean;
  13006. /**
  13007. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13008. */
  13009. get isInput(): boolean;
  13010. /**
  13011. * Gets or sets the build Id
  13012. */
  13013. get buildId(): number;
  13014. set buildId(value: number);
  13015. /**
  13016. * Gets or sets the target of the block
  13017. */
  13018. get target(): NodeMaterialBlockTargets;
  13019. set target(value: NodeMaterialBlockTargets);
  13020. /**
  13021. * Gets the list of input points
  13022. */
  13023. get inputs(): NodeMaterialConnectionPoint[];
  13024. /** Gets the list of output points */
  13025. get outputs(): NodeMaterialConnectionPoint[];
  13026. /**
  13027. * Find an input by its name
  13028. * @param name defines the name of the input to look for
  13029. * @returns the input or null if not found
  13030. */
  13031. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13032. /**
  13033. * Find an output by its name
  13034. * @param name defines the name of the outputto look for
  13035. * @returns the output or null if not found
  13036. */
  13037. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13038. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13039. visibleInInspector: boolean;
  13040. /**
  13041. * Creates a new NodeMaterialBlock
  13042. * @param name defines the block name
  13043. * @param target defines the target of that block (Vertex by default)
  13044. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13045. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13046. */
  13047. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13048. /**
  13049. * Initialize the block and prepare the context for build
  13050. * @param state defines the state that will be used for the build
  13051. */
  13052. initialize(state: NodeMaterialBuildState): void;
  13053. /**
  13054. * Bind data to effect. Will only be called for blocks with isBindable === true
  13055. * @param effect defines the effect to bind data to
  13056. * @param nodeMaterial defines the hosting NodeMaterial
  13057. * @param mesh defines the mesh that will be rendered
  13058. * @param subMesh defines the submesh that will be rendered
  13059. */
  13060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13061. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13062. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13063. protected _writeFloat(value: number): string;
  13064. /**
  13065. * Gets the current class name e.g. "NodeMaterialBlock"
  13066. * @returns the class name
  13067. */
  13068. getClassName(): string;
  13069. /**
  13070. * Register a new input. Must be called inside a block constructor
  13071. * @param name defines the connection point name
  13072. * @param type defines the connection point type
  13073. * @param isOptional defines a boolean indicating that this input can be omitted
  13074. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13075. * @param point an already created connection point. If not provided, create a new one
  13076. * @returns the current block
  13077. */
  13078. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13079. /**
  13080. * Register a new output. Must be called inside a block constructor
  13081. * @param name defines the connection point name
  13082. * @param type defines the connection point type
  13083. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13084. * @param point an already created connection point. If not provided, create a new one
  13085. * @returns the current block
  13086. */
  13087. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13088. /**
  13089. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13090. * @param forOutput defines an optional connection point to check compatibility with
  13091. * @returns the first available input or null
  13092. */
  13093. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13094. /**
  13095. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13096. * @param forBlock defines an optional block to check compatibility with
  13097. * @returns the first available input or null
  13098. */
  13099. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13100. /**
  13101. * Gets the sibling of the given output
  13102. * @param current defines the current output
  13103. * @returns the next output in the list or null
  13104. */
  13105. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13106. /**
  13107. * Connect current block with another block
  13108. * @param other defines the block to connect with
  13109. * @param options define the various options to help pick the right connections
  13110. * @returns the current block
  13111. */
  13112. connectTo(other: NodeMaterialBlock, options?: {
  13113. input?: string;
  13114. output?: string;
  13115. outputSwizzle?: string;
  13116. }): this | undefined;
  13117. protected _buildBlock(state: NodeMaterialBuildState): void;
  13118. /**
  13119. * Add uniforms, samplers and uniform buffers at compilation time
  13120. * @param state defines the state to update
  13121. * @param nodeMaterial defines the node material requesting the update
  13122. * @param defines defines the material defines to update
  13123. * @param uniformBuffers defines the list of uniform buffer names
  13124. */
  13125. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13126. /**
  13127. * Add potential fallbacks if shader compilation fails
  13128. * @param mesh defines the mesh to be rendered
  13129. * @param fallbacks defines the current prioritized list of fallbacks
  13130. */
  13131. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13132. /**
  13133. * Initialize defines for shader compilation
  13134. * @param mesh defines the mesh to be rendered
  13135. * @param nodeMaterial defines the node material requesting the update
  13136. * @param defines defines the material defines to update
  13137. * @param useInstances specifies that instances should be used
  13138. */
  13139. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13140. /**
  13141. * Update defines for shader compilation
  13142. * @param mesh defines the mesh to be rendered
  13143. * @param nodeMaterial defines the node material requesting the update
  13144. * @param defines defines the material defines to update
  13145. * @param useInstances specifies that instances should be used
  13146. * @param subMesh defines which submesh to render
  13147. */
  13148. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13149. /**
  13150. * Lets the block try to connect some inputs automatically
  13151. * @param material defines the hosting NodeMaterial
  13152. */
  13153. autoConfigure(material: NodeMaterial): void;
  13154. /**
  13155. * Function called when a block is declared as repeatable content generator
  13156. * @param vertexShaderState defines the current compilation state for the vertex shader
  13157. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13158. * @param mesh defines the mesh to be rendered
  13159. * @param defines defines the material defines to update
  13160. */
  13161. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13162. /**
  13163. * Checks if the block is ready
  13164. * @param mesh defines the mesh to be rendered
  13165. * @param nodeMaterial defines the node material requesting the update
  13166. * @param defines defines the material defines to update
  13167. * @param useInstances specifies that instances should be used
  13168. * @returns true if the block is ready
  13169. */
  13170. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13171. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13172. private _processBuild;
  13173. /**
  13174. * Validates the new name for the block node.
  13175. * @param newName the new name to be given to the node.
  13176. * @returns false if the name is a reserve word, else true.
  13177. */
  13178. validateBlockName(newName: string): boolean;
  13179. /**
  13180. * Compile the current node and generate the shader code
  13181. * @param state defines the current compilation state (uniforms, samplers, current string)
  13182. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13183. * @returns true if already built
  13184. */
  13185. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13186. protected _inputRename(name: string): string;
  13187. protected _outputRename(name: string): string;
  13188. protected _dumpPropertiesCode(): string;
  13189. /** @hidden */
  13190. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13191. /** @hidden */
  13192. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13193. /**
  13194. * Clone the current block to a new identical block
  13195. * @param scene defines the hosting scene
  13196. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13197. * @returns a copy of the current block
  13198. */
  13199. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13200. /**
  13201. * Serializes this block in a JSON representation
  13202. * @returns the serialized block object
  13203. */
  13204. serialize(): any;
  13205. /** @hidden */
  13206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13207. private _deserializePortDisplayNamesAndExposedOnFrame;
  13208. /**
  13209. * Release resources
  13210. */
  13211. dispose(): void;
  13212. }
  13213. }
  13214. declare module BABYLON {
  13215. /**
  13216. * Base class of materials working in push mode in babylon JS
  13217. * @hidden
  13218. */
  13219. export class PushMaterial extends Material {
  13220. protected _activeEffect: Effect;
  13221. protected _normalMatrix: Matrix;
  13222. constructor(name: string, scene: Scene);
  13223. getEffect(): Effect;
  13224. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13225. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13226. /**
  13227. * Binds the given world matrix to the active effect
  13228. *
  13229. * @param world the matrix to bind
  13230. */
  13231. bindOnlyWorldMatrix(world: Matrix): void;
  13232. /**
  13233. * Binds the given normal matrix to the active effect
  13234. *
  13235. * @param normalMatrix the matrix to bind
  13236. */
  13237. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13238. bind(world: Matrix, mesh?: Mesh): void;
  13239. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13240. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13241. }
  13242. }
  13243. declare module BABYLON {
  13244. /**
  13245. * Root class for all node material optimizers
  13246. */
  13247. export class NodeMaterialOptimizer {
  13248. /**
  13249. * Function used to optimize a NodeMaterial graph
  13250. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13251. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13252. */
  13253. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13254. }
  13255. }
  13256. declare module BABYLON {
  13257. /**
  13258. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13259. */
  13260. export class TransformBlock extends NodeMaterialBlock {
  13261. /**
  13262. * Defines the value to use to complement W value to transform it to a Vector4
  13263. */
  13264. complementW: number;
  13265. /**
  13266. * Defines the value to use to complement z value to transform it to a Vector4
  13267. */
  13268. complementZ: number;
  13269. /**
  13270. * Creates a new TransformBlock
  13271. * @param name defines the block name
  13272. */
  13273. constructor(name: string);
  13274. /**
  13275. * Gets the current class name
  13276. * @returns the class name
  13277. */
  13278. getClassName(): string;
  13279. /**
  13280. * Gets the vector input
  13281. */
  13282. get vector(): NodeMaterialConnectionPoint;
  13283. /**
  13284. * Gets the output component
  13285. */
  13286. get output(): NodeMaterialConnectionPoint;
  13287. /**
  13288. * Gets the xyz output component
  13289. */
  13290. get xyz(): NodeMaterialConnectionPoint;
  13291. /**
  13292. * Gets the matrix transform input
  13293. */
  13294. get transform(): NodeMaterialConnectionPoint;
  13295. protected _buildBlock(state: NodeMaterialBuildState): this;
  13296. /**
  13297. * Update defines for shader compilation
  13298. * @param mesh defines the mesh to be rendered
  13299. * @param nodeMaterial defines the node material requesting the update
  13300. * @param defines defines the material defines to update
  13301. * @param useInstances specifies that instances should be used
  13302. * @param subMesh defines which submesh to render
  13303. */
  13304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13305. serialize(): any;
  13306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13307. protected _dumpPropertiesCode(): string;
  13308. }
  13309. }
  13310. declare module BABYLON {
  13311. /**
  13312. * Block used to output the vertex position
  13313. */
  13314. export class VertexOutputBlock extends NodeMaterialBlock {
  13315. /**
  13316. * Creates a new VertexOutputBlock
  13317. * @param name defines the block name
  13318. */
  13319. constructor(name: string);
  13320. /**
  13321. * Gets the current class name
  13322. * @returns the class name
  13323. */
  13324. getClassName(): string;
  13325. /**
  13326. * Gets the vector input component
  13327. */
  13328. get vector(): NodeMaterialConnectionPoint;
  13329. protected _buildBlock(state: NodeMaterialBuildState): this;
  13330. }
  13331. }
  13332. declare module BABYLON {
  13333. /**
  13334. * Block used to output the final color
  13335. */
  13336. export class FragmentOutputBlock extends NodeMaterialBlock {
  13337. /**
  13338. * Create a new FragmentOutputBlock
  13339. * @param name defines the block name
  13340. */
  13341. constructor(name: string);
  13342. /**
  13343. * Gets the current class name
  13344. * @returns the class name
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Gets the rgba input component
  13349. */
  13350. get rgba(): NodeMaterialConnectionPoint;
  13351. /**
  13352. * Gets the rgb input component
  13353. */
  13354. get rgb(): NodeMaterialConnectionPoint;
  13355. /**
  13356. * Gets the a input component
  13357. */
  13358. get a(): NodeMaterialConnectionPoint;
  13359. protected _buildBlock(state: NodeMaterialBuildState): this;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Block used for the particle ramp gradient section
  13365. */
  13366. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13367. /**
  13368. * Create a new ParticleRampGradientBlock
  13369. * @param name defines the block name
  13370. */
  13371. constructor(name: string);
  13372. /**
  13373. * Gets the current class name
  13374. * @returns the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Gets the color input component
  13379. */
  13380. get color(): NodeMaterialConnectionPoint;
  13381. /**
  13382. * Gets the rampColor output component
  13383. */
  13384. get rampColor(): NodeMaterialConnectionPoint;
  13385. /**
  13386. * Initialize the block and prepare the context for build
  13387. * @param state defines the state that will be used for the build
  13388. */
  13389. initialize(state: NodeMaterialBuildState): void;
  13390. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13391. }
  13392. }
  13393. declare module BABYLON {
  13394. /**
  13395. * Block used for the particle blend multiply section
  13396. */
  13397. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13398. /**
  13399. * Create a new ParticleBlendMultiplyBlock
  13400. * @param name defines the block name
  13401. */
  13402. constructor(name: string);
  13403. /**
  13404. * Gets the current class name
  13405. * @returns the class name
  13406. */
  13407. getClassName(): string;
  13408. /**
  13409. * Gets the color input component
  13410. */
  13411. get color(): NodeMaterialConnectionPoint;
  13412. /**
  13413. * Gets the alphaTexture input component
  13414. */
  13415. get alphaTexture(): NodeMaterialConnectionPoint;
  13416. /**
  13417. * Gets the alphaColor input component
  13418. */
  13419. get alphaColor(): NodeMaterialConnectionPoint;
  13420. /**
  13421. * Gets the blendColor output component
  13422. */
  13423. get blendColor(): NodeMaterialConnectionPoint;
  13424. /**
  13425. * Initialize the block and prepare the context for build
  13426. * @param state defines the state that will be used for the build
  13427. */
  13428. initialize(state: NodeMaterialBuildState): void;
  13429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13430. }
  13431. }
  13432. declare module BABYLON {
  13433. /**
  13434. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13435. */
  13436. export class VectorMergerBlock extends NodeMaterialBlock {
  13437. /**
  13438. * Create a new VectorMergerBlock
  13439. * @param name defines the block name
  13440. */
  13441. constructor(name: string);
  13442. /**
  13443. * Gets the current class name
  13444. * @returns the class name
  13445. */
  13446. getClassName(): string;
  13447. /**
  13448. * Gets the xyz component (input)
  13449. */
  13450. get xyzIn(): NodeMaterialConnectionPoint;
  13451. /**
  13452. * Gets the xy component (input)
  13453. */
  13454. get xyIn(): NodeMaterialConnectionPoint;
  13455. /**
  13456. * Gets the x component (input)
  13457. */
  13458. get x(): NodeMaterialConnectionPoint;
  13459. /**
  13460. * Gets the y component (input)
  13461. */
  13462. get y(): NodeMaterialConnectionPoint;
  13463. /**
  13464. * Gets the z component (input)
  13465. */
  13466. get z(): NodeMaterialConnectionPoint;
  13467. /**
  13468. * Gets the w component (input)
  13469. */
  13470. get w(): NodeMaterialConnectionPoint;
  13471. /**
  13472. * Gets the xyzw component (output)
  13473. */
  13474. get xyzw(): NodeMaterialConnectionPoint;
  13475. /**
  13476. * Gets the xyz component (output)
  13477. */
  13478. get xyzOut(): NodeMaterialConnectionPoint;
  13479. /**
  13480. * Gets the xy component (output)
  13481. */
  13482. get xyOut(): NodeMaterialConnectionPoint;
  13483. /**
  13484. * Gets the xy component (output)
  13485. * @deprecated Please use xyOut instead.
  13486. */
  13487. get xy(): NodeMaterialConnectionPoint;
  13488. /**
  13489. * Gets the xyz component (output)
  13490. * @deprecated Please use xyzOut instead.
  13491. */
  13492. get xyz(): NodeMaterialConnectionPoint;
  13493. protected _buildBlock(state: NodeMaterialBuildState): this;
  13494. }
  13495. }
  13496. declare module BABYLON {
  13497. /**
  13498. * Block used to remap a float from a range to a new one
  13499. */
  13500. export class RemapBlock extends NodeMaterialBlock {
  13501. /**
  13502. * Gets or sets the source range
  13503. */
  13504. sourceRange: Vector2;
  13505. /**
  13506. * Gets or sets the target range
  13507. */
  13508. targetRange: Vector2;
  13509. /**
  13510. * Creates a new RemapBlock
  13511. * @param name defines the block name
  13512. */
  13513. constructor(name: string);
  13514. /**
  13515. * Gets the current class name
  13516. * @returns the class name
  13517. */
  13518. getClassName(): string;
  13519. /**
  13520. * Gets the input component
  13521. */
  13522. get input(): NodeMaterialConnectionPoint;
  13523. /**
  13524. * Gets the source min input component
  13525. */
  13526. get sourceMin(): NodeMaterialConnectionPoint;
  13527. /**
  13528. * Gets the source max input component
  13529. */
  13530. get sourceMax(): NodeMaterialConnectionPoint;
  13531. /**
  13532. * Gets the target min input component
  13533. */
  13534. get targetMin(): NodeMaterialConnectionPoint;
  13535. /**
  13536. * Gets the target max input component
  13537. */
  13538. get targetMax(): NodeMaterialConnectionPoint;
  13539. /**
  13540. * Gets the output component
  13541. */
  13542. get output(): NodeMaterialConnectionPoint;
  13543. protected _buildBlock(state: NodeMaterialBuildState): this;
  13544. protected _dumpPropertiesCode(): string;
  13545. serialize(): any;
  13546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13547. }
  13548. }
  13549. declare module BABYLON {
  13550. /**
  13551. * Block used to multiply 2 values
  13552. */
  13553. export class MultiplyBlock extends NodeMaterialBlock {
  13554. /**
  13555. * Creates a new MultiplyBlock
  13556. * @param name defines the block name
  13557. */
  13558. constructor(name: string);
  13559. /**
  13560. * Gets the current class name
  13561. * @returns the class name
  13562. */
  13563. getClassName(): string;
  13564. /**
  13565. * Gets the left operand input component
  13566. */
  13567. get left(): NodeMaterialConnectionPoint;
  13568. /**
  13569. * Gets the right operand input component
  13570. */
  13571. get right(): NodeMaterialConnectionPoint;
  13572. /**
  13573. * Gets the output component
  13574. */
  13575. get output(): NodeMaterialConnectionPoint;
  13576. protected _buildBlock(state: NodeMaterialBuildState): this;
  13577. }
  13578. }
  13579. declare module BABYLON {
  13580. /** Interface used by value gradients (color, factor, ...) */
  13581. export interface IValueGradient {
  13582. /**
  13583. * Gets or sets the gradient value (between 0 and 1)
  13584. */
  13585. gradient: number;
  13586. }
  13587. /** Class used to store color4 gradient */
  13588. export class ColorGradient implements IValueGradient {
  13589. /**
  13590. * Gets or sets the gradient value (between 0 and 1)
  13591. */
  13592. gradient: number;
  13593. /**
  13594. * Gets or sets first associated color
  13595. */
  13596. color1: Color4;
  13597. /**
  13598. * Gets or sets second associated color
  13599. */
  13600. color2?: Color4 | undefined;
  13601. /**
  13602. * Creates a new color4 gradient
  13603. * @param gradient gets or sets the gradient value (between 0 and 1)
  13604. * @param color1 gets or sets first associated color
  13605. * @param color2 gets or sets first second color
  13606. */
  13607. constructor(
  13608. /**
  13609. * Gets or sets the gradient value (between 0 and 1)
  13610. */
  13611. gradient: number,
  13612. /**
  13613. * Gets or sets first associated color
  13614. */
  13615. color1: Color4,
  13616. /**
  13617. * Gets or sets second associated color
  13618. */
  13619. color2?: Color4 | undefined);
  13620. /**
  13621. * Will get a color picked randomly between color1 and color2.
  13622. * If color2 is undefined then color1 will be used
  13623. * @param result defines the target Color4 to store the result in
  13624. */
  13625. getColorToRef(result: Color4): void;
  13626. }
  13627. /** Class used to store color 3 gradient */
  13628. export class Color3Gradient implements IValueGradient {
  13629. /**
  13630. * Gets or sets the gradient value (between 0 and 1)
  13631. */
  13632. gradient: number;
  13633. /**
  13634. * Gets or sets the associated color
  13635. */
  13636. color: Color3;
  13637. /**
  13638. * Creates a new color3 gradient
  13639. * @param gradient gets or sets the gradient value (between 0 and 1)
  13640. * @param color gets or sets associated color
  13641. */
  13642. constructor(
  13643. /**
  13644. * Gets or sets the gradient value (between 0 and 1)
  13645. */
  13646. gradient: number,
  13647. /**
  13648. * Gets or sets the associated color
  13649. */
  13650. color: Color3);
  13651. }
  13652. /** Class used to store factor gradient */
  13653. export class FactorGradient implements IValueGradient {
  13654. /**
  13655. * Gets or sets the gradient value (between 0 and 1)
  13656. */
  13657. gradient: number;
  13658. /**
  13659. * Gets or sets first associated factor
  13660. */
  13661. factor1: number;
  13662. /**
  13663. * Gets or sets second associated factor
  13664. */
  13665. factor2?: number | undefined;
  13666. /**
  13667. * Creates a new factor gradient
  13668. * @param gradient gets or sets the gradient value (between 0 and 1)
  13669. * @param factor1 gets or sets first associated factor
  13670. * @param factor2 gets or sets second associated factor
  13671. */
  13672. constructor(
  13673. /**
  13674. * Gets or sets the gradient value (between 0 and 1)
  13675. */
  13676. gradient: number,
  13677. /**
  13678. * Gets or sets first associated factor
  13679. */
  13680. factor1: number,
  13681. /**
  13682. * Gets or sets second associated factor
  13683. */
  13684. factor2?: number | undefined);
  13685. /**
  13686. * Will get a number picked randomly between factor1 and factor2.
  13687. * If factor2 is undefined then factor1 will be used
  13688. * @returns the picked number
  13689. */
  13690. getFactor(): number;
  13691. }
  13692. /**
  13693. * Helper used to simplify some generic gradient tasks
  13694. */
  13695. export class GradientHelper {
  13696. /**
  13697. * Gets the current gradient from an array of IValueGradient
  13698. * @param ratio defines the current ratio to get
  13699. * @param gradients defines the array of IValueGradient
  13700. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13701. */
  13702. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13703. }
  13704. }
  13705. declare module BABYLON {
  13706. interface ThinEngine {
  13707. /**
  13708. * Creates a raw texture
  13709. * @param data defines the data to store in the texture
  13710. * @param width defines the width of the texture
  13711. * @param height defines the height of the texture
  13712. * @param format defines the format of the data
  13713. * @param generateMipMaps defines if the engine should generate the mip levels
  13714. * @param invertY defines if data must be stored with Y axis inverted
  13715. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13716. * @param compression defines the compression used (null by default)
  13717. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13718. * @returns the raw texture inside an InternalTexture
  13719. */
  13720. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13721. /**
  13722. * Update a raw texture
  13723. * @param texture defines the texture to update
  13724. * @param data defines the data to store in the texture
  13725. * @param format defines the format of the data
  13726. * @param invertY defines if data must be stored with Y axis inverted
  13727. */
  13728. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13729. /**
  13730. * Update a raw texture
  13731. * @param texture defines the texture to update
  13732. * @param data defines the data to store in the texture
  13733. * @param format defines the format of the data
  13734. * @param invertY defines if data must be stored with Y axis inverted
  13735. * @param compression defines the compression used (null by default)
  13736. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13737. */
  13738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13739. /**
  13740. * Creates a new raw cube texture
  13741. * @param data defines the array of data to use to create each face
  13742. * @param size defines the size of the textures
  13743. * @param format defines the format of the data
  13744. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13745. * @param generateMipMaps defines if the engine should generate the mip levels
  13746. * @param invertY defines if data must be stored with Y axis inverted
  13747. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13748. * @param compression defines the compression used (null by default)
  13749. * @returns the cube texture as an InternalTexture
  13750. */
  13751. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13752. /**
  13753. * Update a raw cube texture
  13754. * @param texture defines the texture to udpdate
  13755. * @param data defines the data to store
  13756. * @param format defines the data format
  13757. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13758. * @param invertY defines if data must be stored with Y axis inverted
  13759. */
  13760. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13761. /**
  13762. * Update a raw cube texture
  13763. * @param texture defines the texture to udpdate
  13764. * @param data defines the data to store
  13765. * @param format defines the data format
  13766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13767. * @param invertY defines if data must be stored with Y axis inverted
  13768. * @param compression defines the compression used (null by default)
  13769. */
  13770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13771. /**
  13772. * Update a raw cube texture
  13773. * @param texture defines the texture to udpdate
  13774. * @param data defines the data to store
  13775. * @param format defines the data format
  13776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13777. * @param invertY defines if data must be stored with Y axis inverted
  13778. * @param compression defines the compression used (null by default)
  13779. * @param level defines which level of the texture to update
  13780. */
  13781. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13782. /**
  13783. * Creates a new raw cube texture from a specified url
  13784. * @param url defines the url where the data is located
  13785. * @param scene defines the current scene
  13786. * @param size defines the size of the textures
  13787. * @param format defines the format of the data
  13788. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13789. * @param noMipmap defines if the engine should avoid generating the mip levels
  13790. * @param callback defines a callback used to extract texture data from loaded data
  13791. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13792. * @param onLoad defines a callback called when texture is loaded
  13793. * @param onError defines a callback called if there is an error
  13794. * @returns the cube texture as an InternalTexture
  13795. */
  13796. 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;
  13797. /**
  13798. * Creates a new raw cube texture from a specified url
  13799. * @param url defines the url where the data is located
  13800. * @param scene defines the current scene
  13801. * @param size defines the size of the textures
  13802. * @param format defines the format of the data
  13803. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13804. * @param noMipmap defines if the engine should avoid generating the mip levels
  13805. * @param callback defines a callback used to extract texture data from loaded data
  13806. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13807. * @param onLoad defines a callback called when texture is loaded
  13808. * @param onError defines a callback called if there is an error
  13809. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13810. * @param invertY defines if data must be stored with Y axis inverted
  13811. * @returns the cube texture as an InternalTexture
  13812. */
  13813. 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;
  13814. /**
  13815. * Creates a new raw 3D texture
  13816. * @param data defines the data used to create the texture
  13817. * @param width defines the width of the texture
  13818. * @param height defines the height of the texture
  13819. * @param depth defines the depth of the texture
  13820. * @param format defines the format of the texture
  13821. * @param generateMipMaps defines if the engine must generate mip levels
  13822. * @param invertY defines if data must be stored with Y axis inverted
  13823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13824. * @param compression defines the compressed used (can be null)
  13825. * @param textureType defines the compressed used (can be null)
  13826. * @returns a new raw 3D texture (stored in an InternalTexture)
  13827. */
  13828. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13829. /**
  13830. * Update a raw 3D texture
  13831. * @param texture defines the texture to update
  13832. * @param data defines the data to store
  13833. * @param format defines the data format
  13834. * @param invertY defines if data must be stored with Y axis inverted
  13835. */
  13836. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13837. /**
  13838. * Update a raw 3D texture
  13839. * @param texture defines the texture to update
  13840. * @param data defines the data to store
  13841. * @param format defines the data format
  13842. * @param invertY defines if data must be stored with Y axis inverted
  13843. * @param compression defines the used compression (can be null)
  13844. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13845. */
  13846. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13847. /**
  13848. * Creates a new raw 2D array texture
  13849. * @param data defines the data used to create the texture
  13850. * @param width defines the width of the texture
  13851. * @param height defines the height of the texture
  13852. * @param depth defines the number of layers of the texture
  13853. * @param format defines the format of the texture
  13854. * @param generateMipMaps defines if the engine must generate mip levels
  13855. * @param invertY defines if data must be stored with Y axis inverted
  13856. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13857. * @param compression defines the compressed used (can be null)
  13858. * @param textureType defines the compressed used (can be null)
  13859. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13860. */
  13861. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13862. /**
  13863. * Update a raw 2D array texture
  13864. * @param texture defines the texture to update
  13865. * @param data defines the data to store
  13866. * @param format defines the data format
  13867. * @param invertY defines if data must be stored with Y axis inverted
  13868. */
  13869. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13870. /**
  13871. * Update a raw 2D array texture
  13872. * @param texture defines the texture to update
  13873. * @param data defines the data to store
  13874. * @param format defines the data format
  13875. * @param invertY defines if data must be stored with Y axis inverted
  13876. * @param compression defines the used compression (can be null)
  13877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13878. */
  13879. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13880. }
  13881. }
  13882. declare module BABYLON {
  13883. /**
  13884. * Raw texture can help creating a texture directly from an array of data.
  13885. * This can be super useful if you either get the data from an uncompressed source or
  13886. * if you wish to create your texture pixel by pixel.
  13887. */
  13888. export class RawTexture extends Texture {
  13889. /**
  13890. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13891. */
  13892. format: number;
  13893. /**
  13894. * Instantiates a new RawTexture.
  13895. * Raw texture can help creating a texture directly from an array of data.
  13896. * This can be super useful if you either get the data from an uncompressed source or
  13897. * if you wish to create your texture pixel by pixel.
  13898. * @param data define the array of data to use to create the texture
  13899. * @param width define the width of the texture
  13900. * @param height define the height of the texture
  13901. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13902. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13903. * @param generateMipMaps define whether mip maps should be generated or not
  13904. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13905. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13906. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13907. */
  13908. constructor(data: ArrayBufferView, width: number, height: number,
  13909. /**
  13910. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13911. */
  13912. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13913. /**
  13914. * Updates the texture underlying data.
  13915. * @param data Define the new data of the texture
  13916. */
  13917. update(data: ArrayBufferView): void;
  13918. /**
  13919. * Creates a luminance texture from some data.
  13920. * @param data Define the texture data
  13921. * @param width Define the width of the texture
  13922. * @param height Define the height of the texture
  13923. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13924. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13925. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13926. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13927. * @returns the luminance texture
  13928. */
  13929. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13930. /**
  13931. * Creates a luminance alpha texture from some data.
  13932. * @param data Define the texture data
  13933. * @param width Define the width of the texture
  13934. * @param height Define the height of the texture
  13935. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13936. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13939. * @returns the luminance alpha texture
  13940. */
  13941. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13942. /**
  13943. * Creates an alpha texture from some data.
  13944. * @param data Define the texture data
  13945. * @param width Define the width of the texture
  13946. * @param height Define the height of the texture
  13947. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13948. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13949. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13950. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13951. * @returns the alpha texture
  13952. */
  13953. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13954. /**
  13955. * Creates a RGB texture from some data.
  13956. * @param data Define the texture data
  13957. * @param width Define the width of the texture
  13958. * @param height Define the height of the texture
  13959. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13960. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13961. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13962. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13963. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13964. * @returns the RGB alpha texture
  13965. */
  13966. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13967. /**
  13968. * Creates a RGBA texture from some data.
  13969. * @param data Define the texture data
  13970. * @param width Define the width of the texture
  13971. * @param height Define the height of the texture
  13972. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13973. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13974. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13975. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13976. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13977. * @returns the RGBA texture
  13978. */
  13979. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13980. /**
  13981. * Creates a R texture from some data.
  13982. * @param data Define the texture data
  13983. * @param width Define the width of the texture
  13984. * @param height Define the height of the texture
  13985. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13986. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13987. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13988. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13989. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13990. * @returns the R texture
  13991. */
  13992. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13993. }
  13994. }
  13995. declare module BABYLON {
  13996. interface ThinEngine {
  13997. /**
  13998. * Update a dynamic index buffer
  13999. * @param indexBuffer defines the target index buffer
  14000. * @param indices defines the data to update
  14001. * @param offset defines the offset in the target index buffer where update should start
  14002. */
  14003. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14004. /**
  14005. * Updates a dynamic vertex buffer.
  14006. * @param vertexBuffer the vertex buffer to update
  14007. * @param data the data used to update the vertex buffer
  14008. * @param byteOffset the byte offset of the data
  14009. * @param byteLength the byte length of the data
  14010. */
  14011. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14012. }
  14013. }
  14014. declare module BABYLON {
  14015. interface AbstractScene {
  14016. /**
  14017. * The list of procedural textures added to the scene
  14018. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14019. */
  14020. proceduralTextures: Array<ProceduralTexture>;
  14021. }
  14022. /**
  14023. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14024. * in a given scene.
  14025. */
  14026. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14027. /**
  14028. * The component name helpfull to identify the component in the list of scene components.
  14029. */
  14030. readonly name: string;
  14031. /**
  14032. * The scene the component belongs to.
  14033. */
  14034. scene: Scene;
  14035. /**
  14036. * Creates a new instance of the component for the given scene
  14037. * @param scene Defines the scene to register the component in
  14038. */
  14039. constructor(scene: Scene);
  14040. /**
  14041. * Registers the component in a given scene
  14042. */
  14043. register(): void;
  14044. /**
  14045. * Rebuilds the elements related to this component in case of
  14046. * context lost for instance.
  14047. */
  14048. rebuild(): void;
  14049. /**
  14050. * Disposes the component and the associated ressources.
  14051. */
  14052. dispose(): void;
  14053. private _beforeClear;
  14054. }
  14055. }
  14056. declare module BABYLON {
  14057. interface ThinEngine {
  14058. /**
  14059. * Creates a new render target cube texture
  14060. * @param size defines the size of the texture
  14061. * @param options defines the options used to create the texture
  14062. * @returns a new render target cube texture stored in an InternalTexture
  14063. */
  14064. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14065. }
  14066. }
  14067. declare module BABYLON {
  14068. /** @hidden */
  14069. export var proceduralVertexShader: {
  14070. name: string;
  14071. shader: string;
  14072. };
  14073. }
  14074. declare module BABYLON {
  14075. /**
  14076. * 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.
  14077. * This is the base class of any Procedural texture and contains most of the shareable code.
  14078. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14079. */
  14080. export class ProceduralTexture extends Texture {
  14081. /**
  14082. * Define if the texture is enabled or not (disabled texture will not render)
  14083. */
  14084. isEnabled: boolean;
  14085. /**
  14086. * Define if the texture must be cleared before rendering (default is true)
  14087. */
  14088. autoClear: boolean;
  14089. /**
  14090. * Callback called when the texture is generated
  14091. */
  14092. onGenerated: () => void;
  14093. /**
  14094. * Event raised when the texture is generated
  14095. */
  14096. onGeneratedObservable: Observable<ProceduralTexture>;
  14097. /**
  14098. * Event raised before the texture is generated
  14099. */
  14100. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14101. /**
  14102. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14103. */
  14104. nodeMaterialSource: Nullable<NodeMaterial>;
  14105. /** @hidden */
  14106. _generateMipMaps: boolean;
  14107. /** @hidden **/
  14108. _effect: Effect;
  14109. /** @hidden */
  14110. _textures: {
  14111. [key: string]: Texture;
  14112. };
  14113. /** @hidden */
  14114. protected _fallbackTexture: Nullable<Texture>;
  14115. private _size;
  14116. private _currentRefreshId;
  14117. private _frameId;
  14118. private _refreshRate;
  14119. private _vertexBuffers;
  14120. private _indexBuffer;
  14121. private _uniforms;
  14122. private _samplers;
  14123. private _fragment;
  14124. private _floats;
  14125. private _ints;
  14126. private _floatsArrays;
  14127. private _colors3;
  14128. private _colors4;
  14129. private _vectors2;
  14130. private _vectors3;
  14131. private _matrices;
  14132. private _fallbackTextureUsed;
  14133. private _fullEngine;
  14134. private _cachedDefines;
  14135. private _contentUpdateId;
  14136. private _contentData;
  14137. /**
  14138. * Instantiates a new procedural texture.
  14139. * 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.
  14140. * This is the base class of any Procedural texture and contains most of the shareable code.
  14141. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14142. * @param name Define the name of the texture
  14143. * @param size Define the size of the texture to create
  14144. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14145. * @param scene Define the scene the texture belongs to
  14146. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14147. * @param generateMipMaps Define if the texture should creates mip maps or not
  14148. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14149. * @param textureType The FBO internal texture type
  14150. */
  14151. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14152. /**
  14153. * The effect that is created when initializing the post process.
  14154. * @returns The created effect corresponding the the postprocess.
  14155. */
  14156. getEffect(): Effect;
  14157. /**
  14158. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14159. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14160. */
  14161. getContent(): Nullable<ArrayBufferView>;
  14162. private _createIndexBuffer;
  14163. /** @hidden */
  14164. _rebuild(): void;
  14165. /**
  14166. * Resets the texture in order to recreate its associated resources.
  14167. * This can be called in case of context loss
  14168. */
  14169. reset(): void;
  14170. protected _getDefines(): string;
  14171. /**
  14172. * Is the texture ready to be used ? (rendered at least once)
  14173. * @returns true if ready, otherwise, false.
  14174. */
  14175. isReady(): boolean;
  14176. /**
  14177. * Resets the refresh counter of the texture and start bak from scratch.
  14178. * Could be useful to regenerate the texture if it is setup to render only once.
  14179. */
  14180. resetRefreshCounter(): void;
  14181. /**
  14182. * Set the fragment shader to use in order to render the texture.
  14183. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14184. */
  14185. setFragment(fragment: any): void;
  14186. /**
  14187. * Define the refresh rate of the texture or the rendering frequency.
  14188. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14189. */
  14190. get refreshRate(): number;
  14191. set refreshRate(value: number);
  14192. /** @hidden */
  14193. _shouldRender(): boolean;
  14194. /**
  14195. * Get the size the texture is rendering at.
  14196. * @returns the size (on cube texture it is always squared)
  14197. */
  14198. getRenderSize(): RenderTargetTextureSize;
  14199. /**
  14200. * Resize the texture to new value.
  14201. * @param size Define the new size the texture should have
  14202. * @param generateMipMaps Define whether the new texture should create mip maps
  14203. */
  14204. resize(size: number, generateMipMaps: boolean): void;
  14205. private _checkUniform;
  14206. /**
  14207. * Set a texture in the shader program used to render.
  14208. * @param name Define the name of the uniform samplers as defined in the shader
  14209. * @param texture Define the texture to bind to this sampler
  14210. * @return the texture itself allowing "fluent" like uniform updates
  14211. */
  14212. setTexture(name: string, texture: Texture): ProceduralTexture;
  14213. /**
  14214. * Set a float in the shader.
  14215. * @param name Define the name of the uniform as defined in the shader
  14216. * @param value Define the value to give to the uniform
  14217. * @return the texture itself allowing "fluent" like uniform updates
  14218. */
  14219. setFloat(name: string, value: number): ProceduralTexture;
  14220. /**
  14221. * Set a int in the shader.
  14222. * @param name Define the name of the uniform as defined in the shader
  14223. * @param value Define the value to give to the uniform
  14224. * @return the texture itself allowing "fluent" like uniform updates
  14225. */
  14226. setInt(name: string, value: number): ProceduralTexture;
  14227. /**
  14228. * Set an array of floats in the shader.
  14229. * @param name Define the name of the uniform as defined in the shader
  14230. * @param value Define the value to give to the uniform
  14231. * @return the texture itself allowing "fluent" like uniform updates
  14232. */
  14233. setFloats(name: string, value: number[]): ProceduralTexture;
  14234. /**
  14235. * Set a vec3 in the shader from a Color3.
  14236. * @param name Define the name of the uniform as defined in the shader
  14237. * @param value Define the value to give to the uniform
  14238. * @return the texture itself allowing "fluent" like uniform updates
  14239. */
  14240. setColor3(name: string, value: Color3): ProceduralTexture;
  14241. /**
  14242. * Set a vec4 in the shader from a Color4.
  14243. * @param name Define the name of the uniform as defined in the shader
  14244. * @param value Define the value to give to the uniform
  14245. * @return the texture itself allowing "fluent" like uniform updates
  14246. */
  14247. setColor4(name: string, value: Color4): ProceduralTexture;
  14248. /**
  14249. * Set a vec2 in the shader from a Vector2.
  14250. * @param name Define the name of the uniform as defined in the shader
  14251. * @param value Define the value to give to the uniform
  14252. * @return the texture itself allowing "fluent" like uniform updates
  14253. */
  14254. setVector2(name: string, value: Vector2): ProceduralTexture;
  14255. /**
  14256. * Set a vec3 in the shader from a Vector3.
  14257. * @param name Define the name of the uniform as defined in the shader
  14258. * @param value Define the value to give to the uniform
  14259. * @return the texture itself allowing "fluent" like uniform updates
  14260. */
  14261. setVector3(name: string, value: Vector3): ProceduralTexture;
  14262. /**
  14263. * Set a mat4 in the shader from a MAtrix.
  14264. * @param name Define the name of the uniform as defined in the shader
  14265. * @param value Define the value to give to the uniform
  14266. * @return the texture itself allowing "fluent" like uniform updates
  14267. */
  14268. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14269. /**
  14270. * Render the texture to its associated render target.
  14271. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14272. */
  14273. render(useCameraPostProcess?: boolean): void;
  14274. /**
  14275. * Clone the texture.
  14276. * @returns the cloned texture
  14277. */
  14278. clone(): ProceduralTexture;
  14279. /**
  14280. * Dispose the texture and release its asoociated resources.
  14281. */
  14282. dispose(): void;
  14283. }
  14284. }
  14285. declare module BABYLON {
  14286. /**
  14287. * This represents the base class for particle system in Babylon.
  14288. * 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.
  14289. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14290. * @example https://doc.babylonjs.com/babylon101/particles
  14291. */
  14292. export class BaseParticleSystem {
  14293. /**
  14294. * Source color is added to the destination color without alpha affecting the result
  14295. */
  14296. static BLENDMODE_ONEONE: number;
  14297. /**
  14298. * Blend current color and particle color using particle’s alpha
  14299. */
  14300. static BLENDMODE_STANDARD: number;
  14301. /**
  14302. * Add current color and particle color multiplied by particle’s alpha
  14303. */
  14304. static BLENDMODE_ADD: number;
  14305. /**
  14306. * Multiply current color with particle color
  14307. */
  14308. static BLENDMODE_MULTIPLY: number;
  14309. /**
  14310. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14311. */
  14312. static BLENDMODE_MULTIPLYADD: number;
  14313. /**
  14314. * List of animations used by the particle system.
  14315. */
  14316. animations: Animation[];
  14317. /**
  14318. * Gets or sets the unique id of the particle system
  14319. */
  14320. uniqueId: number;
  14321. /**
  14322. * The id of the Particle system.
  14323. */
  14324. id: string;
  14325. /**
  14326. * The friendly name of the Particle system.
  14327. */
  14328. name: string;
  14329. /**
  14330. * Snippet ID if the particle system was created from the snippet server
  14331. */
  14332. snippetId: string;
  14333. /**
  14334. * The rendering group used by the Particle system to chose when to render.
  14335. */
  14336. renderingGroupId: number;
  14337. /**
  14338. * The emitter represents the Mesh or position we are attaching the particle system to.
  14339. */
  14340. emitter: Nullable<AbstractMesh | Vector3>;
  14341. /**
  14342. * The maximum number of particles to emit per frame
  14343. */
  14344. emitRate: number;
  14345. /**
  14346. * If you want to launch only a few particles at once, that can be done, as well.
  14347. */
  14348. manualEmitCount: number;
  14349. /**
  14350. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14351. */
  14352. updateSpeed: number;
  14353. /**
  14354. * The amount of time the particle system is running (depends of the overall update speed).
  14355. */
  14356. targetStopDuration: number;
  14357. /**
  14358. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14359. */
  14360. disposeOnStop: boolean;
  14361. /**
  14362. * Minimum power of emitting particles.
  14363. */
  14364. minEmitPower: number;
  14365. /**
  14366. * Maximum power of emitting particles.
  14367. */
  14368. maxEmitPower: number;
  14369. /**
  14370. * Minimum life time of emitting particles.
  14371. */
  14372. minLifeTime: number;
  14373. /**
  14374. * Maximum life time of emitting particles.
  14375. */
  14376. maxLifeTime: number;
  14377. /**
  14378. * Minimum Size of emitting particles.
  14379. */
  14380. minSize: number;
  14381. /**
  14382. * Maximum Size of emitting particles.
  14383. */
  14384. maxSize: number;
  14385. /**
  14386. * Minimum scale of emitting particles on X axis.
  14387. */
  14388. minScaleX: number;
  14389. /**
  14390. * Maximum scale of emitting particles on X axis.
  14391. */
  14392. maxScaleX: number;
  14393. /**
  14394. * Minimum scale of emitting particles on Y axis.
  14395. */
  14396. minScaleY: number;
  14397. /**
  14398. * Maximum scale of emitting particles on Y axis.
  14399. */
  14400. maxScaleY: number;
  14401. /**
  14402. * Gets or sets the minimal initial rotation in radians.
  14403. */
  14404. minInitialRotation: number;
  14405. /**
  14406. * Gets or sets the maximal initial rotation in radians.
  14407. */
  14408. maxInitialRotation: number;
  14409. /**
  14410. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14411. */
  14412. minAngularSpeed: number;
  14413. /**
  14414. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14415. */
  14416. maxAngularSpeed: number;
  14417. /**
  14418. * The texture used to render each particle. (this can be a spritesheet)
  14419. */
  14420. particleTexture: Nullable<BaseTexture>;
  14421. /**
  14422. * The layer mask we are rendering the particles through.
  14423. */
  14424. layerMask: number;
  14425. /**
  14426. * This can help using your own shader to render the particle system.
  14427. * The according effect will be created
  14428. */
  14429. customShader: any;
  14430. /**
  14431. * By default particle system starts as soon as they are created. This prevents the
  14432. * automatic start to happen and let you decide when to start emitting particles.
  14433. */
  14434. preventAutoStart: boolean;
  14435. private _noiseTexture;
  14436. /**
  14437. * Gets or sets a texture used to add random noise to particle positions
  14438. */
  14439. get noiseTexture(): Nullable<ProceduralTexture>;
  14440. set noiseTexture(value: Nullable<ProceduralTexture>);
  14441. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14442. noiseStrength: Vector3;
  14443. /**
  14444. * Callback triggered when the particle animation is ending.
  14445. */
  14446. onAnimationEnd: Nullable<() => void>;
  14447. /**
  14448. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14449. */
  14450. blendMode: number;
  14451. /**
  14452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14453. * to override the particles.
  14454. */
  14455. forceDepthWrite: boolean;
  14456. /** 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 */
  14457. preWarmCycles: number;
  14458. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14459. preWarmStepOffset: number;
  14460. /**
  14461. * 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)
  14462. */
  14463. spriteCellChangeSpeed: number;
  14464. /**
  14465. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14466. */
  14467. startSpriteCellID: number;
  14468. /**
  14469. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14470. */
  14471. endSpriteCellID: number;
  14472. /**
  14473. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14474. */
  14475. spriteCellWidth: number;
  14476. /**
  14477. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14478. */
  14479. spriteCellHeight: number;
  14480. /**
  14481. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14482. */
  14483. spriteRandomStartCell: boolean;
  14484. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14485. translationPivot: Vector2;
  14486. /** @hidden */
  14487. protected _isAnimationSheetEnabled: boolean;
  14488. /**
  14489. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14490. */
  14491. beginAnimationOnStart: boolean;
  14492. /**
  14493. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14494. */
  14495. beginAnimationFrom: number;
  14496. /**
  14497. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14498. */
  14499. beginAnimationTo: number;
  14500. /**
  14501. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14502. */
  14503. beginAnimationLoop: boolean;
  14504. /**
  14505. * Gets or sets a world offset applied to all particles
  14506. */
  14507. worldOffset: Vector3;
  14508. /**
  14509. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14510. */
  14511. get isAnimationSheetEnabled(): boolean;
  14512. set isAnimationSheetEnabled(value: boolean);
  14513. /**
  14514. * Get hosting scene
  14515. * @returns the scene
  14516. */
  14517. getScene(): Nullable<Scene>;
  14518. /**
  14519. * You can use gravity if you want to give an orientation to your particles.
  14520. */
  14521. gravity: Vector3;
  14522. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14523. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14524. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14525. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14526. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14527. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14528. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14529. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14530. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14531. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14532. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14533. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14534. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14535. /**
  14536. * Defines the delay in milliseconds before starting the system (0 by default)
  14537. */
  14538. startDelay: number;
  14539. /**
  14540. * Gets the current list of drag gradients.
  14541. * You must use addDragGradient and removeDragGradient to udpate this list
  14542. * @returns the list of drag gradients
  14543. */
  14544. getDragGradients(): Nullable<Array<FactorGradient>>;
  14545. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14546. limitVelocityDamping: number;
  14547. /**
  14548. * Gets the current list of limit velocity gradients.
  14549. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14550. * @returns the list of limit velocity gradients
  14551. */
  14552. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14553. /**
  14554. * Gets the current list of color gradients.
  14555. * You must use addColorGradient and removeColorGradient to udpate this list
  14556. * @returns the list of color gradients
  14557. */
  14558. getColorGradients(): Nullable<Array<ColorGradient>>;
  14559. /**
  14560. * Gets the current list of size gradients.
  14561. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14562. * @returns the list of size gradients
  14563. */
  14564. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14565. /**
  14566. * Gets the current list of color remap gradients.
  14567. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14568. * @returns the list of color remap gradients
  14569. */
  14570. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14571. /**
  14572. * Gets the current list of alpha remap gradients.
  14573. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14574. * @returns the list of alpha remap gradients
  14575. */
  14576. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14577. /**
  14578. * Gets the current list of life time gradients.
  14579. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14580. * @returns the list of life time gradients
  14581. */
  14582. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14583. /**
  14584. * Gets the current list of angular speed gradients.
  14585. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14586. * @returns the list of angular speed gradients
  14587. */
  14588. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14589. /**
  14590. * Gets the current list of velocity gradients.
  14591. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14592. * @returns the list of velocity gradients
  14593. */
  14594. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14595. /**
  14596. * Gets the current list of start size gradients.
  14597. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14598. * @returns the list of start size gradients
  14599. */
  14600. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14601. /**
  14602. * Gets the current list of emit rate gradients.
  14603. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14604. * @returns the list of emit rate gradients
  14605. */
  14606. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14607. /**
  14608. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14610. */
  14611. get direction1(): Vector3;
  14612. set direction1(value: Vector3);
  14613. /**
  14614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14615. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14616. */
  14617. get direction2(): Vector3;
  14618. set direction2(value: Vector3);
  14619. /**
  14620. * 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.
  14621. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14622. */
  14623. get minEmitBox(): Vector3;
  14624. set minEmitBox(value: Vector3);
  14625. /**
  14626. * 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.
  14627. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14628. */
  14629. get maxEmitBox(): Vector3;
  14630. set maxEmitBox(value: Vector3);
  14631. /**
  14632. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14633. */
  14634. color1: Color4;
  14635. /**
  14636. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14637. */
  14638. color2: Color4;
  14639. /**
  14640. * Color the particle will have at the end of its lifetime
  14641. */
  14642. colorDead: Color4;
  14643. /**
  14644. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14645. */
  14646. textureMask: Color4;
  14647. /**
  14648. * The particle emitter type defines the emitter used by the particle system.
  14649. * It can be for example box, sphere, or cone...
  14650. */
  14651. particleEmitterType: IParticleEmitterType;
  14652. /** @hidden */
  14653. _isSubEmitter: boolean;
  14654. /**
  14655. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14656. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14657. */
  14658. billboardMode: number;
  14659. protected _isBillboardBased: boolean;
  14660. /**
  14661. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14662. */
  14663. get isBillboardBased(): boolean;
  14664. set isBillboardBased(value: boolean);
  14665. /**
  14666. * The scene the particle system belongs to.
  14667. */
  14668. protected _scene: Nullable<Scene>;
  14669. /**
  14670. * The engine the particle system belongs to.
  14671. */
  14672. protected _engine: ThinEngine;
  14673. /**
  14674. * Local cache of defines for image processing.
  14675. */
  14676. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14677. /**
  14678. * Default configuration related to image processing available in the standard Material.
  14679. */
  14680. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14681. /**
  14682. * Gets the image processing configuration used either in this material.
  14683. */
  14684. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14685. /**
  14686. * Sets the Default image processing configuration used either in the this material.
  14687. *
  14688. * If sets to null, the scene one is in use.
  14689. */
  14690. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14691. /**
  14692. * Attaches a new image processing configuration to the Standard Material.
  14693. * @param configuration
  14694. */
  14695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14696. /** @hidden */
  14697. protected _reset(): void;
  14698. /** @hidden */
  14699. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14700. /**
  14701. * Instantiates a particle system.
  14702. * 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.
  14703. * @param name The name of the particle system
  14704. */
  14705. constructor(name: string);
  14706. /**
  14707. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @returns the emitter
  14711. */
  14712. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14713. /**
  14714. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14715. * @param radius The radius of the hemisphere to emit from
  14716. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14717. * @returns the emitter
  14718. */
  14719. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14720. /**
  14721. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14722. * @param radius The radius of the sphere to emit from
  14723. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14724. * @returns the emitter
  14725. */
  14726. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14727. /**
  14728. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14729. * @param radius The radius of the sphere to emit from
  14730. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14731. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14732. * @returns the emitter
  14733. */
  14734. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14735. /**
  14736. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14737. * @param radius The radius of the emission cylinder
  14738. * @param height The height of the emission cylinder
  14739. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14740. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14741. * @returns the emitter
  14742. */
  14743. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14744. /**
  14745. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14746. * @param radius The radius of the cylinder to emit from
  14747. * @param height The height of the emission cylinder
  14748. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14751. * @returns the emitter
  14752. */
  14753. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14754. /**
  14755. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14756. * @param radius The radius of the cone to emit from
  14757. * @param angle The base angle of the cone
  14758. * @returns the emitter
  14759. */
  14760. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14761. /**
  14762. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14765. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14766. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14767. * @returns the emitter
  14768. */
  14769. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14770. }
  14771. }
  14772. declare module BABYLON {
  14773. /**
  14774. * Type of sub emitter
  14775. */
  14776. export enum SubEmitterType {
  14777. /**
  14778. * Attached to the particle over it's lifetime
  14779. */
  14780. ATTACHED = 0,
  14781. /**
  14782. * Created when the particle dies
  14783. */
  14784. END = 1
  14785. }
  14786. /**
  14787. * Sub emitter class used to emit particles from an existing particle
  14788. */
  14789. export class SubEmitter {
  14790. /**
  14791. * the particle system to be used by the sub emitter
  14792. */
  14793. particleSystem: ParticleSystem;
  14794. /**
  14795. * Type of the submitter (Default: END)
  14796. */
  14797. type: SubEmitterType;
  14798. /**
  14799. * 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)
  14800. * Note: This only is supported when using an emitter of type Mesh
  14801. */
  14802. inheritDirection: boolean;
  14803. /**
  14804. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14805. */
  14806. inheritedVelocityAmount: number;
  14807. /**
  14808. * Creates a sub emitter
  14809. * @param particleSystem the particle system to be used by the sub emitter
  14810. */
  14811. constructor(
  14812. /**
  14813. * the particle system to be used by the sub emitter
  14814. */
  14815. particleSystem: ParticleSystem);
  14816. /**
  14817. * Clones the sub emitter
  14818. * @returns the cloned sub emitter
  14819. */
  14820. clone(): SubEmitter;
  14821. /**
  14822. * Serialize current object to a JSON object
  14823. * @returns the serialized object
  14824. */
  14825. serialize(): any;
  14826. /** @hidden */
  14827. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14828. /**
  14829. * Creates a new SubEmitter from a serialized JSON version
  14830. * @param serializationObject defines the JSON object to read from
  14831. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14832. * @param rootUrl defines the rootUrl for data loading
  14833. * @returns a new SubEmitter
  14834. */
  14835. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14836. /** Release associated resources */
  14837. dispose(): void;
  14838. }
  14839. }
  14840. declare module BABYLON {
  14841. /** @hidden */
  14842. export var clipPlaneFragmentDeclaration: {
  14843. name: string;
  14844. shader: string;
  14845. };
  14846. }
  14847. declare module BABYLON {
  14848. /** @hidden */
  14849. export var imageProcessingDeclaration: {
  14850. name: string;
  14851. shader: string;
  14852. };
  14853. }
  14854. declare module BABYLON {
  14855. /** @hidden */
  14856. export var imageProcessingFunctions: {
  14857. name: string;
  14858. shader: string;
  14859. };
  14860. }
  14861. declare module BABYLON {
  14862. /** @hidden */
  14863. export var clipPlaneFragment: {
  14864. name: string;
  14865. shader: string;
  14866. };
  14867. }
  14868. declare module BABYLON {
  14869. /** @hidden */
  14870. export var particlesPixelShader: {
  14871. name: string;
  14872. shader: string;
  14873. };
  14874. }
  14875. declare module BABYLON {
  14876. /** @hidden */
  14877. export var clipPlaneVertexDeclaration: {
  14878. name: string;
  14879. shader: string;
  14880. };
  14881. }
  14882. declare module BABYLON {
  14883. /** @hidden */
  14884. export var clipPlaneVertex: {
  14885. name: string;
  14886. shader: string;
  14887. };
  14888. }
  14889. declare module BABYLON {
  14890. /** @hidden */
  14891. export var particlesVertexShader: {
  14892. name: string;
  14893. shader: string;
  14894. };
  14895. }
  14896. declare module BABYLON {
  14897. /**
  14898. * Interface used to define entities containing multiple clip planes
  14899. */
  14900. export interface IClipPlanesHolder {
  14901. /**
  14902. * Gets or sets the active clipplane 1
  14903. */
  14904. clipPlane: Nullable<Plane>;
  14905. /**
  14906. * Gets or sets the active clipplane 2
  14907. */
  14908. clipPlane2: Nullable<Plane>;
  14909. /**
  14910. * Gets or sets the active clipplane 3
  14911. */
  14912. clipPlane3: Nullable<Plane>;
  14913. /**
  14914. * Gets or sets the active clipplane 4
  14915. */
  14916. clipPlane4: Nullable<Plane>;
  14917. /**
  14918. * Gets or sets the active clipplane 5
  14919. */
  14920. clipPlane5: Nullable<Plane>;
  14921. /**
  14922. * Gets or sets the active clipplane 6
  14923. */
  14924. clipPlane6: Nullable<Plane>;
  14925. }
  14926. }
  14927. declare module BABYLON {
  14928. /**
  14929. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14930. *
  14931. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14932. *
  14933. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14934. */
  14935. export class ThinMaterialHelper {
  14936. /**
  14937. * Binds the clip plane information from the holder to the effect.
  14938. * @param effect The effect we are binding the data to
  14939. * @param holder The entity containing the clip plane information
  14940. */
  14941. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14942. }
  14943. }
  14944. declare module BABYLON {
  14945. interface ThinEngine {
  14946. /**
  14947. * Sets alpha constants used by some alpha blending modes
  14948. * @param r defines the red component
  14949. * @param g defines the green component
  14950. * @param b defines the blue component
  14951. * @param a defines the alpha component
  14952. */
  14953. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14954. /**
  14955. * Sets the current alpha mode
  14956. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14957. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14958. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14959. */
  14960. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14961. /**
  14962. * Gets the current alpha mode
  14963. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14964. * @returns the current alpha mode
  14965. */
  14966. getAlphaMode(): number;
  14967. /**
  14968. * Sets the current alpha equation
  14969. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14970. */
  14971. setAlphaEquation(equation: number): void;
  14972. /**
  14973. * Gets the current alpha equation.
  14974. * @returns the current alpha equation
  14975. */
  14976. getAlphaEquation(): number;
  14977. }
  14978. }
  14979. declare module BABYLON {
  14980. /**
  14981. * This represents a particle system in Babylon.
  14982. * 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.
  14983. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14984. * @example https://doc.babylonjs.com/babylon101/particles
  14985. */
  14986. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14987. /**
  14988. * Billboard mode will only apply to Y axis
  14989. */
  14990. static readonly BILLBOARDMODE_Y: number;
  14991. /**
  14992. * Billboard mode will apply to all axes
  14993. */
  14994. static readonly BILLBOARDMODE_ALL: number;
  14995. /**
  14996. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14997. */
  14998. static readonly BILLBOARDMODE_STRETCHED: number;
  14999. /**
  15000. * This function can be defined to provide custom update for active particles.
  15001. * This function will be called instead of regular update (age, position, color, etc.).
  15002. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15003. */
  15004. updateFunction: (particles: Particle[]) => void;
  15005. private _emitterWorldMatrix;
  15006. /**
  15007. * This function can be defined to specify initial direction for every new particle.
  15008. * It by default use the emitterType defined function
  15009. */
  15010. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15011. /**
  15012. * This function can be defined to specify initial position for every new particle.
  15013. * It by default use the emitterType defined function
  15014. */
  15015. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15016. /**
  15017. * @hidden
  15018. */
  15019. _inheritedVelocityOffset: Vector3;
  15020. /**
  15021. * An event triggered when the system is disposed
  15022. */
  15023. onDisposeObservable: Observable<IParticleSystem>;
  15024. /**
  15025. * An event triggered when the system is stopped
  15026. */
  15027. onStoppedObservable: Observable<IParticleSystem>;
  15028. private _onDisposeObserver;
  15029. /**
  15030. * Sets a callback that will be triggered when the system is disposed
  15031. */
  15032. set onDispose(callback: () => void);
  15033. private _particles;
  15034. private _epsilon;
  15035. private _capacity;
  15036. private _stockParticles;
  15037. private _newPartsExcess;
  15038. private _vertexData;
  15039. private _vertexBuffer;
  15040. private _vertexBuffers;
  15041. private _spriteBuffer;
  15042. private _indexBuffer;
  15043. private _effect;
  15044. private _customEffect;
  15045. private _cachedDefines;
  15046. private _scaledColorStep;
  15047. private _colorDiff;
  15048. private _scaledDirection;
  15049. private _scaledGravity;
  15050. private _currentRenderId;
  15051. private _alive;
  15052. private _useInstancing;
  15053. private _vertexArrayObject;
  15054. private _started;
  15055. private _stopped;
  15056. private _actualFrame;
  15057. private _scaledUpdateSpeed;
  15058. private _vertexBufferSize;
  15059. /** @hidden */
  15060. _currentEmitRateGradient: Nullable<FactorGradient>;
  15061. /** @hidden */
  15062. _currentEmitRate1: number;
  15063. /** @hidden */
  15064. _currentEmitRate2: number;
  15065. /** @hidden */
  15066. _currentStartSizeGradient: Nullable<FactorGradient>;
  15067. /** @hidden */
  15068. _currentStartSize1: number;
  15069. /** @hidden */
  15070. _currentStartSize2: number;
  15071. private readonly _rawTextureWidth;
  15072. private _rampGradientsTexture;
  15073. private _useRampGradients;
  15074. /** Gets or sets a matrix to use to compute projection */
  15075. defaultProjectionMatrix: Matrix;
  15076. /** Gets or sets a matrix to use to compute view */
  15077. defaultViewMatrix: Matrix;
  15078. /** Gets or sets a boolean indicating that ramp gradients must be used
  15079. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15080. */
  15081. get useRampGradients(): boolean;
  15082. set useRampGradients(value: boolean);
  15083. /**
  15084. * 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.
  15085. * 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: [])
  15086. */
  15087. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15088. private _subEmitters;
  15089. /**
  15090. * @hidden
  15091. * If the particle systems emitter should be disposed when the particle system is disposed
  15092. */
  15093. _disposeEmitterOnDispose: boolean;
  15094. /**
  15095. * The current active Sub-systems, this property is used by the root particle system only.
  15096. */
  15097. activeSubSystems: Array<ParticleSystem>;
  15098. /**
  15099. * Specifies if the particles are updated in emitter local space or world space
  15100. */
  15101. isLocal: boolean;
  15102. private _rootParticleSystem;
  15103. /**
  15104. * Gets the current list of active particles
  15105. */
  15106. get particles(): Particle[];
  15107. /**
  15108. * Gets the number of particles active at the same time.
  15109. * @returns The number of active particles.
  15110. */
  15111. getActiveCount(): number;
  15112. /**
  15113. * Returns the string "ParticleSystem"
  15114. * @returns a string containing the class name
  15115. */
  15116. getClassName(): string;
  15117. /**
  15118. * Gets a boolean indicating that the system is stopping
  15119. * @returns true if the system is currently stopping
  15120. */
  15121. isStopping(): boolean;
  15122. /**
  15123. * Gets the custom effect used to render the particles
  15124. * @param blendMode Blend mode for which the effect should be retrieved
  15125. * @returns The effect
  15126. */
  15127. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15128. /**
  15129. * Sets the custom effect used to render the particles
  15130. * @param effect The effect to set
  15131. * @param blendMode Blend mode for which the effect should be set
  15132. */
  15133. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15134. /** @hidden */
  15135. private _onBeforeDrawParticlesObservable;
  15136. /**
  15137. * Observable that will be called just before the particles are drawn
  15138. */
  15139. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15140. /**
  15141. * Gets the name of the particle vertex shader
  15142. */
  15143. get vertexShaderName(): string;
  15144. /**
  15145. * Instantiates a particle system.
  15146. * 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.
  15147. * @param name The name of the particle system
  15148. * @param capacity The max number of particles alive at the same time
  15149. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15150. * @param customEffect a custom effect used to change the way particles are rendered by default
  15151. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15152. * @param epsilon Offset used to render the particles
  15153. */
  15154. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15155. private _addFactorGradient;
  15156. private _removeFactorGradient;
  15157. /**
  15158. * Adds a new life time gradient
  15159. * @param gradient defines the gradient to use (between 0 and 1)
  15160. * @param factor defines the life time factor to affect to the specified gradient
  15161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15162. * @returns the current particle system
  15163. */
  15164. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15165. /**
  15166. * Remove a specific life time gradient
  15167. * @param gradient defines the gradient to remove
  15168. * @returns the current particle system
  15169. */
  15170. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15171. /**
  15172. * Adds a new size gradient
  15173. * @param gradient defines the gradient to use (between 0 and 1)
  15174. * @param factor defines the size factor to affect to the specified gradient
  15175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15176. * @returns the current particle system
  15177. */
  15178. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15179. /**
  15180. * Remove a specific size gradient
  15181. * @param gradient defines the gradient to remove
  15182. * @returns the current particle system
  15183. */
  15184. removeSizeGradient(gradient: number): IParticleSystem;
  15185. /**
  15186. * Adds a new color remap gradient
  15187. * @param gradient defines the gradient to use (between 0 and 1)
  15188. * @param min defines the color remap minimal range
  15189. * @param max defines the color remap maximal range
  15190. * @returns the current particle system
  15191. */
  15192. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15193. /**
  15194. * Remove a specific color remap gradient
  15195. * @param gradient defines the gradient to remove
  15196. * @returns the current particle system
  15197. */
  15198. removeColorRemapGradient(gradient: number): IParticleSystem;
  15199. /**
  15200. * Adds a new alpha remap gradient
  15201. * @param gradient defines the gradient to use (between 0 and 1)
  15202. * @param min defines the alpha remap minimal range
  15203. * @param max defines the alpha remap maximal range
  15204. * @returns the current particle system
  15205. */
  15206. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15207. /**
  15208. * Remove a specific alpha remap gradient
  15209. * @param gradient defines the gradient to remove
  15210. * @returns the current particle system
  15211. */
  15212. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15213. /**
  15214. * Adds a new angular speed gradient
  15215. * @param gradient defines the gradient to use (between 0 and 1)
  15216. * @param factor defines the angular speed to affect to the specified gradient
  15217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15218. * @returns the current particle system
  15219. */
  15220. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15221. /**
  15222. * Remove a specific angular speed gradient
  15223. * @param gradient defines the gradient to remove
  15224. * @returns the current particle system
  15225. */
  15226. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15227. /**
  15228. * Adds a new velocity gradient
  15229. * @param gradient defines the gradient to use (between 0 and 1)
  15230. * @param factor defines the velocity to affect to the specified gradient
  15231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15232. * @returns the current particle system
  15233. */
  15234. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15235. /**
  15236. * Remove a specific velocity gradient
  15237. * @param gradient defines the gradient to remove
  15238. * @returns the current particle system
  15239. */
  15240. removeVelocityGradient(gradient: number): IParticleSystem;
  15241. /**
  15242. * Adds a new limit velocity gradient
  15243. * @param gradient defines the gradient to use (between 0 and 1)
  15244. * @param factor defines the limit velocity value to affect to the specified gradient
  15245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15246. * @returns the current particle system
  15247. */
  15248. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15249. /**
  15250. * Remove a specific limit velocity gradient
  15251. * @param gradient defines the gradient to remove
  15252. * @returns the current particle system
  15253. */
  15254. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15255. /**
  15256. * Adds a new drag gradient
  15257. * @param gradient defines the gradient to use (between 0 and 1)
  15258. * @param factor defines the drag value to affect to the specified gradient
  15259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15260. * @returns the current particle system
  15261. */
  15262. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15263. /**
  15264. * Remove a specific drag gradient
  15265. * @param gradient defines the gradient to remove
  15266. * @returns the current particle system
  15267. */
  15268. removeDragGradient(gradient: number): IParticleSystem;
  15269. /**
  15270. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15271. * @param gradient defines the gradient to use (between 0 and 1)
  15272. * @param factor defines the emit rate value to affect to the specified gradient
  15273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15274. * @returns the current particle system
  15275. */
  15276. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15277. /**
  15278. * Remove a specific emit rate gradient
  15279. * @param gradient defines the gradient to remove
  15280. * @returns the current particle system
  15281. */
  15282. removeEmitRateGradient(gradient: number): IParticleSystem;
  15283. /**
  15284. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15285. * @param gradient defines the gradient to use (between 0 and 1)
  15286. * @param factor defines the start size value to affect to the specified gradient
  15287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15288. * @returns the current particle system
  15289. */
  15290. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15291. /**
  15292. * Remove a specific start size gradient
  15293. * @param gradient defines the gradient to remove
  15294. * @returns the current particle system
  15295. */
  15296. removeStartSizeGradient(gradient: number): IParticleSystem;
  15297. private _createRampGradientTexture;
  15298. /**
  15299. * Gets the current list of ramp gradients.
  15300. * You must use addRampGradient and removeRampGradient to udpate this list
  15301. * @returns the list of ramp gradients
  15302. */
  15303. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15304. /** Force the system to rebuild all gradients that need to be resync */
  15305. forceRefreshGradients(): void;
  15306. private _syncRampGradientTexture;
  15307. /**
  15308. * Adds a new ramp gradient used to remap particle colors
  15309. * @param gradient defines the gradient to use (between 0 and 1)
  15310. * @param color defines the color to affect to the specified gradient
  15311. * @returns the current particle system
  15312. */
  15313. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15314. /**
  15315. * Remove a specific ramp gradient
  15316. * @param gradient defines the gradient to remove
  15317. * @returns the current particle system
  15318. */
  15319. removeRampGradient(gradient: number): ParticleSystem;
  15320. /**
  15321. * Adds a new color gradient
  15322. * @param gradient defines the gradient to use (between 0 and 1)
  15323. * @param color1 defines the color to affect to the specified gradient
  15324. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15325. * @returns this particle system
  15326. */
  15327. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15328. /**
  15329. * Remove a specific color gradient
  15330. * @param gradient defines the gradient to remove
  15331. * @returns this particle system
  15332. */
  15333. removeColorGradient(gradient: number): IParticleSystem;
  15334. private _fetchR;
  15335. protected _reset(): void;
  15336. private _resetEffect;
  15337. private _createVertexBuffers;
  15338. private _createIndexBuffer;
  15339. /**
  15340. * Gets the maximum number of particles active at the same time.
  15341. * @returns The max number of active particles.
  15342. */
  15343. getCapacity(): number;
  15344. /**
  15345. * Gets whether there are still active particles in the system.
  15346. * @returns True if it is alive, otherwise false.
  15347. */
  15348. isAlive(): boolean;
  15349. /**
  15350. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15351. * @returns True if it has been started, otherwise false.
  15352. */
  15353. isStarted(): boolean;
  15354. private _prepareSubEmitterInternalArray;
  15355. /**
  15356. * Starts the particle system and begins to emit
  15357. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15358. */
  15359. start(delay?: number): void;
  15360. /**
  15361. * Stops the particle system.
  15362. * @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.
  15363. */
  15364. stop(stopSubEmitters?: boolean): void;
  15365. /**
  15366. * Remove all active particles
  15367. */
  15368. reset(): void;
  15369. /**
  15370. * @hidden (for internal use only)
  15371. */
  15372. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15373. /**
  15374. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15375. * Its lifetime will start back at 0.
  15376. */
  15377. recycleParticle: (particle: Particle) => void;
  15378. private _stopSubEmitters;
  15379. private _createParticle;
  15380. private _removeFromRoot;
  15381. private _emitFromParticle;
  15382. private _update;
  15383. /** @hidden */
  15384. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15385. /** @hidden */
  15386. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15387. /**
  15388. * Fill the defines array according to the current settings of the particle system
  15389. * @param defines Array to be updated
  15390. * @param blendMode blend mode to take into account when updating the array
  15391. */
  15392. fillDefines(defines: Array<string>, blendMode: number): void;
  15393. /**
  15394. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15395. * @param uniforms Uniforms array to fill
  15396. * @param attributes Attributes array to fill
  15397. * @param samplers Samplers array to fill
  15398. */
  15399. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15400. /** @hidden */
  15401. private _getEffect;
  15402. /**
  15403. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15404. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15405. */
  15406. animate(preWarmOnly?: boolean): void;
  15407. private _appendParticleVertices;
  15408. /**
  15409. * Rebuilds the particle system.
  15410. */
  15411. rebuild(): void;
  15412. /**
  15413. * Is this system ready to be used/rendered
  15414. * @return true if the system is ready
  15415. */
  15416. isReady(): boolean;
  15417. private _render;
  15418. /**
  15419. * Renders the particle system in its current state.
  15420. * @returns the current number of particles
  15421. */
  15422. render(): number;
  15423. /**
  15424. * Disposes the particle system and free the associated resources
  15425. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15426. */
  15427. dispose(disposeTexture?: boolean): void;
  15428. /**
  15429. * Clones the particle system.
  15430. * @param name The name of the cloned object
  15431. * @param newEmitter The new emitter to use
  15432. * @returns the cloned particle system
  15433. */
  15434. clone(name: string, newEmitter: any): ParticleSystem;
  15435. /**
  15436. * Serializes the particle system to a JSON object
  15437. * @param serializeTexture defines if the texture must be serialized as well
  15438. * @returns the JSON object
  15439. */
  15440. serialize(serializeTexture?: boolean): any;
  15441. /** @hidden */
  15442. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15443. /** @hidden */
  15444. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15445. /**
  15446. * Parses a JSON object to create a particle system.
  15447. * @param parsedParticleSystem The JSON object to parse
  15448. * @param sceneOrEngine The scene or the engine to create the particle system in
  15449. * @param rootUrl The root url to use to load external dependencies like texture
  15450. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15451. * @returns the Parsed particle system
  15452. */
  15453. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15454. }
  15455. }
  15456. declare module BABYLON {
  15457. /**
  15458. * A particle represents one of the element emitted by a particle system.
  15459. * This is mainly define by its coordinates, direction, velocity and age.
  15460. */
  15461. export class Particle {
  15462. /**
  15463. * The particle system the particle belongs to.
  15464. */
  15465. particleSystem: ParticleSystem;
  15466. private static _Count;
  15467. /**
  15468. * Unique ID of the particle
  15469. */
  15470. id: number;
  15471. /**
  15472. * The world position of the particle in the scene.
  15473. */
  15474. position: Vector3;
  15475. /**
  15476. * The world direction of the particle in the scene.
  15477. */
  15478. direction: Vector3;
  15479. /**
  15480. * The color of the particle.
  15481. */
  15482. color: Color4;
  15483. /**
  15484. * The color change of the particle per step.
  15485. */
  15486. colorStep: Color4;
  15487. /**
  15488. * Defines how long will the life of the particle be.
  15489. */
  15490. lifeTime: number;
  15491. /**
  15492. * The current age of the particle.
  15493. */
  15494. age: number;
  15495. /**
  15496. * The current size of the particle.
  15497. */
  15498. size: number;
  15499. /**
  15500. * The current scale of the particle.
  15501. */
  15502. scale: Vector2;
  15503. /**
  15504. * The current angle of the particle.
  15505. */
  15506. angle: number;
  15507. /**
  15508. * Defines how fast is the angle changing.
  15509. */
  15510. angularSpeed: number;
  15511. /**
  15512. * Defines the cell index used by the particle to be rendered from a sprite.
  15513. */
  15514. cellIndex: number;
  15515. /**
  15516. * The information required to support color remapping
  15517. */
  15518. remapData: Vector4;
  15519. /** @hidden */
  15520. _randomCellOffset?: number;
  15521. /** @hidden */
  15522. _initialDirection: Nullable<Vector3>;
  15523. /** @hidden */
  15524. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15525. /** @hidden */
  15526. _initialStartSpriteCellID: number;
  15527. /** @hidden */
  15528. _initialEndSpriteCellID: number;
  15529. /** @hidden */
  15530. _currentColorGradient: Nullable<ColorGradient>;
  15531. /** @hidden */
  15532. _currentColor1: Color4;
  15533. /** @hidden */
  15534. _currentColor2: Color4;
  15535. /** @hidden */
  15536. _currentSizeGradient: Nullable<FactorGradient>;
  15537. /** @hidden */
  15538. _currentSize1: number;
  15539. /** @hidden */
  15540. _currentSize2: number;
  15541. /** @hidden */
  15542. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15543. /** @hidden */
  15544. _currentAngularSpeed1: number;
  15545. /** @hidden */
  15546. _currentAngularSpeed2: number;
  15547. /** @hidden */
  15548. _currentVelocityGradient: Nullable<FactorGradient>;
  15549. /** @hidden */
  15550. _currentVelocity1: number;
  15551. /** @hidden */
  15552. _currentVelocity2: number;
  15553. /** @hidden */
  15554. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15555. /** @hidden */
  15556. _currentLimitVelocity1: number;
  15557. /** @hidden */
  15558. _currentLimitVelocity2: number;
  15559. /** @hidden */
  15560. _currentDragGradient: Nullable<FactorGradient>;
  15561. /** @hidden */
  15562. _currentDrag1: number;
  15563. /** @hidden */
  15564. _currentDrag2: number;
  15565. /** @hidden */
  15566. _randomNoiseCoordinates1: Vector3;
  15567. /** @hidden */
  15568. _randomNoiseCoordinates2: Vector3;
  15569. /** @hidden */
  15570. _localPosition?: Vector3;
  15571. /**
  15572. * Creates a new instance Particle
  15573. * @param particleSystem the particle system the particle belongs to
  15574. */
  15575. constructor(
  15576. /**
  15577. * The particle system the particle belongs to.
  15578. */
  15579. particleSystem: ParticleSystem);
  15580. private updateCellInfoFromSystem;
  15581. /**
  15582. * Defines how the sprite cell index is updated for the particle
  15583. */
  15584. updateCellIndex(): void;
  15585. /** @hidden */
  15586. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15587. /** @hidden */
  15588. _inheritParticleInfoToSubEmitters(): void;
  15589. /** @hidden */
  15590. _reset(): void;
  15591. /**
  15592. * Copy the properties of particle to another one.
  15593. * @param other the particle to copy the information to.
  15594. */
  15595. copyTo(other: Particle): void;
  15596. }
  15597. }
  15598. declare module BABYLON {
  15599. /**
  15600. * Particle emitter represents a volume emitting particles.
  15601. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15602. */
  15603. export interface IParticleEmitterType {
  15604. /**
  15605. * Called by the particle System when the direction is computed for the created particle.
  15606. * @param worldMatrix is the world matrix of the particle system
  15607. * @param directionToUpdate is the direction vector to update with the result
  15608. * @param particle is the particle we are computed the direction for
  15609. * @param isLocal defines if the direction should be set in local space
  15610. */
  15611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15612. /**
  15613. * Called by the particle System when the position is computed for the created particle.
  15614. * @param worldMatrix is the world matrix of the particle system
  15615. * @param positionToUpdate is the position vector to update with the result
  15616. * @param particle is the particle we are computed the position for
  15617. * @param isLocal defines if the position should be set in local space
  15618. */
  15619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15620. /**
  15621. * Clones the current emitter and returns a copy of it
  15622. * @returns the new emitter
  15623. */
  15624. clone(): IParticleEmitterType;
  15625. /**
  15626. * Called by the GPUParticleSystem to setup the update shader
  15627. * @param effect defines the update shader
  15628. */
  15629. applyToShader(effect: Effect): void;
  15630. /**
  15631. * Returns a string to use to update the GPU particles update shader
  15632. * @returns the effect defines string
  15633. */
  15634. getEffectDefines(): string;
  15635. /**
  15636. * Returns a string representing the class name
  15637. * @returns a string containing the class name
  15638. */
  15639. getClassName(): string;
  15640. /**
  15641. * Serializes the particle system to a JSON object.
  15642. * @returns the JSON object
  15643. */
  15644. serialize(): any;
  15645. /**
  15646. * Parse properties from a JSON object
  15647. * @param serializationObject defines the JSON object
  15648. * @param scene defines the hosting scene
  15649. */
  15650. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15651. }
  15652. }
  15653. declare module BABYLON {
  15654. /**
  15655. * Particle emitter emitting particles from the inside of a box.
  15656. * It emits the particles randomly between 2 given directions.
  15657. */
  15658. export class BoxParticleEmitter implements IParticleEmitterType {
  15659. /**
  15660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15661. */
  15662. direction1: Vector3;
  15663. /**
  15664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15665. */
  15666. direction2: Vector3;
  15667. /**
  15668. * 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.
  15669. */
  15670. minEmitBox: Vector3;
  15671. /**
  15672. * 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.
  15673. */
  15674. maxEmitBox: Vector3;
  15675. /**
  15676. * Creates a new instance BoxParticleEmitter
  15677. */
  15678. constructor();
  15679. /**
  15680. * Called by the particle System when the direction is computed for the created particle.
  15681. * @param worldMatrix is the world matrix of the particle system
  15682. * @param directionToUpdate is the direction vector to update with the result
  15683. * @param particle is the particle we are computed the direction for
  15684. * @param isLocal defines if the direction should be set in local space
  15685. */
  15686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15687. /**
  15688. * Called by the particle System when the position is computed for the created particle.
  15689. * @param worldMatrix is the world matrix of the particle system
  15690. * @param positionToUpdate is the position vector to update with the result
  15691. * @param particle is the particle we are computed the position for
  15692. * @param isLocal defines if the position should be set in local space
  15693. */
  15694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15695. /**
  15696. * Clones the current emitter and returns a copy of it
  15697. * @returns the new emitter
  15698. */
  15699. clone(): BoxParticleEmitter;
  15700. /**
  15701. * Called by the GPUParticleSystem to setup the update shader
  15702. * @param effect defines the update shader
  15703. */
  15704. applyToShader(effect: Effect): void;
  15705. /**
  15706. * Returns a string to use to update the GPU particles update shader
  15707. * @returns a string containng the defines string
  15708. */
  15709. getEffectDefines(): string;
  15710. /**
  15711. * Returns the string "BoxParticleEmitter"
  15712. * @returns a string containing the class name
  15713. */
  15714. getClassName(): string;
  15715. /**
  15716. * Serializes the particle system to a JSON object.
  15717. * @returns the JSON object
  15718. */
  15719. serialize(): any;
  15720. /**
  15721. * Parse properties from a JSON object
  15722. * @param serializationObject defines the JSON object
  15723. */
  15724. parse(serializationObject: any): void;
  15725. }
  15726. }
  15727. declare module BABYLON {
  15728. /**
  15729. * Particle emitter emitting particles from the inside of a cone.
  15730. * It emits the particles alongside the cone volume from the base to the particle.
  15731. * The emission direction might be randomized.
  15732. */
  15733. export class ConeParticleEmitter implements IParticleEmitterType {
  15734. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15735. directionRandomizer: number;
  15736. private _radius;
  15737. private _angle;
  15738. private _height;
  15739. /**
  15740. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15741. */
  15742. radiusRange: number;
  15743. /**
  15744. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15745. */
  15746. heightRange: number;
  15747. /**
  15748. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15749. */
  15750. emitFromSpawnPointOnly: boolean;
  15751. /**
  15752. * Gets or sets the radius of the emission cone
  15753. */
  15754. get radius(): number;
  15755. set radius(value: number);
  15756. /**
  15757. * Gets or sets the angle of the emission cone
  15758. */
  15759. get angle(): number;
  15760. set angle(value: number);
  15761. private _buildHeight;
  15762. /**
  15763. * Creates a new instance ConeParticleEmitter
  15764. * @param radius the radius of the emission cone (1 by default)
  15765. * @param angle the cone base angle (PI by default)
  15766. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15767. */
  15768. constructor(radius?: number, angle?: number,
  15769. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15770. directionRandomizer?: number);
  15771. /**
  15772. * Called by the particle System when the direction is computed for the created particle.
  15773. * @param worldMatrix is the world matrix of the particle system
  15774. * @param directionToUpdate is the direction vector to update with the result
  15775. * @param particle is the particle we are computed the direction for
  15776. * @param isLocal defines if the direction should be set in local space
  15777. */
  15778. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15779. /**
  15780. * Called by the particle System when the position is computed for the created particle.
  15781. * @param worldMatrix is the world matrix of the particle system
  15782. * @param positionToUpdate is the position vector to update with the result
  15783. * @param particle is the particle we are computed the position for
  15784. * @param isLocal defines if the position should be set in local space
  15785. */
  15786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15787. /**
  15788. * Clones the current emitter and returns a copy of it
  15789. * @returns the new emitter
  15790. */
  15791. clone(): ConeParticleEmitter;
  15792. /**
  15793. * Called by the GPUParticleSystem to setup the update shader
  15794. * @param effect defines the update shader
  15795. */
  15796. applyToShader(effect: Effect): void;
  15797. /**
  15798. * Returns a string to use to update the GPU particles update shader
  15799. * @returns a string containng the defines string
  15800. */
  15801. getEffectDefines(): string;
  15802. /**
  15803. * Returns the string "ConeParticleEmitter"
  15804. * @returns a string containing the class name
  15805. */
  15806. getClassName(): string;
  15807. /**
  15808. * Serializes the particle system to a JSON object.
  15809. * @returns the JSON object
  15810. */
  15811. serialize(): any;
  15812. /**
  15813. * Parse properties from a JSON object
  15814. * @param serializationObject defines the JSON object
  15815. */
  15816. parse(serializationObject: any): void;
  15817. }
  15818. }
  15819. declare module BABYLON {
  15820. /**
  15821. * Particle emitter emitting particles from the inside of a cylinder.
  15822. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15823. */
  15824. export class CylinderParticleEmitter implements IParticleEmitterType {
  15825. /**
  15826. * The radius of the emission cylinder.
  15827. */
  15828. radius: number;
  15829. /**
  15830. * The height of the emission cylinder.
  15831. */
  15832. height: number;
  15833. /**
  15834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15835. */
  15836. radiusRange: number;
  15837. /**
  15838. * How much to randomize the particle direction [0-1].
  15839. */
  15840. directionRandomizer: number;
  15841. /**
  15842. * Creates a new instance CylinderParticleEmitter
  15843. * @param radius the radius of the emission cylinder (1 by default)
  15844. * @param height the height of the emission cylinder (1 by default)
  15845. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15846. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15847. */
  15848. constructor(
  15849. /**
  15850. * The radius of the emission cylinder.
  15851. */
  15852. radius?: number,
  15853. /**
  15854. * The height of the emission cylinder.
  15855. */
  15856. height?: number,
  15857. /**
  15858. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15859. */
  15860. radiusRange?: number,
  15861. /**
  15862. * How much to randomize the particle direction [0-1].
  15863. */
  15864. directionRandomizer?: number);
  15865. /**
  15866. * Called by the particle System when the direction is computed for the created particle.
  15867. * @param worldMatrix is the world matrix of the particle system
  15868. * @param directionToUpdate is the direction vector to update with the result
  15869. * @param particle is the particle we are computed the direction for
  15870. * @param isLocal defines if the direction should be set in local space
  15871. */
  15872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15873. /**
  15874. * Called by the particle System when the position is computed for the created particle.
  15875. * @param worldMatrix is the world matrix of the particle system
  15876. * @param positionToUpdate is the position vector to update with the result
  15877. * @param particle is the particle we are computed the position for
  15878. * @param isLocal defines if the position should be set in local space
  15879. */
  15880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15881. /**
  15882. * Clones the current emitter and returns a copy of it
  15883. * @returns the new emitter
  15884. */
  15885. clone(): CylinderParticleEmitter;
  15886. /**
  15887. * Called by the GPUParticleSystem to setup the update shader
  15888. * @param effect defines the update shader
  15889. */
  15890. applyToShader(effect: Effect): void;
  15891. /**
  15892. * Returns a string to use to update the GPU particles update shader
  15893. * @returns a string containng the defines string
  15894. */
  15895. getEffectDefines(): string;
  15896. /**
  15897. * Returns the string "CylinderParticleEmitter"
  15898. * @returns a string containing the class name
  15899. */
  15900. getClassName(): string;
  15901. /**
  15902. * Serializes the particle system to a JSON object.
  15903. * @returns the JSON object
  15904. */
  15905. serialize(): any;
  15906. /**
  15907. * Parse properties from a JSON object
  15908. * @param serializationObject defines the JSON object
  15909. */
  15910. parse(serializationObject: any): void;
  15911. }
  15912. /**
  15913. * Particle emitter emitting particles from the inside of a cylinder.
  15914. * It emits the particles randomly between two vectors.
  15915. */
  15916. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15917. /**
  15918. * The min limit of the emission direction.
  15919. */
  15920. direction1: Vector3;
  15921. /**
  15922. * The max limit of the emission direction.
  15923. */
  15924. direction2: Vector3;
  15925. /**
  15926. * Creates a new instance CylinderDirectedParticleEmitter
  15927. * @param radius the radius of the emission cylinder (1 by default)
  15928. * @param height the height of the emission cylinder (1 by default)
  15929. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15930. * @param direction1 the min limit of the emission direction (up vector by default)
  15931. * @param direction2 the max limit of the emission direction (up vector by default)
  15932. */
  15933. constructor(radius?: number, height?: number, radiusRange?: number,
  15934. /**
  15935. * The min limit of the emission direction.
  15936. */
  15937. direction1?: Vector3,
  15938. /**
  15939. * The max limit of the emission direction.
  15940. */
  15941. direction2?: Vector3);
  15942. /**
  15943. * Called by the particle System when the direction is computed for the created particle.
  15944. * @param worldMatrix is the world matrix of the particle system
  15945. * @param directionToUpdate is the direction vector to update with the result
  15946. * @param particle is the particle we are computed the direction for
  15947. */
  15948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15949. /**
  15950. * Clones the current emitter and returns a copy of it
  15951. * @returns the new emitter
  15952. */
  15953. clone(): CylinderDirectedParticleEmitter;
  15954. /**
  15955. * Called by the GPUParticleSystem to setup the update shader
  15956. * @param effect defines the update shader
  15957. */
  15958. applyToShader(effect: Effect): void;
  15959. /**
  15960. * Returns a string to use to update the GPU particles update shader
  15961. * @returns a string containng the defines string
  15962. */
  15963. getEffectDefines(): string;
  15964. /**
  15965. * Returns the string "CylinderDirectedParticleEmitter"
  15966. * @returns a string containing the class name
  15967. */
  15968. getClassName(): string;
  15969. /**
  15970. * Serializes the particle system to a JSON object.
  15971. * @returns the JSON object
  15972. */
  15973. serialize(): any;
  15974. /**
  15975. * Parse properties from a JSON object
  15976. * @param serializationObject defines the JSON object
  15977. */
  15978. parse(serializationObject: any): void;
  15979. }
  15980. }
  15981. declare module BABYLON {
  15982. /**
  15983. * Particle emitter emitting particles from the inside of a hemisphere.
  15984. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15985. */
  15986. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15987. /**
  15988. * The radius of the emission hemisphere.
  15989. */
  15990. radius: number;
  15991. /**
  15992. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15993. */
  15994. radiusRange: number;
  15995. /**
  15996. * How much to randomize the particle direction [0-1].
  15997. */
  15998. directionRandomizer: number;
  15999. /**
  16000. * Creates a new instance HemisphericParticleEmitter
  16001. * @param radius the radius of the emission hemisphere (1 by default)
  16002. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16003. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16004. */
  16005. constructor(
  16006. /**
  16007. * The radius of the emission hemisphere.
  16008. */
  16009. radius?: number,
  16010. /**
  16011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16012. */
  16013. radiusRange?: number,
  16014. /**
  16015. * How much to randomize the particle direction [0-1].
  16016. */
  16017. directionRandomizer?: number);
  16018. /**
  16019. * Called by the particle System when the direction is computed for the created particle.
  16020. * @param worldMatrix is the world matrix of the particle system
  16021. * @param directionToUpdate is the direction vector to update with the result
  16022. * @param particle is the particle we are computed the direction for
  16023. * @param isLocal defines if the direction should be set in local space
  16024. */
  16025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16026. /**
  16027. * Called by the particle System when the position is computed for the created particle.
  16028. * @param worldMatrix is the world matrix of the particle system
  16029. * @param positionToUpdate is the position vector to update with the result
  16030. * @param particle is the particle we are computed the position for
  16031. * @param isLocal defines if the position should be set in local space
  16032. */
  16033. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16034. /**
  16035. * Clones the current emitter and returns a copy of it
  16036. * @returns the new emitter
  16037. */
  16038. clone(): HemisphericParticleEmitter;
  16039. /**
  16040. * Called by the GPUParticleSystem to setup the update shader
  16041. * @param effect defines the update shader
  16042. */
  16043. applyToShader(effect: Effect): void;
  16044. /**
  16045. * Returns a string to use to update the GPU particles update shader
  16046. * @returns a string containng the defines string
  16047. */
  16048. getEffectDefines(): string;
  16049. /**
  16050. * Returns the string "HemisphericParticleEmitter"
  16051. * @returns a string containing the class name
  16052. */
  16053. getClassName(): string;
  16054. /**
  16055. * Serializes the particle system to a JSON object.
  16056. * @returns the JSON object
  16057. */
  16058. serialize(): any;
  16059. /**
  16060. * Parse properties from a JSON object
  16061. * @param serializationObject defines the JSON object
  16062. */
  16063. parse(serializationObject: any): void;
  16064. }
  16065. }
  16066. declare module BABYLON {
  16067. /**
  16068. * Particle emitter emitting particles from a point.
  16069. * It emits the particles randomly between 2 given directions.
  16070. */
  16071. export class PointParticleEmitter implements IParticleEmitterType {
  16072. /**
  16073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16074. */
  16075. direction1: Vector3;
  16076. /**
  16077. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16078. */
  16079. direction2: Vector3;
  16080. /**
  16081. * Creates a new instance PointParticleEmitter
  16082. */
  16083. constructor();
  16084. /**
  16085. * Called by the particle System when the direction is computed for the created particle.
  16086. * @param worldMatrix is the world matrix of the particle system
  16087. * @param directionToUpdate is the direction vector to update with the result
  16088. * @param particle is the particle we are computed the direction for
  16089. * @param isLocal defines if the direction should be set in local space
  16090. */
  16091. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16092. /**
  16093. * Called by the particle System when the position is computed for the created particle.
  16094. * @param worldMatrix is the world matrix of the particle system
  16095. * @param positionToUpdate is the position vector to update with the result
  16096. * @param particle is the particle we are computed the position for
  16097. * @param isLocal defines if the position should be set in local space
  16098. */
  16099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16100. /**
  16101. * Clones the current emitter and returns a copy of it
  16102. * @returns the new emitter
  16103. */
  16104. clone(): PointParticleEmitter;
  16105. /**
  16106. * Called by the GPUParticleSystem to setup the update shader
  16107. * @param effect defines the update shader
  16108. */
  16109. applyToShader(effect: Effect): void;
  16110. /**
  16111. * Returns a string to use to update the GPU particles update shader
  16112. * @returns a string containng the defines string
  16113. */
  16114. getEffectDefines(): string;
  16115. /**
  16116. * Returns the string "PointParticleEmitter"
  16117. * @returns a string containing the class name
  16118. */
  16119. getClassName(): string;
  16120. /**
  16121. * Serializes the particle system to a JSON object.
  16122. * @returns the JSON object
  16123. */
  16124. serialize(): any;
  16125. /**
  16126. * Parse properties from a JSON object
  16127. * @param serializationObject defines the JSON object
  16128. */
  16129. parse(serializationObject: any): void;
  16130. }
  16131. }
  16132. declare module BABYLON {
  16133. /**
  16134. * Particle emitter emitting particles from the inside of a sphere.
  16135. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16136. */
  16137. export class SphereParticleEmitter implements IParticleEmitterType {
  16138. /**
  16139. * The radius of the emission sphere.
  16140. */
  16141. radius: number;
  16142. /**
  16143. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16144. */
  16145. radiusRange: number;
  16146. /**
  16147. * How much to randomize the particle direction [0-1].
  16148. */
  16149. directionRandomizer: number;
  16150. /**
  16151. * Creates a new instance SphereParticleEmitter
  16152. * @param radius the radius of the emission sphere (1 by default)
  16153. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16154. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16155. */
  16156. constructor(
  16157. /**
  16158. * The radius of the emission sphere.
  16159. */
  16160. radius?: number,
  16161. /**
  16162. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16163. */
  16164. radiusRange?: number,
  16165. /**
  16166. * How much to randomize the particle direction [0-1].
  16167. */
  16168. directionRandomizer?: number);
  16169. /**
  16170. * Called by the particle System when the direction is computed for the created particle.
  16171. * @param worldMatrix is the world matrix of the particle system
  16172. * @param directionToUpdate is the direction vector to update with the result
  16173. * @param particle is the particle we are computed the direction for
  16174. * @param isLocal defines if the direction should be set in local space
  16175. */
  16176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16177. /**
  16178. * Called by the particle System when the position is computed for the created particle.
  16179. * @param worldMatrix is the world matrix of the particle system
  16180. * @param positionToUpdate is the position vector to update with the result
  16181. * @param particle is the particle we are computed the position for
  16182. * @param isLocal defines if the position should be set in local space
  16183. */
  16184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16185. /**
  16186. * Clones the current emitter and returns a copy of it
  16187. * @returns the new emitter
  16188. */
  16189. clone(): SphereParticleEmitter;
  16190. /**
  16191. * Called by the GPUParticleSystem to setup the update shader
  16192. * @param effect defines the update shader
  16193. */
  16194. applyToShader(effect: Effect): void;
  16195. /**
  16196. * Returns a string to use to update the GPU particles update shader
  16197. * @returns a string containng the defines string
  16198. */
  16199. getEffectDefines(): string;
  16200. /**
  16201. * Returns the string "SphereParticleEmitter"
  16202. * @returns a string containing the class name
  16203. */
  16204. getClassName(): string;
  16205. /**
  16206. * Serializes the particle system to a JSON object.
  16207. * @returns the JSON object
  16208. */
  16209. serialize(): any;
  16210. /**
  16211. * Parse properties from a JSON object
  16212. * @param serializationObject defines the JSON object
  16213. */
  16214. parse(serializationObject: any): void;
  16215. }
  16216. /**
  16217. * Particle emitter emitting particles from the inside of a sphere.
  16218. * It emits the particles randomly between two vectors.
  16219. */
  16220. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16221. /**
  16222. * The min limit of the emission direction.
  16223. */
  16224. direction1: Vector3;
  16225. /**
  16226. * The max limit of the emission direction.
  16227. */
  16228. direction2: Vector3;
  16229. /**
  16230. * Creates a new instance SphereDirectedParticleEmitter
  16231. * @param radius the radius of the emission sphere (1 by default)
  16232. * @param direction1 the min limit of the emission direction (up vector by default)
  16233. * @param direction2 the max limit of the emission direction (up vector by default)
  16234. */
  16235. constructor(radius?: number,
  16236. /**
  16237. * The min limit of the emission direction.
  16238. */
  16239. direction1?: Vector3,
  16240. /**
  16241. * The max limit of the emission direction.
  16242. */
  16243. direction2?: Vector3);
  16244. /**
  16245. * Called by the particle System when the direction is computed for the created particle.
  16246. * @param worldMatrix is the world matrix of the particle system
  16247. * @param directionToUpdate is the direction vector to update with the result
  16248. * @param particle is the particle we are computed the direction for
  16249. */
  16250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16251. /**
  16252. * Clones the current emitter and returns a copy of it
  16253. * @returns the new emitter
  16254. */
  16255. clone(): SphereDirectedParticleEmitter;
  16256. /**
  16257. * Called by the GPUParticleSystem to setup the update shader
  16258. * @param effect defines the update shader
  16259. */
  16260. applyToShader(effect: Effect): void;
  16261. /**
  16262. * Returns a string to use to update the GPU particles update shader
  16263. * @returns a string containng the defines string
  16264. */
  16265. getEffectDefines(): string;
  16266. /**
  16267. * Returns the string "SphereDirectedParticleEmitter"
  16268. * @returns a string containing the class name
  16269. */
  16270. getClassName(): string;
  16271. /**
  16272. * Serializes the particle system to a JSON object.
  16273. * @returns the JSON object
  16274. */
  16275. serialize(): any;
  16276. /**
  16277. * Parse properties from a JSON object
  16278. * @param serializationObject defines the JSON object
  16279. */
  16280. parse(serializationObject: any): void;
  16281. }
  16282. }
  16283. declare module BABYLON {
  16284. /**
  16285. * Particle emitter emitting particles from a custom list of positions.
  16286. */
  16287. export class CustomParticleEmitter implements IParticleEmitterType {
  16288. /**
  16289. * Gets or sets the position generator that will create the inital position of each particle.
  16290. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16291. */
  16292. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16293. /**
  16294. * Gets or sets the destination generator that will create the final destination of each particle.
  16295. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16296. */
  16297. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16298. /**
  16299. * Creates a new instance CustomParticleEmitter
  16300. */
  16301. constructor();
  16302. /**
  16303. * Called by the particle System when the direction is computed for the created particle.
  16304. * @param worldMatrix is the world matrix of the particle system
  16305. * @param directionToUpdate is the direction vector to update with the result
  16306. * @param particle is the particle we are computed the direction for
  16307. * @param isLocal defines if the direction should be set in local space
  16308. */
  16309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16310. /**
  16311. * Called by the particle System when the position is computed for the created particle.
  16312. * @param worldMatrix is the world matrix of the particle system
  16313. * @param positionToUpdate is the position vector to update with the result
  16314. * @param particle is the particle we are computed the position for
  16315. * @param isLocal defines if the position should be set in local space
  16316. */
  16317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16318. /**
  16319. * Clones the current emitter and returns a copy of it
  16320. * @returns the new emitter
  16321. */
  16322. clone(): CustomParticleEmitter;
  16323. /**
  16324. * Called by the GPUParticleSystem to setup the update shader
  16325. * @param effect defines the update shader
  16326. */
  16327. applyToShader(effect: Effect): void;
  16328. /**
  16329. * Returns a string to use to update the GPU particles update shader
  16330. * @returns a string containng the defines string
  16331. */
  16332. getEffectDefines(): string;
  16333. /**
  16334. * Returns the string "PointParticleEmitter"
  16335. * @returns a string containing the class name
  16336. */
  16337. getClassName(): string;
  16338. /**
  16339. * Serializes the particle system to a JSON object.
  16340. * @returns the JSON object
  16341. */
  16342. serialize(): any;
  16343. /**
  16344. * Parse properties from a JSON object
  16345. * @param serializationObject defines the JSON object
  16346. */
  16347. parse(serializationObject: any): void;
  16348. }
  16349. }
  16350. declare module BABYLON {
  16351. /**
  16352. * Particle emitter emitting particles from the inside of a box.
  16353. * It emits the particles randomly between 2 given directions.
  16354. */
  16355. export class MeshParticleEmitter implements IParticleEmitterType {
  16356. private _indices;
  16357. private _positions;
  16358. private _normals;
  16359. private _storedNormal;
  16360. private _mesh;
  16361. /**
  16362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16363. */
  16364. direction1: Vector3;
  16365. /**
  16366. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16367. */
  16368. direction2: Vector3;
  16369. /**
  16370. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16371. */
  16372. useMeshNormalsForDirection: boolean;
  16373. /** Defines the mesh to use as source */
  16374. get mesh(): Nullable<AbstractMesh>;
  16375. set mesh(value: Nullable<AbstractMesh>);
  16376. /**
  16377. * Creates a new instance MeshParticleEmitter
  16378. * @param mesh defines the mesh to use as source
  16379. */
  16380. constructor(mesh?: Nullable<AbstractMesh>);
  16381. /**
  16382. * Called by the particle System when the direction is computed for the created particle.
  16383. * @param worldMatrix is the world matrix of the particle system
  16384. * @param directionToUpdate is the direction vector to update with the result
  16385. * @param particle is the particle we are computed the direction for
  16386. * @param isLocal defines if the direction should be set in local space
  16387. */
  16388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16389. /**
  16390. * Called by the particle System when the position is computed for the created particle.
  16391. * @param worldMatrix is the world matrix of the particle system
  16392. * @param positionToUpdate is the position vector to update with the result
  16393. * @param particle is the particle we are computed the position for
  16394. * @param isLocal defines if the position should be set in local space
  16395. */
  16396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16397. /**
  16398. * Clones the current emitter and returns a copy of it
  16399. * @returns the new emitter
  16400. */
  16401. clone(): MeshParticleEmitter;
  16402. /**
  16403. * Called by the GPUParticleSystem to setup the update shader
  16404. * @param effect defines the update shader
  16405. */
  16406. applyToShader(effect: Effect): void;
  16407. /**
  16408. * Returns a string to use to update the GPU particles update shader
  16409. * @returns a string containng the defines string
  16410. */
  16411. getEffectDefines(): string;
  16412. /**
  16413. * Returns the string "BoxParticleEmitter"
  16414. * @returns a string containing the class name
  16415. */
  16416. getClassName(): string;
  16417. /**
  16418. * Serializes the particle system to a JSON object.
  16419. * @returns the JSON object
  16420. */
  16421. serialize(): any;
  16422. /**
  16423. * Parse properties from a JSON object
  16424. * @param serializationObject defines the JSON object
  16425. * @param scene defines the hosting scene
  16426. */
  16427. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16428. }
  16429. }
  16430. declare module BABYLON {
  16431. /**
  16432. * Interface representing a particle system in Babylon.js.
  16433. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16434. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16435. */
  16436. export interface IParticleSystem {
  16437. /**
  16438. * List of animations used by the particle system.
  16439. */
  16440. animations: Animation[];
  16441. /**
  16442. * The id of the Particle system.
  16443. */
  16444. id: string;
  16445. /**
  16446. * The name of the Particle system.
  16447. */
  16448. name: string;
  16449. /**
  16450. * The emitter represents the Mesh or position we are attaching the particle system to.
  16451. */
  16452. emitter: Nullable<AbstractMesh | Vector3>;
  16453. /**
  16454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16455. */
  16456. isBillboardBased: boolean;
  16457. /**
  16458. * The rendering group used by the Particle system to chose when to render.
  16459. */
  16460. renderingGroupId: number;
  16461. /**
  16462. * The layer mask we are rendering the particles through.
  16463. */
  16464. layerMask: number;
  16465. /**
  16466. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16467. */
  16468. updateSpeed: number;
  16469. /**
  16470. * The amount of time the particle system is running (depends of the overall update speed).
  16471. */
  16472. targetStopDuration: number;
  16473. /**
  16474. * The texture used to render each particle. (this can be a spritesheet)
  16475. */
  16476. particleTexture: Nullable<BaseTexture>;
  16477. /**
  16478. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16479. */
  16480. blendMode: number;
  16481. /**
  16482. * Minimum life time of emitting particles.
  16483. */
  16484. minLifeTime: number;
  16485. /**
  16486. * Maximum life time of emitting particles.
  16487. */
  16488. maxLifeTime: number;
  16489. /**
  16490. * Minimum Size of emitting particles.
  16491. */
  16492. minSize: number;
  16493. /**
  16494. * Maximum Size of emitting particles.
  16495. */
  16496. maxSize: number;
  16497. /**
  16498. * Minimum scale of emitting particles on X axis.
  16499. */
  16500. minScaleX: number;
  16501. /**
  16502. * Maximum scale of emitting particles on X axis.
  16503. */
  16504. maxScaleX: number;
  16505. /**
  16506. * Minimum scale of emitting particles on Y axis.
  16507. */
  16508. minScaleY: number;
  16509. /**
  16510. * Maximum scale of emitting particles on Y axis.
  16511. */
  16512. maxScaleY: number;
  16513. /**
  16514. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16515. */
  16516. color1: Color4;
  16517. /**
  16518. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16519. */
  16520. color2: Color4;
  16521. /**
  16522. * Color the particle will have at the end of its lifetime.
  16523. */
  16524. colorDead: Color4;
  16525. /**
  16526. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16527. */
  16528. emitRate: number;
  16529. /**
  16530. * You can use gravity if you want to give an orientation to your particles.
  16531. */
  16532. gravity: Vector3;
  16533. /**
  16534. * Minimum power of emitting particles.
  16535. */
  16536. minEmitPower: number;
  16537. /**
  16538. * Maximum power of emitting particles.
  16539. */
  16540. maxEmitPower: number;
  16541. /**
  16542. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16543. */
  16544. minAngularSpeed: number;
  16545. /**
  16546. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16547. */
  16548. maxAngularSpeed: number;
  16549. /**
  16550. * Gets or sets the minimal initial rotation in radians.
  16551. */
  16552. minInitialRotation: number;
  16553. /**
  16554. * Gets or sets the maximal initial rotation in radians.
  16555. */
  16556. maxInitialRotation: number;
  16557. /**
  16558. * The particle emitter type defines the emitter used by the particle system.
  16559. * It can be for example box, sphere, or cone...
  16560. */
  16561. particleEmitterType: Nullable<IParticleEmitterType>;
  16562. /**
  16563. * Defines the delay in milliseconds before starting the system (0 by default)
  16564. */
  16565. startDelay: number;
  16566. /**
  16567. * 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
  16568. */
  16569. preWarmCycles: number;
  16570. /**
  16571. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16572. */
  16573. preWarmStepOffset: number;
  16574. /**
  16575. * 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)
  16576. */
  16577. spriteCellChangeSpeed: number;
  16578. /**
  16579. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16580. */
  16581. startSpriteCellID: number;
  16582. /**
  16583. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16584. */
  16585. endSpriteCellID: number;
  16586. /**
  16587. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16588. */
  16589. spriteCellWidth: number;
  16590. /**
  16591. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16592. */
  16593. spriteCellHeight: number;
  16594. /**
  16595. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16596. */
  16597. spriteRandomStartCell: boolean;
  16598. /**
  16599. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16600. */
  16601. isAnimationSheetEnabled: boolean;
  16602. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16603. translationPivot: Vector2;
  16604. /**
  16605. * Gets or sets a texture used to add random noise to particle positions
  16606. */
  16607. noiseTexture: Nullable<BaseTexture>;
  16608. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16609. noiseStrength: Vector3;
  16610. /**
  16611. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16612. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16613. */
  16614. billboardMode: number;
  16615. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16616. limitVelocityDamping: number;
  16617. /**
  16618. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16619. */
  16620. beginAnimationOnStart: boolean;
  16621. /**
  16622. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16623. */
  16624. beginAnimationFrom: number;
  16625. /**
  16626. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16627. */
  16628. beginAnimationTo: number;
  16629. /**
  16630. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16631. */
  16632. beginAnimationLoop: boolean;
  16633. /**
  16634. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16635. */
  16636. disposeOnStop: boolean;
  16637. /**
  16638. * Specifies if the particles are updated in emitter local space or world space
  16639. */
  16640. isLocal: boolean;
  16641. /** Snippet ID if the particle system was created from the snippet server */
  16642. snippetId: string;
  16643. /** Gets or sets a matrix to use to compute projection */
  16644. defaultProjectionMatrix: Matrix;
  16645. /**
  16646. * Gets the maximum number of particles active at the same time.
  16647. * @returns The max number of active particles.
  16648. */
  16649. getCapacity(): number;
  16650. /**
  16651. * Gets the number of particles active at the same time.
  16652. * @returns The number of active particles.
  16653. */
  16654. getActiveCount(): number;
  16655. /**
  16656. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16657. * @returns True if it has been started, otherwise false.
  16658. */
  16659. isStarted(): boolean;
  16660. /**
  16661. * Animates the particle system for this frame.
  16662. */
  16663. animate(): void;
  16664. /**
  16665. * Renders the particle system in its current state.
  16666. * @returns the current number of particles
  16667. */
  16668. render(): number;
  16669. /**
  16670. * Dispose the particle system and frees its associated resources.
  16671. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16672. */
  16673. dispose(disposeTexture?: boolean): void;
  16674. /**
  16675. * An event triggered when the system is disposed
  16676. */
  16677. onDisposeObservable: Observable<IParticleSystem>;
  16678. /**
  16679. * An event triggered when the system is stopped
  16680. */
  16681. onStoppedObservable: Observable<IParticleSystem>;
  16682. /**
  16683. * Clones the particle system.
  16684. * @param name The name of the cloned object
  16685. * @param newEmitter The new emitter to use
  16686. * @returns the cloned particle system
  16687. */
  16688. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16689. /**
  16690. * Serializes the particle system to a JSON object
  16691. * @param serializeTexture defines if the texture must be serialized as well
  16692. * @returns the JSON object
  16693. */
  16694. serialize(serializeTexture: boolean): any;
  16695. /**
  16696. * Rebuild the particle system
  16697. */
  16698. rebuild(): void;
  16699. /** Force the system to rebuild all gradients that need to be resync */
  16700. forceRefreshGradients(): void;
  16701. /**
  16702. * Starts the particle system and begins to emit
  16703. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16704. */
  16705. start(delay?: number): void;
  16706. /**
  16707. * Stops the particle system.
  16708. */
  16709. stop(): void;
  16710. /**
  16711. * Remove all active particles
  16712. */
  16713. reset(): void;
  16714. /**
  16715. * Gets a boolean indicating that the system is stopping
  16716. * @returns true if the system is currently stopping
  16717. */
  16718. isStopping(): boolean;
  16719. /**
  16720. * Is this system ready to be used/rendered
  16721. * @return true if the system is ready
  16722. */
  16723. isReady(): boolean;
  16724. /**
  16725. * Returns the string "ParticleSystem"
  16726. * @returns a string containing the class name
  16727. */
  16728. getClassName(): string;
  16729. /**
  16730. * Gets the custom effect used to render the particles
  16731. * @param blendMode Blend mode for which the effect should be retrieved
  16732. * @returns The effect
  16733. */
  16734. getCustomEffect(blendMode: number): Nullable<Effect>;
  16735. /**
  16736. * Sets the custom effect used to render the particles
  16737. * @param effect The effect to set
  16738. * @param blendMode Blend mode for which the effect should be set
  16739. */
  16740. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16741. /**
  16742. * Fill the defines array according to the current settings of the particle system
  16743. * @param defines Array to be updated
  16744. * @param blendMode blend mode to take into account when updating the array
  16745. */
  16746. fillDefines(defines: Array<string>, blendMode: number): void;
  16747. /**
  16748. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16749. * @param uniforms Uniforms array to fill
  16750. * @param attributes Attributes array to fill
  16751. * @param samplers Samplers array to fill
  16752. */
  16753. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16754. /**
  16755. * Observable that will be called just before the particles are drawn
  16756. */
  16757. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16758. /**
  16759. * Gets the name of the particle vertex shader
  16760. */
  16761. vertexShaderName: string;
  16762. /**
  16763. * Adds a new color gradient
  16764. * @param gradient defines the gradient to use (between 0 and 1)
  16765. * @param color1 defines the color to affect to the specified gradient
  16766. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16767. * @returns the current particle system
  16768. */
  16769. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16770. /**
  16771. * Remove a specific color gradient
  16772. * @param gradient defines the gradient to remove
  16773. * @returns the current particle system
  16774. */
  16775. removeColorGradient(gradient: number): IParticleSystem;
  16776. /**
  16777. * Adds a new size gradient
  16778. * @param gradient defines the gradient to use (between 0 and 1)
  16779. * @param factor defines the size factor to affect to the specified gradient
  16780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16781. * @returns the current particle system
  16782. */
  16783. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16784. /**
  16785. * Remove a specific size gradient
  16786. * @param gradient defines the gradient to remove
  16787. * @returns the current particle system
  16788. */
  16789. removeSizeGradient(gradient: number): IParticleSystem;
  16790. /**
  16791. * Gets the current list of color gradients.
  16792. * You must use addColorGradient and removeColorGradient to udpate this list
  16793. * @returns the list of color gradients
  16794. */
  16795. getColorGradients(): Nullable<Array<ColorGradient>>;
  16796. /**
  16797. * Gets the current list of size gradients.
  16798. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16799. * @returns the list of size gradients
  16800. */
  16801. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16802. /**
  16803. * Gets the current list of angular speed gradients.
  16804. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16805. * @returns the list of angular speed gradients
  16806. */
  16807. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16808. /**
  16809. * Adds a new angular speed gradient
  16810. * @param gradient defines the gradient to use (between 0 and 1)
  16811. * @param factor defines the angular speed to affect to the specified gradient
  16812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16813. * @returns the current particle system
  16814. */
  16815. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16816. /**
  16817. * Remove a specific angular speed gradient
  16818. * @param gradient defines the gradient to remove
  16819. * @returns the current particle system
  16820. */
  16821. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16822. /**
  16823. * Gets the current list of velocity gradients.
  16824. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16825. * @returns the list of velocity gradients
  16826. */
  16827. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16828. /**
  16829. * Adds a new velocity gradient
  16830. * @param gradient defines the gradient to use (between 0 and 1)
  16831. * @param factor defines the velocity to affect to the specified gradient
  16832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16833. * @returns the current particle system
  16834. */
  16835. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16836. /**
  16837. * Remove a specific velocity gradient
  16838. * @param gradient defines the gradient to remove
  16839. * @returns the current particle system
  16840. */
  16841. removeVelocityGradient(gradient: number): IParticleSystem;
  16842. /**
  16843. * Gets the current list of limit velocity gradients.
  16844. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16845. * @returns the list of limit velocity gradients
  16846. */
  16847. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16848. /**
  16849. * Adds a new limit velocity gradient
  16850. * @param gradient defines the gradient to use (between 0 and 1)
  16851. * @param factor defines the limit velocity to affect to the specified gradient
  16852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16853. * @returns the current particle system
  16854. */
  16855. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16856. /**
  16857. * Remove a specific limit velocity gradient
  16858. * @param gradient defines the gradient to remove
  16859. * @returns the current particle system
  16860. */
  16861. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16862. /**
  16863. * Adds a new drag gradient
  16864. * @param gradient defines the gradient to use (between 0 and 1)
  16865. * @param factor defines the drag to affect to the specified gradient
  16866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16867. * @returns the current particle system
  16868. */
  16869. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16870. /**
  16871. * Remove a specific drag gradient
  16872. * @param gradient defines the gradient to remove
  16873. * @returns the current particle system
  16874. */
  16875. removeDragGradient(gradient: number): IParticleSystem;
  16876. /**
  16877. * Gets the current list of drag gradients.
  16878. * You must use addDragGradient and removeDragGradient to udpate this list
  16879. * @returns the list of drag gradients
  16880. */
  16881. getDragGradients(): Nullable<Array<FactorGradient>>;
  16882. /**
  16883. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16884. * @param gradient defines the gradient to use (between 0 and 1)
  16885. * @param factor defines the emit rate to affect to the specified gradient
  16886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16887. * @returns the current particle system
  16888. */
  16889. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16890. /**
  16891. * Remove a specific emit rate gradient
  16892. * @param gradient defines the gradient to remove
  16893. * @returns the current particle system
  16894. */
  16895. removeEmitRateGradient(gradient: number): IParticleSystem;
  16896. /**
  16897. * Gets the current list of emit rate gradients.
  16898. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16899. * @returns the list of emit rate gradients
  16900. */
  16901. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16902. /**
  16903. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16904. * @param gradient defines the gradient to use (between 0 and 1)
  16905. * @param factor defines the start size to affect to the specified gradient
  16906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16907. * @returns the current particle system
  16908. */
  16909. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16910. /**
  16911. * Remove a specific start size gradient
  16912. * @param gradient defines the gradient to remove
  16913. * @returns the current particle system
  16914. */
  16915. removeStartSizeGradient(gradient: number): IParticleSystem;
  16916. /**
  16917. * Gets the current list of start size gradients.
  16918. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16919. * @returns the list of start size gradients
  16920. */
  16921. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16922. /**
  16923. * Adds a new life time gradient
  16924. * @param gradient defines the gradient to use (between 0 and 1)
  16925. * @param factor defines the life time factor to affect to the specified gradient
  16926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16927. * @returns the current particle system
  16928. */
  16929. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16930. /**
  16931. * Remove a specific life time gradient
  16932. * @param gradient defines the gradient to remove
  16933. * @returns the current particle system
  16934. */
  16935. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16936. /**
  16937. * Gets the current list of life time gradients.
  16938. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16939. * @returns the list of life time gradients
  16940. */
  16941. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16942. /**
  16943. * Gets the current list of color gradients.
  16944. * You must use addColorGradient and removeColorGradient to udpate this list
  16945. * @returns the list of color gradients
  16946. */
  16947. getColorGradients(): Nullable<Array<ColorGradient>>;
  16948. /**
  16949. * Adds a new ramp gradient used to remap particle colors
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param color defines the color to affect to the specified gradient
  16952. * @returns the current particle system
  16953. */
  16954. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16955. /**
  16956. * Gets the current list of ramp gradients.
  16957. * You must use addRampGradient and removeRampGradient to udpate this list
  16958. * @returns the list of ramp gradients
  16959. */
  16960. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16961. /** Gets or sets a boolean indicating that ramp gradients must be used
  16962. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16963. */
  16964. useRampGradients: boolean;
  16965. /**
  16966. * Adds a new color remap gradient
  16967. * @param gradient defines the gradient to use (between 0 and 1)
  16968. * @param min defines the color remap minimal range
  16969. * @param max defines the color remap maximal range
  16970. * @returns the current particle system
  16971. */
  16972. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16973. /**
  16974. * Gets the current list of color remap gradients.
  16975. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16976. * @returns the list of color remap gradients
  16977. */
  16978. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16979. /**
  16980. * Adds a new alpha remap gradient
  16981. * @param gradient defines the gradient to use (between 0 and 1)
  16982. * @param min defines the alpha remap minimal range
  16983. * @param max defines the alpha remap maximal range
  16984. * @returns the current particle system
  16985. */
  16986. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16987. /**
  16988. * Gets the current list of alpha remap gradients.
  16989. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16990. * @returns the list of alpha remap gradients
  16991. */
  16992. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16993. /**
  16994. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16997. * @returns the emitter
  16998. */
  16999. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17000. /**
  17001. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17002. * @param radius The radius of the hemisphere to emit from
  17003. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17004. * @returns the emitter
  17005. */
  17006. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17007. /**
  17008. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17009. * @param radius The radius of the sphere to emit from
  17010. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17011. * @returns the emitter
  17012. */
  17013. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17014. /**
  17015. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17016. * @param radius The radius of the sphere to emit from
  17017. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17018. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17019. * @returns the emitter
  17020. */
  17021. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17022. /**
  17023. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17024. * @param radius The radius of the emission cylinder
  17025. * @param height The height of the emission cylinder
  17026. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17027. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17028. * @returns the emitter
  17029. */
  17030. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17031. /**
  17032. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17033. * @param radius The radius of the cylinder to emit from
  17034. * @param height The height of the emission cylinder
  17035. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17036. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17037. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17038. * @returns the emitter
  17039. */
  17040. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17041. /**
  17042. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17043. * @param radius The radius of the cone to emit from
  17044. * @param angle The base angle of the cone
  17045. * @returns the emitter
  17046. */
  17047. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17048. /**
  17049. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17052. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17053. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17054. * @returns the emitter
  17055. */
  17056. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17057. /**
  17058. * Get hosting scene
  17059. * @returns the scene
  17060. */
  17061. getScene(): Nullable<Scene>;
  17062. }
  17063. }
  17064. declare module BABYLON {
  17065. /**
  17066. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17067. */
  17068. export class ColorSplitterBlock extends NodeMaterialBlock {
  17069. /**
  17070. * Create a new ColorSplitterBlock
  17071. * @param name defines the block name
  17072. */
  17073. constructor(name: string);
  17074. /**
  17075. * Gets the current class name
  17076. * @returns the class name
  17077. */
  17078. getClassName(): string;
  17079. /**
  17080. * Gets the rgba component (input)
  17081. */
  17082. get rgba(): NodeMaterialConnectionPoint;
  17083. /**
  17084. * Gets the rgb component (input)
  17085. */
  17086. get rgbIn(): NodeMaterialConnectionPoint;
  17087. /**
  17088. * Gets the rgb component (output)
  17089. */
  17090. get rgbOut(): NodeMaterialConnectionPoint;
  17091. /**
  17092. * Gets the r component (output)
  17093. */
  17094. get r(): NodeMaterialConnectionPoint;
  17095. /**
  17096. * Gets the g component (output)
  17097. */
  17098. get g(): NodeMaterialConnectionPoint;
  17099. /**
  17100. * Gets the b component (output)
  17101. */
  17102. get b(): NodeMaterialConnectionPoint;
  17103. /**
  17104. * Gets the a component (output)
  17105. */
  17106. get a(): NodeMaterialConnectionPoint;
  17107. protected _inputRename(name: string): string;
  17108. protected _outputRename(name: string): string;
  17109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17110. }
  17111. }
  17112. declare module BABYLON {
  17113. /**
  17114. * Operations supported by the Trigonometry block
  17115. */
  17116. export enum TrigonometryBlockOperations {
  17117. /** Cos */
  17118. Cos = 0,
  17119. /** Sin */
  17120. Sin = 1,
  17121. /** Abs */
  17122. Abs = 2,
  17123. /** Exp */
  17124. Exp = 3,
  17125. /** Exp2 */
  17126. Exp2 = 4,
  17127. /** Round */
  17128. Round = 5,
  17129. /** Floor */
  17130. Floor = 6,
  17131. /** Ceiling */
  17132. Ceiling = 7,
  17133. /** Square root */
  17134. Sqrt = 8,
  17135. /** Log */
  17136. Log = 9,
  17137. /** Tangent */
  17138. Tan = 10,
  17139. /** Arc tangent */
  17140. ArcTan = 11,
  17141. /** Arc cosinus */
  17142. ArcCos = 12,
  17143. /** Arc sinus */
  17144. ArcSin = 13,
  17145. /** Fraction */
  17146. Fract = 14,
  17147. /** Sign */
  17148. Sign = 15,
  17149. /** To radians (from degrees) */
  17150. Radians = 16,
  17151. /** To degrees (from radians) */
  17152. Degrees = 17
  17153. }
  17154. /**
  17155. * Block used to apply trigonometry operation to floats
  17156. */
  17157. export class TrigonometryBlock extends NodeMaterialBlock {
  17158. /**
  17159. * Gets or sets the operation applied by the block
  17160. */
  17161. operation: TrigonometryBlockOperations;
  17162. /**
  17163. * Creates a new TrigonometryBlock
  17164. * @param name defines the block name
  17165. */
  17166. constructor(name: string);
  17167. /**
  17168. * Gets the current class name
  17169. * @returns the class name
  17170. */
  17171. getClassName(): string;
  17172. /**
  17173. * Gets the input component
  17174. */
  17175. get input(): NodeMaterialConnectionPoint;
  17176. /**
  17177. * Gets the output component
  17178. */
  17179. get output(): NodeMaterialConnectionPoint;
  17180. protected _buildBlock(state: NodeMaterialBuildState): this;
  17181. serialize(): any;
  17182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17183. protected _dumpPropertiesCode(): string;
  17184. }
  17185. }
  17186. declare module BABYLON {
  17187. /**
  17188. * Interface used to configure the node material editor
  17189. */
  17190. export interface INodeMaterialEditorOptions {
  17191. /** Define the URl to load node editor script */
  17192. editorURL?: string;
  17193. }
  17194. /** @hidden */
  17195. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17196. NORMAL: boolean;
  17197. TANGENT: boolean;
  17198. UV1: boolean;
  17199. /** BONES */
  17200. NUM_BONE_INFLUENCERS: number;
  17201. BonesPerMesh: number;
  17202. BONETEXTURE: boolean;
  17203. /** MORPH TARGETS */
  17204. MORPHTARGETS: boolean;
  17205. MORPHTARGETS_NORMAL: boolean;
  17206. MORPHTARGETS_TANGENT: boolean;
  17207. MORPHTARGETS_UV: boolean;
  17208. NUM_MORPH_INFLUENCERS: number;
  17209. /** IMAGE PROCESSING */
  17210. IMAGEPROCESSING: boolean;
  17211. VIGNETTE: boolean;
  17212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17213. VIGNETTEBLENDMODEOPAQUE: boolean;
  17214. TONEMAPPING: boolean;
  17215. TONEMAPPING_ACES: boolean;
  17216. CONTRAST: boolean;
  17217. EXPOSURE: boolean;
  17218. COLORCURVES: boolean;
  17219. COLORGRADING: boolean;
  17220. COLORGRADING3D: boolean;
  17221. SAMPLER3DGREENDEPTH: boolean;
  17222. SAMPLER3DBGRMAP: boolean;
  17223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17224. /** MISC. */
  17225. BUMPDIRECTUV: number;
  17226. constructor();
  17227. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17228. }
  17229. /**
  17230. * Class used to configure NodeMaterial
  17231. */
  17232. export interface INodeMaterialOptions {
  17233. /**
  17234. * Defines if blocks should emit comments
  17235. */
  17236. emitComments: boolean;
  17237. }
  17238. /**
  17239. * Class used to create a node based material built by assembling shader blocks
  17240. */
  17241. export class NodeMaterial extends PushMaterial {
  17242. private static _BuildIdGenerator;
  17243. private _options;
  17244. private _vertexCompilationState;
  17245. private _fragmentCompilationState;
  17246. private _sharedData;
  17247. private _buildId;
  17248. private _buildWasSuccessful;
  17249. private _cachedWorldViewMatrix;
  17250. private _cachedWorldViewProjectionMatrix;
  17251. private _optimizers;
  17252. private _animationFrame;
  17253. /** Define the Url to load node editor script */
  17254. static EditorURL: string;
  17255. /** Define the Url to load snippets */
  17256. static SnippetUrl: string;
  17257. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17258. static IgnoreTexturesAtLoadTime: boolean;
  17259. private BJSNODEMATERIALEDITOR;
  17260. /** Get the inspector from bundle or global */
  17261. private _getGlobalNodeMaterialEditor;
  17262. /**
  17263. * Snippet ID if the material was created from the snippet server
  17264. */
  17265. snippetId: string;
  17266. /**
  17267. * Gets or sets data used by visual editor
  17268. * @see https://nme.babylonjs.com
  17269. */
  17270. editorData: any;
  17271. /**
  17272. * 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)
  17273. */
  17274. ignoreAlpha: boolean;
  17275. /**
  17276. * Defines the maximum number of lights that can be used in the material
  17277. */
  17278. maxSimultaneousLights: number;
  17279. /**
  17280. * Observable raised when the material is built
  17281. */
  17282. onBuildObservable: Observable<NodeMaterial>;
  17283. /**
  17284. * Gets or sets the root nodes of the material vertex shader
  17285. */
  17286. _vertexOutputNodes: NodeMaterialBlock[];
  17287. /**
  17288. * Gets or sets the root nodes of the material fragment (pixel) shader
  17289. */
  17290. _fragmentOutputNodes: NodeMaterialBlock[];
  17291. /** Gets or sets options to control the node material overall behavior */
  17292. get options(): INodeMaterialOptions;
  17293. set options(options: INodeMaterialOptions);
  17294. /**
  17295. * Default configuration related to image processing available in the standard Material.
  17296. */
  17297. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17298. /**
  17299. * Gets the image processing configuration used either in this material.
  17300. */
  17301. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17302. /**
  17303. * Sets the Default image processing configuration used either in the this material.
  17304. *
  17305. * If sets to null, the scene one is in use.
  17306. */
  17307. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17308. /**
  17309. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17310. */
  17311. attachedBlocks: NodeMaterialBlock[];
  17312. /**
  17313. * Specifies the mode of the node material
  17314. * @hidden
  17315. */
  17316. _mode: NodeMaterialModes;
  17317. /**
  17318. * Gets the mode property
  17319. */
  17320. get mode(): NodeMaterialModes;
  17321. /**
  17322. * A free comment about the material
  17323. */
  17324. comment: string;
  17325. /**
  17326. * Create a new node based material
  17327. * @param name defines the material name
  17328. * @param scene defines the hosting scene
  17329. * @param options defines creation option
  17330. */
  17331. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17332. /**
  17333. * Gets the current class name of the material e.g. "NodeMaterial"
  17334. * @returns the class name
  17335. */
  17336. getClassName(): string;
  17337. /**
  17338. * Keep track of the image processing observer to allow dispose and replace.
  17339. */
  17340. private _imageProcessingObserver;
  17341. /**
  17342. * Attaches a new image processing configuration to the Standard Material.
  17343. * @param configuration
  17344. */
  17345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17346. /**
  17347. * Get a block by its name
  17348. * @param name defines the name of the block to retrieve
  17349. * @returns the required block or null if not found
  17350. */
  17351. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17352. /**
  17353. * Get a block by its name
  17354. * @param predicate defines the predicate used to find the good candidate
  17355. * @returns the required block or null if not found
  17356. */
  17357. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17358. /**
  17359. * Get an input block by its name
  17360. * @param predicate defines the predicate used to find the good candidate
  17361. * @returns the required input block or null if not found
  17362. */
  17363. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17364. /**
  17365. * Gets the list of input blocks attached to this material
  17366. * @returns an array of InputBlocks
  17367. */
  17368. getInputBlocks(): InputBlock[];
  17369. /**
  17370. * Adds a new optimizer to the list of optimizers
  17371. * @param optimizer defines the optimizers to add
  17372. * @returns the current material
  17373. */
  17374. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17375. /**
  17376. * Remove an optimizer from the list of optimizers
  17377. * @param optimizer defines the optimizers to remove
  17378. * @returns the current material
  17379. */
  17380. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17381. /**
  17382. * Add a new block to the list of output nodes
  17383. * @param node defines the node to add
  17384. * @returns the current material
  17385. */
  17386. addOutputNode(node: NodeMaterialBlock): this;
  17387. /**
  17388. * Remove a block from the list of root nodes
  17389. * @param node defines the node to remove
  17390. * @returns the current material
  17391. */
  17392. removeOutputNode(node: NodeMaterialBlock): this;
  17393. private _addVertexOutputNode;
  17394. private _removeVertexOutputNode;
  17395. private _addFragmentOutputNode;
  17396. private _removeFragmentOutputNode;
  17397. /**
  17398. * Specifies if the material will require alpha blending
  17399. * @returns a boolean specifying if alpha blending is needed
  17400. */
  17401. needAlphaBlending(): boolean;
  17402. /**
  17403. * Specifies if this material should be rendered in alpha test mode
  17404. * @returns a boolean specifying if an alpha test is needed.
  17405. */
  17406. needAlphaTesting(): boolean;
  17407. private _initializeBlock;
  17408. private _resetDualBlocks;
  17409. /**
  17410. * Remove a block from the current node material
  17411. * @param block defines the block to remove
  17412. */
  17413. removeBlock(block: NodeMaterialBlock): void;
  17414. /**
  17415. * Build the material and generates the inner effect
  17416. * @param verbose defines if the build should log activity
  17417. */
  17418. build(verbose?: boolean): void;
  17419. /**
  17420. * Runs an otpimization phase to try to improve the shader code
  17421. */
  17422. optimize(): void;
  17423. private _prepareDefinesForAttributes;
  17424. /**
  17425. * Create a post process from the material
  17426. * @param camera The camera to apply the render pass to.
  17427. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17429. * @param engine The engine which the post process will be applied. (default: current engine)
  17430. * @param reusable If the post process can be reused on the same frame. (default: false)
  17431. * @param textureType Type of textures used when performing the post process. (default: 0)
  17432. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17433. * @returns the post process created
  17434. */
  17435. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17436. /**
  17437. * Create the post process effect from the material
  17438. * @param postProcess The post process to create the effect for
  17439. */
  17440. createEffectForPostProcess(postProcess: PostProcess): void;
  17441. private _createEffectForPostProcess;
  17442. /**
  17443. * Create a new procedural texture based on this node material
  17444. * @param size defines the size of the texture
  17445. * @param scene defines the hosting scene
  17446. * @returns the new procedural texture attached to this node material
  17447. */
  17448. createProceduralTexture(size: number | {
  17449. width: number;
  17450. height: number;
  17451. layers?: number;
  17452. }, scene: Scene): Nullable<ProceduralTexture>;
  17453. private _createEffectForParticles;
  17454. private _checkInternals;
  17455. /**
  17456. * Create the effect to be used as the custom effect for a particle system
  17457. * @param particleSystem Particle system to create the effect for
  17458. * @param onCompiled defines a function to call when the effect creation is successful
  17459. * @param onError defines a function to call when the effect creation has failed
  17460. */
  17461. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17462. private _processDefines;
  17463. /**
  17464. * Get if the submesh is ready to be used and all its information available.
  17465. * Child classes can use it to update shaders
  17466. * @param mesh defines the mesh to check
  17467. * @param subMesh defines which submesh to check
  17468. * @param useInstances specifies that instances should be used
  17469. * @returns a boolean indicating that the submesh is ready or not
  17470. */
  17471. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17472. /**
  17473. * Get a string representing the shaders built by the current node graph
  17474. */
  17475. get compiledShaders(): string;
  17476. /**
  17477. * Binds the world matrix to the material
  17478. * @param world defines the world transformation matrix
  17479. */
  17480. bindOnlyWorldMatrix(world: Matrix): void;
  17481. /**
  17482. * Binds the submesh to this material by preparing the effect and shader to draw
  17483. * @param world defines the world transformation matrix
  17484. * @param mesh defines the mesh containing the submesh
  17485. * @param subMesh defines the submesh to bind the material to
  17486. */
  17487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17488. /**
  17489. * Gets the active textures from the material
  17490. * @returns an array of textures
  17491. */
  17492. getActiveTextures(): BaseTexture[];
  17493. /**
  17494. * Gets the list of texture blocks
  17495. * @returns an array of texture blocks
  17496. */
  17497. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17498. /**
  17499. * Specifies if the material uses a texture
  17500. * @param texture defines the texture to check against the material
  17501. * @returns a boolean specifying if the material uses the texture
  17502. */
  17503. hasTexture(texture: BaseTexture): boolean;
  17504. /**
  17505. * Disposes the material
  17506. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17507. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17508. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17509. */
  17510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17511. /** Creates the node editor window. */
  17512. private _createNodeEditor;
  17513. /**
  17514. * Launch the node material editor
  17515. * @param config Define the configuration of the editor
  17516. * @return a promise fulfilled when the node editor is visible
  17517. */
  17518. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17519. /**
  17520. * Clear the current material
  17521. */
  17522. clear(): void;
  17523. /**
  17524. * Clear the current material and set it to a default state
  17525. */
  17526. setToDefault(): void;
  17527. /**
  17528. * Clear the current material and set it to a default state for post process
  17529. */
  17530. setToDefaultPostProcess(): void;
  17531. /**
  17532. * Clear the current material and set it to a default state for procedural texture
  17533. */
  17534. setToDefaultProceduralTexture(): void;
  17535. /**
  17536. * Clear the current material and set it to a default state for particle
  17537. */
  17538. setToDefaultParticle(): void;
  17539. /**
  17540. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17541. * @param url defines the url to load from
  17542. * @returns a promise that will fullfil when the material is fully loaded
  17543. */
  17544. loadAsync(url: string): Promise<void>;
  17545. private _gatherBlocks;
  17546. /**
  17547. * Generate a string containing the code declaration required to create an equivalent of this material
  17548. * @returns a string
  17549. */
  17550. generateCode(): string;
  17551. /**
  17552. * Serializes this material in a JSON representation
  17553. * @returns the serialized material object
  17554. */
  17555. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17556. private _restoreConnections;
  17557. /**
  17558. * Clear the current graph and load a new one from a serialization object
  17559. * @param source defines the JSON representation of the material
  17560. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17561. * @param merge defines whether or not the source must be merged or replace the current content
  17562. */
  17563. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17564. /**
  17565. * Makes a duplicate of the current material.
  17566. * @param name - name to use for the new material.
  17567. */
  17568. clone(name: string): NodeMaterial;
  17569. /**
  17570. * Creates a node material from parsed material data
  17571. * @param source defines the JSON representation of the material
  17572. * @param scene defines the hosting scene
  17573. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17574. * @returns a new node material
  17575. */
  17576. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17577. /**
  17578. * Creates a node material from a snippet saved in a remote file
  17579. * @param name defines the name of the material to create
  17580. * @param url defines the url to load from
  17581. * @param scene defines the hosting scene
  17582. * @returns a promise that will resolve to the new node material
  17583. */
  17584. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17585. /**
  17586. * Creates a node material from a snippet saved by the node material editor
  17587. * @param snippetId defines the snippet to load
  17588. * @param scene defines the hosting scene
  17589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17590. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17591. * @returns a promise that will resolve to the new node material
  17592. */
  17593. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17594. /**
  17595. * Creates a new node material set to default basic configuration
  17596. * @param name defines the name of the material
  17597. * @param scene defines the hosting scene
  17598. * @returns a new NodeMaterial
  17599. */
  17600. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17601. }
  17602. }
  17603. declare module BABYLON {
  17604. interface ThinEngine {
  17605. /**
  17606. * Unbind a list of render target textures from the webGL context
  17607. * This is used only when drawBuffer extension or webGL2 are active
  17608. * @param textures defines the render target textures to unbind
  17609. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17610. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17611. */
  17612. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17613. /**
  17614. * Create a multi render target texture
  17615. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17616. * @param size defines the size of the texture
  17617. * @param options defines the creation options
  17618. * @returns the cube texture as an InternalTexture
  17619. */
  17620. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17621. /**
  17622. * Update the sample count for a given multiple render target texture
  17623. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17624. * @param textures defines the textures to update
  17625. * @param samples defines the sample count to set
  17626. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17627. */
  17628. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17629. /**
  17630. * Select a subsets of attachments to draw to.
  17631. * @param attachments gl attachments
  17632. */
  17633. bindAttachments(attachments: number[]): void;
  17634. /**
  17635. * Creates a layout object to draw/clear on specific textures in a MRT
  17636. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17637. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17638. */
  17639. buildTextureLayout(textureStatus: boolean[]): number[];
  17640. /**
  17641. * Restores the webgl state to only draw on the main color attachment
  17642. */
  17643. restoreSingleAttachment(): void;
  17644. }
  17645. }
  17646. declare module BABYLON {
  17647. /**
  17648. * Creation options of the multi render target texture.
  17649. */
  17650. export interface IMultiRenderTargetOptions {
  17651. /**
  17652. * Define if the texture needs to create mip maps after render.
  17653. */
  17654. generateMipMaps?: boolean;
  17655. /**
  17656. * Define the types of all the draw buffers we want to create
  17657. */
  17658. types?: number[];
  17659. /**
  17660. * Define the sampling modes of all the draw buffers we want to create
  17661. */
  17662. samplingModes?: number[];
  17663. /**
  17664. * Define if a depth buffer is required
  17665. */
  17666. generateDepthBuffer?: boolean;
  17667. /**
  17668. * Define if a stencil buffer is required
  17669. */
  17670. generateStencilBuffer?: boolean;
  17671. /**
  17672. * Define if a depth texture is required instead of a depth buffer
  17673. */
  17674. generateDepthTexture?: boolean;
  17675. /**
  17676. * Define the number of desired draw buffers
  17677. */
  17678. textureCount?: number;
  17679. /**
  17680. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17681. */
  17682. doNotChangeAspectRatio?: boolean;
  17683. /**
  17684. * Define the default type of the buffers we are creating
  17685. */
  17686. defaultType?: number;
  17687. }
  17688. /**
  17689. * A multi render target, like a render target provides the ability to render to a texture.
  17690. * Unlike the render target, it can render to several draw buffers in one draw.
  17691. * This is specially interesting in deferred rendering or for any effects requiring more than
  17692. * just one color from a single pass.
  17693. */
  17694. export class MultiRenderTarget extends RenderTargetTexture {
  17695. private _internalTextures;
  17696. private _textures;
  17697. private _multiRenderTargetOptions;
  17698. private _count;
  17699. /**
  17700. * Get if draw buffers are currently supported by the used hardware and browser.
  17701. */
  17702. get isSupported(): boolean;
  17703. /**
  17704. * Get the list of textures generated by the multi render target.
  17705. */
  17706. get textures(): Texture[];
  17707. /**
  17708. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17709. */
  17710. get count(): number;
  17711. /**
  17712. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17713. */
  17714. get depthTexture(): Texture;
  17715. /**
  17716. * Set the wrapping mode on U of all the textures we are rendering to.
  17717. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17718. */
  17719. set wrapU(wrap: number);
  17720. /**
  17721. * Set the wrapping mode on V of all the textures we are rendering to.
  17722. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17723. */
  17724. set wrapV(wrap: number);
  17725. /**
  17726. * Instantiate a new multi render target texture.
  17727. * A multi render target, like a render target provides the ability to render to a texture.
  17728. * Unlike the render target, it can render to several draw buffers in one draw.
  17729. * This is specially interesting in deferred rendering or for any effects requiring more than
  17730. * just one color from a single pass.
  17731. * @param name Define the name of the texture
  17732. * @param size Define the size of the buffers to render to
  17733. * @param count Define the number of target we are rendering into
  17734. * @param scene Define the scene the texture belongs to
  17735. * @param options Define the options used to create the multi render target
  17736. */
  17737. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17738. private _initTypes;
  17739. /** @hidden */
  17740. _rebuild(forceFullRebuild?: boolean): void;
  17741. private _createInternalTextures;
  17742. private _createTextures;
  17743. /**
  17744. * Replaces a texture within the MRT.
  17745. * @param texture The new texture to insert in the MRT
  17746. * @param index The index of the texture to replace
  17747. */
  17748. replaceTexture(texture: Texture, index: number): void;
  17749. /**
  17750. * Define the number of samples used if MSAA is enabled.
  17751. */
  17752. get samples(): number;
  17753. set samples(value: number);
  17754. /**
  17755. * Resize all the textures in the multi render target.
  17756. * Be careful as it will recreate all the data in the new texture.
  17757. * @param size Define the new size
  17758. */
  17759. resize(size: any): void;
  17760. /**
  17761. * Changes the number of render targets in this MRT
  17762. * Be careful as it will recreate all the data in the new texture.
  17763. * @param count new texture count
  17764. * @param options Specifies texture types and sampling modes for new textures
  17765. */
  17766. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17767. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17768. /**
  17769. * Dispose the render targets and their associated resources
  17770. */
  17771. dispose(): void;
  17772. /**
  17773. * Release all the underlying texture used as draw buffers.
  17774. */
  17775. releaseInternalTextures(): void;
  17776. }
  17777. }
  17778. declare module BABYLON {
  17779. /** @hidden */
  17780. export var imageProcessingPixelShader: {
  17781. name: string;
  17782. shader: string;
  17783. };
  17784. }
  17785. declare module BABYLON {
  17786. /**
  17787. * ImageProcessingPostProcess
  17788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17789. */
  17790. export class ImageProcessingPostProcess extends PostProcess {
  17791. /**
  17792. * Default configuration related to image processing available in the PBR Material.
  17793. */
  17794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17795. /**
  17796. * Gets the image processing configuration used either in this material.
  17797. */
  17798. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17799. /**
  17800. * Sets the Default image processing configuration used either in the this material.
  17801. *
  17802. * If sets to null, the scene one is in use.
  17803. */
  17804. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17805. /**
  17806. * Keep track of the image processing observer to allow dispose and replace.
  17807. */
  17808. private _imageProcessingObserver;
  17809. /**
  17810. * Attaches a new image processing configuration to the PBR Material.
  17811. * @param configuration
  17812. */
  17813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17814. /**
  17815. * If the post process is supported.
  17816. */
  17817. get isSupported(): boolean;
  17818. /**
  17819. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17820. */
  17821. get colorCurves(): Nullable<ColorCurves>;
  17822. /**
  17823. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17824. */
  17825. set colorCurves(value: Nullable<ColorCurves>);
  17826. /**
  17827. * Gets wether the color curves effect is enabled.
  17828. */
  17829. get colorCurvesEnabled(): boolean;
  17830. /**
  17831. * Sets wether the color curves effect is enabled.
  17832. */
  17833. set colorCurvesEnabled(value: boolean);
  17834. /**
  17835. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17836. */
  17837. get colorGradingTexture(): Nullable<BaseTexture>;
  17838. /**
  17839. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17840. */
  17841. set colorGradingTexture(value: Nullable<BaseTexture>);
  17842. /**
  17843. * Gets wether the color grading effect is enabled.
  17844. */
  17845. get colorGradingEnabled(): boolean;
  17846. /**
  17847. * Gets wether the color grading effect is enabled.
  17848. */
  17849. set colorGradingEnabled(value: boolean);
  17850. /**
  17851. * Gets exposure used in the effect.
  17852. */
  17853. get exposure(): number;
  17854. /**
  17855. * Sets exposure used in the effect.
  17856. */
  17857. set exposure(value: number);
  17858. /**
  17859. * Gets wether tonemapping is enabled or not.
  17860. */
  17861. get toneMappingEnabled(): boolean;
  17862. /**
  17863. * Sets wether tonemapping is enabled or not
  17864. */
  17865. set toneMappingEnabled(value: boolean);
  17866. /**
  17867. * Gets the type of tone mapping effect.
  17868. */
  17869. get toneMappingType(): number;
  17870. /**
  17871. * Sets the type of tone mapping effect.
  17872. */
  17873. set toneMappingType(value: number);
  17874. /**
  17875. * Gets contrast used in the effect.
  17876. */
  17877. get contrast(): number;
  17878. /**
  17879. * Sets contrast used in the effect.
  17880. */
  17881. set contrast(value: number);
  17882. /**
  17883. * Gets Vignette stretch size.
  17884. */
  17885. get vignetteStretch(): number;
  17886. /**
  17887. * Sets Vignette stretch size.
  17888. */
  17889. set vignetteStretch(value: number);
  17890. /**
  17891. * Gets Vignette centre X Offset.
  17892. */
  17893. get vignetteCentreX(): number;
  17894. /**
  17895. * Sets Vignette centre X Offset.
  17896. */
  17897. set vignetteCentreX(value: number);
  17898. /**
  17899. * Gets Vignette centre Y Offset.
  17900. */
  17901. get vignetteCentreY(): number;
  17902. /**
  17903. * Sets Vignette centre Y Offset.
  17904. */
  17905. set vignetteCentreY(value: number);
  17906. /**
  17907. * Gets Vignette weight or intensity of the vignette effect.
  17908. */
  17909. get vignetteWeight(): number;
  17910. /**
  17911. * Sets Vignette weight or intensity of the vignette effect.
  17912. */
  17913. set vignetteWeight(value: number);
  17914. /**
  17915. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17916. * if vignetteEnabled is set to true.
  17917. */
  17918. get vignetteColor(): Color4;
  17919. /**
  17920. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17921. * if vignetteEnabled is set to true.
  17922. */
  17923. set vignetteColor(value: Color4);
  17924. /**
  17925. * Gets Camera field of view used by the Vignette effect.
  17926. */
  17927. get vignetteCameraFov(): number;
  17928. /**
  17929. * Sets Camera field of view used by the Vignette effect.
  17930. */
  17931. set vignetteCameraFov(value: number);
  17932. /**
  17933. * Gets the vignette blend mode allowing different kind of effect.
  17934. */
  17935. get vignetteBlendMode(): number;
  17936. /**
  17937. * Sets the vignette blend mode allowing different kind of effect.
  17938. */
  17939. set vignetteBlendMode(value: number);
  17940. /**
  17941. * Gets wether the vignette effect is enabled.
  17942. */
  17943. get vignetteEnabled(): boolean;
  17944. /**
  17945. * Sets wether the vignette effect is enabled.
  17946. */
  17947. set vignetteEnabled(value: boolean);
  17948. private _fromLinearSpace;
  17949. /**
  17950. * Gets wether the input of the processing is in Gamma or Linear Space.
  17951. */
  17952. get fromLinearSpace(): boolean;
  17953. /**
  17954. * Sets wether the input of the processing is in Gamma or Linear Space.
  17955. */
  17956. set fromLinearSpace(value: boolean);
  17957. /**
  17958. * Defines cache preventing GC.
  17959. */
  17960. private _defines;
  17961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17962. /**
  17963. * "ImageProcessingPostProcess"
  17964. * @returns "ImageProcessingPostProcess"
  17965. */
  17966. getClassName(): string;
  17967. /**
  17968. * @hidden
  17969. */
  17970. _updateParameters(): void;
  17971. dispose(camera?: Camera): void;
  17972. }
  17973. }
  17974. declare module BABYLON {
  17975. /**
  17976. * Interface for defining prepass effects in the prepass post-process pipeline
  17977. */
  17978. export interface PrePassEffectConfiguration {
  17979. /**
  17980. * Name of the effect
  17981. */
  17982. name: string;
  17983. /**
  17984. * Post process to attach for this effect
  17985. */
  17986. postProcess?: PostProcess;
  17987. /**
  17988. * Textures required in the MRT
  17989. */
  17990. texturesRequired: number[];
  17991. /**
  17992. * Is the effect enabled
  17993. */
  17994. enabled: boolean;
  17995. /**
  17996. * Disposes the effect configuration
  17997. */
  17998. dispose?: () => void;
  17999. /**
  18000. * Creates the associated post process
  18001. */
  18002. createPostProcess?: () => PostProcess;
  18003. }
  18004. }
  18005. declare module BABYLON {
  18006. /**
  18007. * Options to be used when creating a FresnelParameters.
  18008. */
  18009. export type IFresnelParametersCreationOptions = {
  18010. /**
  18011. * Define the color used on edges (grazing angle)
  18012. */
  18013. leftColor?: Color3;
  18014. /**
  18015. * Define the color used on center
  18016. */
  18017. rightColor?: Color3;
  18018. /**
  18019. * Define bias applied to computed fresnel term
  18020. */
  18021. bias?: number;
  18022. /**
  18023. * Defined the power exponent applied to fresnel term
  18024. */
  18025. power?: number;
  18026. /**
  18027. * Define if the fresnel effect is enable or not.
  18028. */
  18029. isEnabled?: boolean;
  18030. };
  18031. /**
  18032. * Serialized format for FresnelParameters.
  18033. */
  18034. export type IFresnelParametersSerialized = {
  18035. /**
  18036. * Define the color used on edges (grazing angle) [as an array]
  18037. */
  18038. leftColor: number[];
  18039. /**
  18040. * Define the color used on center [as an array]
  18041. */
  18042. rightColor: number[];
  18043. /**
  18044. * Define bias applied to computed fresnel term
  18045. */
  18046. bias: number;
  18047. /**
  18048. * Defined the power exponent applied to fresnel term
  18049. */
  18050. power?: number;
  18051. /**
  18052. * Define if the fresnel effect is enable or not.
  18053. */
  18054. isEnabled: boolean;
  18055. };
  18056. /**
  18057. * This represents all the required information to add a fresnel effect on a material:
  18058. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18059. */
  18060. export class FresnelParameters {
  18061. private _isEnabled;
  18062. /**
  18063. * Define if the fresnel effect is enable or not.
  18064. */
  18065. get isEnabled(): boolean;
  18066. set isEnabled(value: boolean);
  18067. /**
  18068. * Define the color used on edges (grazing angle)
  18069. */
  18070. leftColor: Color3;
  18071. /**
  18072. * Define the color used on center
  18073. */
  18074. rightColor: Color3;
  18075. /**
  18076. * Define bias applied to computed fresnel term
  18077. */
  18078. bias: number;
  18079. /**
  18080. * Defined the power exponent applied to fresnel term
  18081. */
  18082. power: number;
  18083. /**
  18084. * Creates a new FresnelParameters object.
  18085. *
  18086. * @param options provide your own settings to optionally to override defaults
  18087. */
  18088. constructor(options?: IFresnelParametersCreationOptions);
  18089. /**
  18090. * Clones the current fresnel and its valuues
  18091. * @returns a clone fresnel configuration
  18092. */
  18093. clone(): FresnelParameters;
  18094. /**
  18095. * Determines equality between FresnelParameters objects
  18096. * @param otherFresnelParameters defines the second operand
  18097. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18098. */
  18099. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18100. /**
  18101. * Serializes the current fresnel parameters to a JSON representation.
  18102. * @return the JSON serialization
  18103. */
  18104. serialize(): IFresnelParametersSerialized;
  18105. /**
  18106. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18107. * @param parsedFresnelParameters Define the JSON representation
  18108. * @returns the parsed parameters
  18109. */
  18110. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18111. }
  18112. }
  18113. declare module BABYLON {
  18114. /**
  18115. * This groups all the flags used to control the materials channel.
  18116. */
  18117. export class MaterialFlags {
  18118. private static _DiffuseTextureEnabled;
  18119. /**
  18120. * Are diffuse textures enabled in the application.
  18121. */
  18122. static get DiffuseTextureEnabled(): boolean;
  18123. static set DiffuseTextureEnabled(value: boolean);
  18124. private static _DetailTextureEnabled;
  18125. /**
  18126. * Are detail textures enabled in the application.
  18127. */
  18128. static get DetailTextureEnabled(): boolean;
  18129. static set DetailTextureEnabled(value: boolean);
  18130. private static _AmbientTextureEnabled;
  18131. /**
  18132. * Are ambient textures enabled in the application.
  18133. */
  18134. static get AmbientTextureEnabled(): boolean;
  18135. static set AmbientTextureEnabled(value: boolean);
  18136. private static _OpacityTextureEnabled;
  18137. /**
  18138. * Are opacity textures enabled in the application.
  18139. */
  18140. static get OpacityTextureEnabled(): boolean;
  18141. static set OpacityTextureEnabled(value: boolean);
  18142. private static _ReflectionTextureEnabled;
  18143. /**
  18144. * Are reflection textures enabled in the application.
  18145. */
  18146. static get ReflectionTextureEnabled(): boolean;
  18147. static set ReflectionTextureEnabled(value: boolean);
  18148. private static _EmissiveTextureEnabled;
  18149. /**
  18150. * Are emissive textures enabled in the application.
  18151. */
  18152. static get EmissiveTextureEnabled(): boolean;
  18153. static set EmissiveTextureEnabled(value: boolean);
  18154. private static _SpecularTextureEnabled;
  18155. /**
  18156. * Are specular textures enabled in the application.
  18157. */
  18158. static get SpecularTextureEnabled(): boolean;
  18159. static set SpecularTextureEnabled(value: boolean);
  18160. private static _BumpTextureEnabled;
  18161. /**
  18162. * Are bump textures enabled in the application.
  18163. */
  18164. static get BumpTextureEnabled(): boolean;
  18165. static set BumpTextureEnabled(value: boolean);
  18166. private static _LightmapTextureEnabled;
  18167. /**
  18168. * Are lightmap textures enabled in the application.
  18169. */
  18170. static get LightmapTextureEnabled(): boolean;
  18171. static set LightmapTextureEnabled(value: boolean);
  18172. private static _RefractionTextureEnabled;
  18173. /**
  18174. * Are refraction textures enabled in the application.
  18175. */
  18176. static get RefractionTextureEnabled(): boolean;
  18177. static set RefractionTextureEnabled(value: boolean);
  18178. private static _ColorGradingTextureEnabled;
  18179. /**
  18180. * Are color grading textures enabled in the application.
  18181. */
  18182. static get ColorGradingTextureEnabled(): boolean;
  18183. static set ColorGradingTextureEnabled(value: boolean);
  18184. private static _FresnelEnabled;
  18185. /**
  18186. * Are fresnels enabled in the application.
  18187. */
  18188. static get FresnelEnabled(): boolean;
  18189. static set FresnelEnabled(value: boolean);
  18190. private static _ClearCoatTextureEnabled;
  18191. /**
  18192. * Are clear coat textures enabled in the application.
  18193. */
  18194. static get ClearCoatTextureEnabled(): boolean;
  18195. static set ClearCoatTextureEnabled(value: boolean);
  18196. private static _ClearCoatBumpTextureEnabled;
  18197. /**
  18198. * Are clear coat bump textures enabled in the application.
  18199. */
  18200. static get ClearCoatBumpTextureEnabled(): boolean;
  18201. static set ClearCoatBumpTextureEnabled(value: boolean);
  18202. private static _ClearCoatTintTextureEnabled;
  18203. /**
  18204. * Are clear coat tint textures enabled in the application.
  18205. */
  18206. static get ClearCoatTintTextureEnabled(): boolean;
  18207. static set ClearCoatTintTextureEnabled(value: boolean);
  18208. private static _SheenTextureEnabled;
  18209. /**
  18210. * Are sheen textures enabled in the application.
  18211. */
  18212. static get SheenTextureEnabled(): boolean;
  18213. static set SheenTextureEnabled(value: boolean);
  18214. private static _AnisotropicTextureEnabled;
  18215. /**
  18216. * Are anisotropic textures enabled in the application.
  18217. */
  18218. static get AnisotropicTextureEnabled(): boolean;
  18219. static set AnisotropicTextureEnabled(value: boolean);
  18220. private static _ThicknessTextureEnabled;
  18221. /**
  18222. * Are thickness textures enabled in the application.
  18223. */
  18224. static get ThicknessTextureEnabled(): boolean;
  18225. static set ThicknessTextureEnabled(value: boolean);
  18226. }
  18227. }
  18228. declare module BABYLON {
  18229. /** @hidden */
  18230. export var defaultFragmentDeclaration: {
  18231. name: string;
  18232. shader: string;
  18233. };
  18234. }
  18235. declare module BABYLON {
  18236. /** @hidden */
  18237. export var defaultUboDeclaration: {
  18238. name: string;
  18239. shader: string;
  18240. };
  18241. }
  18242. declare module BABYLON {
  18243. /** @hidden */
  18244. export var prePassDeclaration: {
  18245. name: string;
  18246. shader: string;
  18247. };
  18248. }
  18249. declare module BABYLON {
  18250. /** @hidden */
  18251. export var lightFragmentDeclaration: {
  18252. name: string;
  18253. shader: string;
  18254. };
  18255. }
  18256. declare module BABYLON {
  18257. /** @hidden */
  18258. export var lightUboDeclaration: {
  18259. name: string;
  18260. shader: string;
  18261. };
  18262. }
  18263. declare module BABYLON {
  18264. /** @hidden */
  18265. export var lightsFragmentFunctions: {
  18266. name: string;
  18267. shader: string;
  18268. };
  18269. }
  18270. declare module BABYLON {
  18271. /** @hidden */
  18272. export var shadowsFragmentFunctions: {
  18273. name: string;
  18274. shader: string;
  18275. };
  18276. }
  18277. declare module BABYLON {
  18278. /** @hidden */
  18279. export var fresnelFunction: {
  18280. name: string;
  18281. shader: string;
  18282. };
  18283. }
  18284. declare module BABYLON {
  18285. /** @hidden */
  18286. export var bumpFragmentMainFunctions: {
  18287. name: string;
  18288. shader: string;
  18289. };
  18290. }
  18291. declare module BABYLON {
  18292. /** @hidden */
  18293. export var bumpFragmentFunctions: {
  18294. name: string;
  18295. shader: string;
  18296. };
  18297. }
  18298. declare module BABYLON {
  18299. /** @hidden */
  18300. export var logDepthDeclaration: {
  18301. name: string;
  18302. shader: string;
  18303. };
  18304. }
  18305. declare module BABYLON {
  18306. /** @hidden */
  18307. export var fogFragmentDeclaration: {
  18308. name: string;
  18309. shader: string;
  18310. };
  18311. }
  18312. declare module BABYLON {
  18313. /** @hidden */
  18314. export var bumpFragment: {
  18315. name: string;
  18316. shader: string;
  18317. };
  18318. }
  18319. declare module BABYLON {
  18320. /** @hidden */
  18321. export var depthPrePass: {
  18322. name: string;
  18323. shader: string;
  18324. };
  18325. }
  18326. declare module BABYLON {
  18327. /** @hidden */
  18328. export var lightFragment: {
  18329. name: string;
  18330. shader: string;
  18331. };
  18332. }
  18333. declare module BABYLON {
  18334. /** @hidden */
  18335. export var logDepthFragment: {
  18336. name: string;
  18337. shader: string;
  18338. };
  18339. }
  18340. declare module BABYLON {
  18341. /** @hidden */
  18342. export var fogFragment: {
  18343. name: string;
  18344. shader: string;
  18345. };
  18346. }
  18347. declare module BABYLON {
  18348. /** @hidden */
  18349. export var defaultPixelShader: {
  18350. name: string;
  18351. shader: string;
  18352. };
  18353. }
  18354. declare module BABYLON {
  18355. /** @hidden */
  18356. export var defaultVertexDeclaration: {
  18357. name: string;
  18358. shader: string;
  18359. };
  18360. }
  18361. declare module BABYLON {
  18362. /** @hidden */
  18363. export var bonesDeclaration: {
  18364. name: string;
  18365. shader: string;
  18366. };
  18367. }
  18368. declare module BABYLON {
  18369. /** @hidden */
  18370. export var instancesDeclaration: {
  18371. name: string;
  18372. shader: string;
  18373. };
  18374. }
  18375. declare module BABYLON {
  18376. /** @hidden */
  18377. export var prePassVertexDeclaration: {
  18378. name: string;
  18379. shader: string;
  18380. };
  18381. }
  18382. declare module BABYLON {
  18383. /** @hidden */
  18384. export var bumpVertexDeclaration: {
  18385. name: string;
  18386. shader: string;
  18387. };
  18388. }
  18389. declare module BABYLON {
  18390. /** @hidden */
  18391. export var fogVertexDeclaration: {
  18392. name: string;
  18393. shader: string;
  18394. };
  18395. }
  18396. declare module BABYLON {
  18397. /** @hidden */
  18398. export var morphTargetsVertexGlobalDeclaration: {
  18399. name: string;
  18400. shader: string;
  18401. };
  18402. }
  18403. declare module BABYLON {
  18404. /** @hidden */
  18405. export var morphTargetsVertexDeclaration: {
  18406. name: string;
  18407. shader: string;
  18408. };
  18409. }
  18410. declare module BABYLON {
  18411. /** @hidden */
  18412. export var morphTargetsVertex: {
  18413. name: string;
  18414. shader: string;
  18415. };
  18416. }
  18417. declare module BABYLON {
  18418. /** @hidden */
  18419. export var instancesVertex: {
  18420. name: string;
  18421. shader: string;
  18422. };
  18423. }
  18424. declare module BABYLON {
  18425. /** @hidden */
  18426. export var bonesVertex: {
  18427. name: string;
  18428. shader: string;
  18429. };
  18430. }
  18431. declare module BABYLON {
  18432. /** @hidden */
  18433. export var prePassVertex: {
  18434. name: string;
  18435. shader: string;
  18436. };
  18437. }
  18438. declare module BABYLON {
  18439. /** @hidden */
  18440. export var bumpVertex: {
  18441. name: string;
  18442. shader: string;
  18443. };
  18444. }
  18445. declare module BABYLON {
  18446. /** @hidden */
  18447. export var fogVertex: {
  18448. name: string;
  18449. shader: string;
  18450. };
  18451. }
  18452. declare module BABYLON {
  18453. /** @hidden */
  18454. export var shadowsVertex: {
  18455. name: string;
  18456. shader: string;
  18457. };
  18458. }
  18459. declare module BABYLON {
  18460. /** @hidden */
  18461. export var pointCloudVertex: {
  18462. name: string;
  18463. shader: string;
  18464. };
  18465. }
  18466. declare module BABYLON {
  18467. /** @hidden */
  18468. export var logDepthVertex: {
  18469. name: string;
  18470. shader: string;
  18471. };
  18472. }
  18473. declare module BABYLON {
  18474. /** @hidden */
  18475. export var defaultVertexShader: {
  18476. name: string;
  18477. shader: string;
  18478. };
  18479. }
  18480. declare module BABYLON {
  18481. /**
  18482. * @hidden
  18483. */
  18484. export interface IMaterialDetailMapDefines {
  18485. DETAIL: boolean;
  18486. DETAILDIRECTUV: number;
  18487. DETAIL_NORMALBLENDMETHOD: number;
  18488. /** @hidden */
  18489. _areTexturesDirty: boolean;
  18490. }
  18491. /**
  18492. * Define the code related to the detail map parameters of a material
  18493. *
  18494. * Inspired from:
  18495. * 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
  18496. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18497. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18498. */
  18499. export class DetailMapConfiguration {
  18500. private _texture;
  18501. /**
  18502. * The detail texture of the material.
  18503. */
  18504. texture: Nullable<BaseTexture>;
  18505. /**
  18506. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18507. * Bigger values mean stronger blending
  18508. */
  18509. diffuseBlendLevel: number;
  18510. /**
  18511. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18512. * Bigger values mean stronger blending. Only used with PBR materials
  18513. */
  18514. roughnessBlendLevel: number;
  18515. /**
  18516. * Defines how strong the bump effect from the detail map is
  18517. * Bigger values mean stronger effect
  18518. */
  18519. bumpLevel: number;
  18520. private _normalBlendMethod;
  18521. /**
  18522. * The method used to blend the bump and detail normals together
  18523. */
  18524. normalBlendMethod: number;
  18525. private _isEnabled;
  18526. /**
  18527. * Enable or disable the detail map on this material
  18528. */
  18529. isEnabled: boolean;
  18530. /** @hidden */
  18531. private _internalMarkAllSubMeshesAsTexturesDirty;
  18532. /** @hidden */
  18533. _markAllSubMeshesAsTexturesDirty(): void;
  18534. /**
  18535. * Instantiate a new detail map
  18536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18537. */
  18538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18539. /**
  18540. * Gets whether the submesh is ready to be used or not.
  18541. * @param defines the list of "defines" to update.
  18542. * @param scene defines the scene the material belongs to.
  18543. * @returns - boolean indicating that the submesh is ready or not.
  18544. */
  18545. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18546. /**
  18547. * Update the defines for detail map usage
  18548. * @param defines the list of "defines" to update.
  18549. * @param scene defines the scene the material belongs to.
  18550. */
  18551. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18552. /**
  18553. * Binds the material data.
  18554. * @param uniformBuffer defines the Uniform buffer to fill in.
  18555. * @param scene defines the scene the material belongs to.
  18556. * @param isFrozen defines whether the material is frozen or not.
  18557. */
  18558. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18559. /**
  18560. * Checks to see if a texture is used in the material.
  18561. * @param texture - Base texture to use.
  18562. * @returns - Boolean specifying if a texture is used in the material.
  18563. */
  18564. hasTexture(texture: BaseTexture): boolean;
  18565. /**
  18566. * Returns an array of the actively used textures.
  18567. * @param activeTextures Array of BaseTextures
  18568. */
  18569. getActiveTextures(activeTextures: BaseTexture[]): void;
  18570. /**
  18571. * Returns the animatable textures.
  18572. * @param animatables Array of animatable textures.
  18573. */
  18574. getAnimatables(animatables: IAnimatable[]): void;
  18575. /**
  18576. * Disposes the resources of the material.
  18577. * @param forceDisposeTextures - Forces the disposal of all textures.
  18578. */
  18579. dispose(forceDisposeTextures?: boolean): void;
  18580. /**
  18581. * Get the current class name useful for serialization or dynamic coding.
  18582. * @returns "DetailMap"
  18583. */
  18584. getClassName(): string;
  18585. /**
  18586. * Add the required uniforms to the current list.
  18587. * @param uniforms defines the current uniform list.
  18588. */
  18589. static AddUniforms(uniforms: string[]): void;
  18590. /**
  18591. * Add the required samplers to the current list.
  18592. * @param samplers defines the current sampler list.
  18593. */
  18594. static AddSamplers(samplers: string[]): void;
  18595. /**
  18596. * Add the required uniforms to the current buffer.
  18597. * @param uniformBuffer defines the current uniform buffer.
  18598. */
  18599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18600. /**
  18601. * Makes a duplicate of the current instance into another one.
  18602. * @param detailMap define the instance where to copy the info
  18603. */
  18604. copyTo(detailMap: DetailMapConfiguration): void;
  18605. /**
  18606. * Serializes this detail map instance
  18607. * @returns - An object with the serialized instance.
  18608. */
  18609. serialize(): any;
  18610. /**
  18611. * Parses a detail map setting from a serialized object.
  18612. * @param source - Serialized object.
  18613. * @param scene Defines the scene we are parsing for
  18614. * @param rootUrl Defines the rootUrl to load from
  18615. */
  18616. parse(source: any, scene: Scene, rootUrl: string): void;
  18617. }
  18618. }
  18619. declare module BABYLON {
  18620. /** @hidden */
  18621. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18622. MAINUV1: boolean;
  18623. MAINUV2: boolean;
  18624. DIFFUSE: boolean;
  18625. DIFFUSEDIRECTUV: number;
  18626. DETAIL: boolean;
  18627. DETAILDIRECTUV: number;
  18628. DETAIL_NORMALBLENDMETHOD: number;
  18629. AMBIENT: boolean;
  18630. AMBIENTDIRECTUV: number;
  18631. OPACITY: boolean;
  18632. OPACITYDIRECTUV: number;
  18633. OPACITYRGB: boolean;
  18634. REFLECTION: boolean;
  18635. EMISSIVE: boolean;
  18636. EMISSIVEDIRECTUV: number;
  18637. SPECULAR: boolean;
  18638. SPECULARDIRECTUV: number;
  18639. BUMP: boolean;
  18640. BUMPDIRECTUV: number;
  18641. PARALLAX: boolean;
  18642. PARALLAXOCCLUSION: boolean;
  18643. SPECULAROVERALPHA: boolean;
  18644. CLIPPLANE: boolean;
  18645. CLIPPLANE2: boolean;
  18646. CLIPPLANE3: boolean;
  18647. CLIPPLANE4: boolean;
  18648. CLIPPLANE5: boolean;
  18649. CLIPPLANE6: boolean;
  18650. ALPHATEST: boolean;
  18651. DEPTHPREPASS: boolean;
  18652. ALPHAFROMDIFFUSE: boolean;
  18653. POINTSIZE: boolean;
  18654. FOG: boolean;
  18655. SPECULARTERM: boolean;
  18656. DIFFUSEFRESNEL: boolean;
  18657. OPACITYFRESNEL: boolean;
  18658. REFLECTIONFRESNEL: boolean;
  18659. REFRACTIONFRESNEL: boolean;
  18660. EMISSIVEFRESNEL: boolean;
  18661. FRESNEL: boolean;
  18662. NORMAL: boolean;
  18663. UV1: boolean;
  18664. UV2: boolean;
  18665. VERTEXCOLOR: boolean;
  18666. VERTEXALPHA: boolean;
  18667. NUM_BONE_INFLUENCERS: number;
  18668. BonesPerMesh: number;
  18669. BONETEXTURE: boolean;
  18670. BONES_VELOCITY_ENABLED: boolean;
  18671. INSTANCES: boolean;
  18672. THIN_INSTANCES: boolean;
  18673. GLOSSINESS: boolean;
  18674. ROUGHNESS: boolean;
  18675. EMISSIVEASILLUMINATION: boolean;
  18676. LINKEMISSIVEWITHDIFFUSE: boolean;
  18677. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18678. LIGHTMAP: boolean;
  18679. LIGHTMAPDIRECTUV: number;
  18680. OBJECTSPACE_NORMALMAP: boolean;
  18681. USELIGHTMAPASSHADOWMAP: boolean;
  18682. REFLECTIONMAP_3D: boolean;
  18683. REFLECTIONMAP_SPHERICAL: boolean;
  18684. REFLECTIONMAP_PLANAR: boolean;
  18685. REFLECTIONMAP_CUBIC: boolean;
  18686. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18687. REFLECTIONMAP_PROJECTION: boolean;
  18688. REFLECTIONMAP_SKYBOX: boolean;
  18689. REFLECTIONMAP_EXPLICIT: boolean;
  18690. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18691. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18692. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18693. INVERTCUBICMAP: boolean;
  18694. LOGARITHMICDEPTH: boolean;
  18695. REFRACTION: boolean;
  18696. REFRACTIONMAP_3D: boolean;
  18697. REFLECTIONOVERALPHA: boolean;
  18698. TWOSIDEDLIGHTING: boolean;
  18699. SHADOWFLOAT: boolean;
  18700. MORPHTARGETS: boolean;
  18701. MORPHTARGETS_NORMAL: boolean;
  18702. MORPHTARGETS_TANGENT: boolean;
  18703. MORPHTARGETS_UV: boolean;
  18704. NUM_MORPH_INFLUENCERS: number;
  18705. NONUNIFORMSCALING: boolean;
  18706. PREMULTIPLYALPHA: boolean;
  18707. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18708. ALPHABLEND: boolean;
  18709. PREPASS: boolean;
  18710. PREPASS_IRRADIANCE: boolean;
  18711. PREPASS_IRRADIANCE_INDEX: number;
  18712. PREPASS_ALBEDO: boolean;
  18713. PREPASS_ALBEDO_INDEX: number;
  18714. PREPASS_DEPTHNORMAL: boolean;
  18715. PREPASS_DEPTHNORMAL_INDEX: number;
  18716. PREPASS_POSITION: boolean;
  18717. PREPASS_POSITION_INDEX: number;
  18718. PREPASS_VELOCITY: boolean;
  18719. PREPASS_VELOCITY_INDEX: number;
  18720. PREPASS_REFLECTIVITY: boolean;
  18721. PREPASS_REFLECTIVITY_INDEX: number;
  18722. SCENE_MRT_COUNT: number;
  18723. RGBDLIGHTMAP: boolean;
  18724. RGBDREFLECTION: boolean;
  18725. RGBDREFRACTION: boolean;
  18726. IMAGEPROCESSING: boolean;
  18727. VIGNETTE: boolean;
  18728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18729. VIGNETTEBLENDMODEOPAQUE: boolean;
  18730. TONEMAPPING: boolean;
  18731. TONEMAPPING_ACES: boolean;
  18732. CONTRAST: boolean;
  18733. COLORCURVES: boolean;
  18734. COLORGRADING: boolean;
  18735. COLORGRADING3D: boolean;
  18736. SAMPLER3DGREENDEPTH: boolean;
  18737. SAMPLER3DBGRMAP: boolean;
  18738. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18739. MULTIVIEW: boolean;
  18740. /**
  18741. * If the reflection texture on this material is in linear color space
  18742. * @hidden
  18743. */
  18744. IS_REFLECTION_LINEAR: boolean;
  18745. /**
  18746. * If the refraction texture on this material is in linear color space
  18747. * @hidden
  18748. */
  18749. IS_REFRACTION_LINEAR: boolean;
  18750. EXPOSURE: boolean;
  18751. constructor();
  18752. setReflectionMode(modeToEnable: string): void;
  18753. }
  18754. /**
  18755. * This is the default material used in Babylon. It is the best trade off between quality
  18756. * and performances.
  18757. * @see https://doc.babylonjs.com/babylon101/materials
  18758. */
  18759. export class StandardMaterial extends PushMaterial {
  18760. private _diffuseTexture;
  18761. /**
  18762. * The basic texture of the material as viewed under a light.
  18763. */
  18764. diffuseTexture: Nullable<BaseTexture>;
  18765. private _ambientTexture;
  18766. /**
  18767. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18768. */
  18769. ambientTexture: Nullable<BaseTexture>;
  18770. private _opacityTexture;
  18771. /**
  18772. * Define the transparency of the material from a texture.
  18773. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18774. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18775. */
  18776. opacityTexture: Nullable<BaseTexture>;
  18777. private _reflectionTexture;
  18778. /**
  18779. * Define the texture used to display the reflection.
  18780. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18781. */
  18782. reflectionTexture: Nullable<BaseTexture>;
  18783. private _emissiveTexture;
  18784. /**
  18785. * Define texture of the material as if self lit.
  18786. * This will be mixed in the final result even in the absence of light.
  18787. */
  18788. emissiveTexture: Nullable<BaseTexture>;
  18789. private _specularTexture;
  18790. /**
  18791. * Define how the color and intensity of the highlight given by the light in the material.
  18792. */
  18793. specularTexture: Nullable<BaseTexture>;
  18794. private _bumpTexture;
  18795. /**
  18796. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18797. * 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.
  18798. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18799. */
  18800. bumpTexture: Nullable<BaseTexture>;
  18801. private _lightmapTexture;
  18802. /**
  18803. * Complex lighting can be computationally expensive to compute at runtime.
  18804. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18805. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18806. */
  18807. lightmapTexture: Nullable<BaseTexture>;
  18808. private _refractionTexture;
  18809. /**
  18810. * Define the texture used to display the refraction.
  18811. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18812. */
  18813. refractionTexture: Nullable<BaseTexture>;
  18814. /**
  18815. * The color of the material lit by the environmental background lighting.
  18816. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18817. */
  18818. ambientColor: Color3;
  18819. /**
  18820. * The basic color of the material as viewed under a light.
  18821. */
  18822. diffuseColor: Color3;
  18823. /**
  18824. * Define how the color and intensity of the highlight given by the light in the material.
  18825. */
  18826. specularColor: Color3;
  18827. /**
  18828. * Define the color of the material as if self lit.
  18829. * This will be mixed in the final result even in the absence of light.
  18830. */
  18831. emissiveColor: Color3;
  18832. /**
  18833. * Defines how sharp are the highlights in the material.
  18834. * The bigger the value the sharper giving a more glossy feeling to the result.
  18835. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18836. */
  18837. specularPower: number;
  18838. private _useAlphaFromDiffuseTexture;
  18839. /**
  18840. * Does the transparency come from the diffuse texture alpha channel.
  18841. */
  18842. useAlphaFromDiffuseTexture: boolean;
  18843. private _useEmissiveAsIllumination;
  18844. /**
  18845. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18846. */
  18847. useEmissiveAsIllumination: boolean;
  18848. private _linkEmissiveWithDiffuse;
  18849. /**
  18850. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18851. * the emissive level when the final color is close to one.
  18852. */
  18853. linkEmissiveWithDiffuse: boolean;
  18854. private _useSpecularOverAlpha;
  18855. /**
  18856. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18857. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18858. */
  18859. useSpecularOverAlpha: boolean;
  18860. private _useReflectionOverAlpha;
  18861. /**
  18862. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18863. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18864. */
  18865. useReflectionOverAlpha: boolean;
  18866. private _disableLighting;
  18867. /**
  18868. * Does lights from the scene impacts this material.
  18869. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18870. */
  18871. disableLighting: boolean;
  18872. private _useObjectSpaceNormalMap;
  18873. /**
  18874. * Allows using an object space normal map (instead of tangent space).
  18875. */
  18876. useObjectSpaceNormalMap: boolean;
  18877. private _useParallax;
  18878. /**
  18879. * Is parallax enabled or not.
  18880. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18881. */
  18882. useParallax: boolean;
  18883. private _useParallaxOcclusion;
  18884. /**
  18885. * Is parallax occlusion enabled or not.
  18886. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18887. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18888. */
  18889. useParallaxOcclusion: boolean;
  18890. /**
  18891. * 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.
  18892. */
  18893. parallaxScaleBias: number;
  18894. private _roughness;
  18895. /**
  18896. * Helps to define how blurry the reflections should appears in the material.
  18897. */
  18898. roughness: number;
  18899. /**
  18900. * In case of refraction, define the value of the index of refraction.
  18901. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18902. */
  18903. indexOfRefraction: number;
  18904. /**
  18905. * Invert the refraction texture alongside the y axis.
  18906. * It can be useful with procedural textures or probe for instance.
  18907. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18908. */
  18909. invertRefractionY: boolean;
  18910. /**
  18911. * Defines the alpha limits in alpha test mode.
  18912. */
  18913. alphaCutOff: number;
  18914. private _useLightmapAsShadowmap;
  18915. /**
  18916. * In case of light mapping, define whether the map contains light or shadow informations.
  18917. */
  18918. useLightmapAsShadowmap: boolean;
  18919. private _diffuseFresnelParameters;
  18920. /**
  18921. * Define the diffuse fresnel parameters of the material.
  18922. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18923. */
  18924. diffuseFresnelParameters: FresnelParameters;
  18925. private _opacityFresnelParameters;
  18926. /**
  18927. * Define the opacity fresnel parameters of the material.
  18928. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18929. */
  18930. opacityFresnelParameters: FresnelParameters;
  18931. private _reflectionFresnelParameters;
  18932. /**
  18933. * Define the reflection fresnel parameters of the material.
  18934. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18935. */
  18936. reflectionFresnelParameters: FresnelParameters;
  18937. private _refractionFresnelParameters;
  18938. /**
  18939. * Define the refraction fresnel parameters of the material.
  18940. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18941. */
  18942. refractionFresnelParameters: FresnelParameters;
  18943. private _emissiveFresnelParameters;
  18944. /**
  18945. * Define the emissive fresnel parameters of the material.
  18946. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18947. */
  18948. emissiveFresnelParameters: FresnelParameters;
  18949. private _useReflectionFresnelFromSpecular;
  18950. /**
  18951. * If true automatically deducts the fresnels values from the material specularity.
  18952. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18953. */
  18954. useReflectionFresnelFromSpecular: boolean;
  18955. private _useGlossinessFromSpecularMapAlpha;
  18956. /**
  18957. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18958. */
  18959. useGlossinessFromSpecularMapAlpha: boolean;
  18960. private _maxSimultaneousLights;
  18961. /**
  18962. * Defines the maximum number of lights that can be used in the material
  18963. */
  18964. maxSimultaneousLights: number;
  18965. private _invertNormalMapX;
  18966. /**
  18967. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18968. */
  18969. invertNormalMapX: boolean;
  18970. private _invertNormalMapY;
  18971. /**
  18972. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18973. */
  18974. invertNormalMapY: boolean;
  18975. private _twoSidedLighting;
  18976. /**
  18977. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18978. */
  18979. twoSidedLighting: boolean;
  18980. /**
  18981. * Default configuration related to image processing available in the standard Material.
  18982. */
  18983. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18984. /**
  18985. * Gets the image processing configuration used either in this material.
  18986. */
  18987. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18988. /**
  18989. * Sets the Default image processing configuration used either in the this material.
  18990. *
  18991. * If sets to null, the scene one is in use.
  18992. */
  18993. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18994. /**
  18995. * Keep track of the image processing observer to allow dispose and replace.
  18996. */
  18997. private _imageProcessingObserver;
  18998. /**
  18999. * Attaches a new image processing configuration to the Standard Material.
  19000. * @param configuration
  19001. */
  19002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19003. /**
  19004. * Defines additionnal PrePass parameters for the material.
  19005. */
  19006. readonly prePassConfiguration: PrePassConfiguration;
  19007. /**
  19008. * Gets wether the color curves effect is enabled.
  19009. */
  19010. get cameraColorCurvesEnabled(): boolean;
  19011. /**
  19012. * Sets wether the color curves effect is enabled.
  19013. */
  19014. set cameraColorCurvesEnabled(value: boolean);
  19015. /**
  19016. * Gets wether the color grading effect is enabled.
  19017. */
  19018. get cameraColorGradingEnabled(): boolean;
  19019. /**
  19020. * Gets wether the color grading effect is enabled.
  19021. */
  19022. set cameraColorGradingEnabled(value: boolean);
  19023. /**
  19024. * Gets wether tonemapping is enabled or not.
  19025. */
  19026. get cameraToneMappingEnabled(): boolean;
  19027. /**
  19028. * Sets wether tonemapping is enabled or not
  19029. */
  19030. set cameraToneMappingEnabled(value: boolean);
  19031. /**
  19032. * The camera exposure used on this material.
  19033. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19034. * This corresponds to a photographic exposure.
  19035. */
  19036. get cameraExposure(): number;
  19037. /**
  19038. * The camera exposure used on this material.
  19039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19040. * This corresponds to a photographic exposure.
  19041. */
  19042. set cameraExposure(value: number);
  19043. /**
  19044. * Gets The camera contrast used on this material.
  19045. */
  19046. get cameraContrast(): number;
  19047. /**
  19048. * Sets The camera contrast used on this material.
  19049. */
  19050. set cameraContrast(value: number);
  19051. /**
  19052. * Gets the Color Grading 2D Lookup Texture.
  19053. */
  19054. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19055. /**
  19056. * Sets the Color Grading 2D Lookup Texture.
  19057. */
  19058. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19059. /**
  19060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19062. * 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;
  19063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19064. */
  19065. get cameraColorCurves(): Nullable<ColorCurves>;
  19066. /**
  19067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19069. * 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;
  19070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19071. */
  19072. set cameraColorCurves(value: Nullable<ColorCurves>);
  19073. /**
  19074. * Can this material render to several textures at once
  19075. */
  19076. get canRenderToMRT(): boolean;
  19077. /**
  19078. * Defines the detail map parameters for the material.
  19079. */
  19080. readonly detailMap: DetailMapConfiguration;
  19081. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19082. protected _worldViewProjectionMatrix: Matrix;
  19083. protected _globalAmbientColor: Color3;
  19084. protected _useLogarithmicDepth: boolean;
  19085. protected _rebuildInParallel: boolean;
  19086. /**
  19087. * Instantiates a new standard material.
  19088. * This is the default material used in Babylon. It is the best trade off between quality
  19089. * and performances.
  19090. * @see https://doc.babylonjs.com/babylon101/materials
  19091. * @param name Define the name of the material in the scene
  19092. * @param scene Define the scene the material belong to
  19093. */
  19094. constructor(name: string, scene: Scene);
  19095. /**
  19096. * Gets a boolean indicating that current material needs to register RTT
  19097. */
  19098. get hasRenderTargetTextures(): boolean;
  19099. /**
  19100. * Gets the current class name of the material e.g. "StandardMaterial"
  19101. * Mainly use in serialization.
  19102. * @returns the class name
  19103. */
  19104. getClassName(): string;
  19105. /**
  19106. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19107. * You can try switching to logarithmic depth.
  19108. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19109. */
  19110. get useLogarithmicDepth(): boolean;
  19111. set useLogarithmicDepth(value: boolean);
  19112. /**
  19113. * Specifies if the material will require alpha blending
  19114. * @returns a boolean specifying if alpha blending is needed
  19115. */
  19116. needAlphaBlending(): boolean;
  19117. /**
  19118. * Specifies if this material should be rendered in alpha test mode
  19119. * @returns a boolean specifying if an alpha test is needed.
  19120. */
  19121. needAlphaTesting(): boolean;
  19122. /**
  19123. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19124. */
  19125. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19126. /**
  19127. * Specifies whether or not there is a usable alpha channel for transparency.
  19128. */
  19129. protected _hasAlphaChannel(): boolean;
  19130. /**
  19131. * Get the texture used for alpha test purpose.
  19132. * @returns the diffuse texture in case of the standard material.
  19133. */
  19134. getAlphaTestTexture(): Nullable<BaseTexture>;
  19135. /**
  19136. * Get if the submesh is ready to be used and all its information available.
  19137. * Child classes can use it to update shaders
  19138. * @param mesh defines the mesh to check
  19139. * @param subMesh defines which submesh to check
  19140. * @param useInstances specifies that instances should be used
  19141. * @returns a boolean indicating that the submesh is ready or not
  19142. */
  19143. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19144. /**
  19145. * Builds the material UBO layouts.
  19146. * Used internally during the effect preparation.
  19147. */
  19148. buildUniformLayout(): void;
  19149. /**
  19150. * Unbinds the material from the mesh
  19151. */
  19152. unbind(): void;
  19153. /**
  19154. * Binds the submesh to this material by preparing the effect and shader to draw
  19155. * @param world defines the world transformation matrix
  19156. * @param mesh defines the mesh containing the submesh
  19157. * @param subMesh defines the submesh to bind the material to
  19158. */
  19159. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19160. /**
  19161. * Get the list of animatables in the material.
  19162. * @returns the list of animatables object used in the material
  19163. */
  19164. getAnimatables(): IAnimatable[];
  19165. /**
  19166. * Gets the active textures from the material
  19167. * @returns an array of textures
  19168. */
  19169. getActiveTextures(): BaseTexture[];
  19170. /**
  19171. * Specifies if the material uses a texture
  19172. * @param texture defines the texture to check against the material
  19173. * @returns a boolean specifying if the material uses the texture
  19174. */
  19175. hasTexture(texture: BaseTexture): boolean;
  19176. /**
  19177. * Disposes the material
  19178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19180. */
  19181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19182. /**
  19183. * Makes a duplicate of the material, and gives it a new name
  19184. * @param name defines the new name for the duplicated material
  19185. * @returns the cloned material
  19186. */
  19187. clone(name: string): StandardMaterial;
  19188. /**
  19189. * Serializes this material in a JSON representation
  19190. * @returns the serialized material object
  19191. */
  19192. serialize(): any;
  19193. /**
  19194. * Creates a standard material from parsed material data
  19195. * @param source defines the JSON representation of the material
  19196. * @param scene defines the hosting scene
  19197. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19198. * @returns a new standard material
  19199. */
  19200. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19201. /**
  19202. * Are diffuse textures enabled in the application.
  19203. */
  19204. static get DiffuseTextureEnabled(): boolean;
  19205. static set DiffuseTextureEnabled(value: boolean);
  19206. /**
  19207. * Are detail textures enabled in the application.
  19208. */
  19209. static get DetailTextureEnabled(): boolean;
  19210. static set DetailTextureEnabled(value: boolean);
  19211. /**
  19212. * Are ambient textures enabled in the application.
  19213. */
  19214. static get AmbientTextureEnabled(): boolean;
  19215. static set AmbientTextureEnabled(value: boolean);
  19216. /**
  19217. * Are opacity textures enabled in the application.
  19218. */
  19219. static get OpacityTextureEnabled(): boolean;
  19220. static set OpacityTextureEnabled(value: boolean);
  19221. /**
  19222. * Are reflection textures enabled in the application.
  19223. */
  19224. static get ReflectionTextureEnabled(): boolean;
  19225. static set ReflectionTextureEnabled(value: boolean);
  19226. /**
  19227. * Are emissive textures enabled in the application.
  19228. */
  19229. static get EmissiveTextureEnabled(): boolean;
  19230. static set EmissiveTextureEnabled(value: boolean);
  19231. /**
  19232. * Are specular textures enabled in the application.
  19233. */
  19234. static get SpecularTextureEnabled(): boolean;
  19235. static set SpecularTextureEnabled(value: boolean);
  19236. /**
  19237. * Are bump textures enabled in the application.
  19238. */
  19239. static get BumpTextureEnabled(): boolean;
  19240. static set BumpTextureEnabled(value: boolean);
  19241. /**
  19242. * Are lightmap textures enabled in the application.
  19243. */
  19244. static get LightmapTextureEnabled(): boolean;
  19245. static set LightmapTextureEnabled(value: boolean);
  19246. /**
  19247. * Are refraction textures enabled in the application.
  19248. */
  19249. static get RefractionTextureEnabled(): boolean;
  19250. static set RefractionTextureEnabled(value: boolean);
  19251. /**
  19252. * Are color grading textures enabled in the application.
  19253. */
  19254. static get ColorGradingTextureEnabled(): boolean;
  19255. static set ColorGradingTextureEnabled(value: boolean);
  19256. /**
  19257. * Are fresnels enabled in the application.
  19258. */
  19259. static get FresnelEnabled(): boolean;
  19260. static set FresnelEnabled(value: boolean);
  19261. }
  19262. }
  19263. declare module BABYLON {
  19264. /** @hidden */
  19265. export var rgbdDecodePixelShader: {
  19266. name: string;
  19267. shader: string;
  19268. };
  19269. }
  19270. declare module BABYLON {
  19271. /**
  19272. * Class used to host RGBD texture specific utilities
  19273. */
  19274. export class RGBDTextureTools {
  19275. /**
  19276. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19277. * @param texture the texture to expand.
  19278. */
  19279. static ExpandRGBDTexture(texture: Texture): void;
  19280. }
  19281. }
  19282. declare module BABYLON {
  19283. /**
  19284. * Class used to host texture specific utilities
  19285. */
  19286. export class BRDFTextureTools {
  19287. /**
  19288. * Prevents texture cache collision
  19289. */
  19290. private static _instanceNumber;
  19291. /**
  19292. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19293. * @param scene defines the hosting scene
  19294. * @returns the environment BRDF texture
  19295. */
  19296. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19297. private static _environmentBRDFBase64Texture;
  19298. }
  19299. }
  19300. declare module BABYLON {
  19301. /**
  19302. * @hidden
  19303. */
  19304. export interface IMaterialClearCoatDefines {
  19305. CLEARCOAT: boolean;
  19306. CLEARCOAT_DEFAULTIOR: boolean;
  19307. CLEARCOAT_TEXTURE: boolean;
  19308. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19309. CLEARCOAT_TEXTUREDIRECTUV: number;
  19310. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19311. CLEARCOAT_BUMP: boolean;
  19312. CLEARCOAT_BUMPDIRECTUV: number;
  19313. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19314. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19315. CLEARCOAT_REMAP_F0: boolean;
  19316. CLEARCOAT_TINT: boolean;
  19317. CLEARCOAT_TINT_TEXTURE: boolean;
  19318. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19319. /** @hidden */
  19320. _areTexturesDirty: boolean;
  19321. }
  19322. /**
  19323. * Define the code related to the clear coat parameters of the pbr material.
  19324. */
  19325. export class PBRClearCoatConfiguration {
  19326. /**
  19327. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19328. * The default fits with a polyurethane material.
  19329. * @hidden
  19330. */
  19331. static readonly _DefaultIndexOfRefraction: number;
  19332. private _isEnabled;
  19333. /**
  19334. * Defines if the clear coat is enabled in the material.
  19335. */
  19336. isEnabled: boolean;
  19337. /**
  19338. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19339. */
  19340. intensity: number;
  19341. /**
  19342. * Defines the clear coat layer roughness.
  19343. */
  19344. roughness: number;
  19345. private _indexOfRefraction;
  19346. /**
  19347. * Defines the index of refraction of the clear coat.
  19348. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19349. * The default fits with a polyurethane material.
  19350. * Changing the default value is more performance intensive.
  19351. */
  19352. indexOfRefraction: number;
  19353. private _texture;
  19354. /**
  19355. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19356. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19357. * if textureRoughness is not empty, else no texture roughness is used
  19358. */
  19359. texture: Nullable<BaseTexture>;
  19360. private _useRoughnessFromMainTexture;
  19361. /**
  19362. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19363. * If false, the green channel from textureRoughness is used for roughness
  19364. */
  19365. useRoughnessFromMainTexture: boolean;
  19366. private _textureRoughness;
  19367. /**
  19368. * Stores the clear coat roughness in a texture (green channel)
  19369. * Not used if useRoughnessFromMainTexture is true
  19370. */
  19371. textureRoughness: Nullable<BaseTexture>;
  19372. private _remapF0OnInterfaceChange;
  19373. /**
  19374. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19375. */
  19376. remapF0OnInterfaceChange: boolean;
  19377. private _bumpTexture;
  19378. /**
  19379. * Define the clear coat specific bump texture.
  19380. */
  19381. bumpTexture: Nullable<BaseTexture>;
  19382. private _isTintEnabled;
  19383. /**
  19384. * Defines if the clear coat tint is enabled in the material.
  19385. */
  19386. isTintEnabled: boolean;
  19387. /**
  19388. * Defines the clear coat tint of the material.
  19389. * This is only use if tint is enabled
  19390. */
  19391. tintColor: Color3;
  19392. /**
  19393. * Defines the distance at which the tint color should be found in the
  19394. * clear coat media.
  19395. * This is only use if tint is enabled
  19396. */
  19397. tintColorAtDistance: number;
  19398. /**
  19399. * Defines the clear coat layer thickness.
  19400. * This is only use if tint is enabled
  19401. */
  19402. tintThickness: number;
  19403. private _tintTexture;
  19404. /**
  19405. * Stores the clear tint values in a texture.
  19406. * rgb is tint
  19407. * a is a thickness factor
  19408. */
  19409. tintTexture: Nullable<BaseTexture>;
  19410. /** @hidden */
  19411. private _internalMarkAllSubMeshesAsTexturesDirty;
  19412. /** @hidden */
  19413. _markAllSubMeshesAsTexturesDirty(): void;
  19414. /**
  19415. * Instantiate a new istance of clear coat configuration.
  19416. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19417. */
  19418. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19419. /**
  19420. * Gets wehter the submesh is ready to be used or not.
  19421. * @param defines the list of "defines" to update.
  19422. * @param scene defines the scene the material belongs to.
  19423. * @param engine defines the engine the material belongs to.
  19424. * @param disableBumpMap defines wether the material disables bump or not.
  19425. * @returns - boolean indicating that the submesh is ready or not.
  19426. */
  19427. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19428. /**
  19429. * Checks to see if a texture is used in the material.
  19430. * @param defines the list of "defines" to update.
  19431. * @param scene defines the scene to the material belongs to.
  19432. */
  19433. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19434. /**
  19435. * Binds the material data.
  19436. * @param uniformBuffer defines the Uniform buffer to fill in.
  19437. * @param scene defines the scene the material belongs to.
  19438. * @param engine defines the engine the material belongs to.
  19439. * @param disableBumpMap defines wether the material disables bump or not.
  19440. * @param isFrozen defines wether the material is frozen or not.
  19441. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19442. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19443. * @param subMesh the submesh to bind data for
  19444. */
  19445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19446. /**
  19447. * Checks to see if a texture is used in the material.
  19448. * @param texture - Base texture to use.
  19449. * @returns - Boolean specifying if a texture is used in the material.
  19450. */
  19451. hasTexture(texture: BaseTexture): boolean;
  19452. /**
  19453. * Returns an array of the actively used textures.
  19454. * @param activeTextures Array of BaseTextures
  19455. */
  19456. getActiveTextures(activeTextures: BaseTexture[]): void;
  19457. /**
  19458. * Returns the animatable textures.
  19459. * @param animatables Array of animatable textures.
  19460. */
  19461. getAnimatables(animatables: IAnimatable[]): void;
  19462. /**
  19463. * Disposes the resources of the material.
  19464. * @param forceDisposeTextures - Forces the disposal of all textures.
  19465. */
  19466. dispose(forceDisposeTextures?: boolean): void;
  19467. /**
  19468. * Get the current class name of the texture useful for serialization or dynamic coding.
  19469. * @returns "PBRClearCoatConfiguration"
  19470. */
  19471. getClassName(): string;
  19472. /**
  19473. * Add fallbacks to the effect fallbacks list.
  19474. * @param defines defines the Base texture to use.
  19475. * @param fallbacks defines the current fallback list.
  19476. * @param currentRank defines the current fallback rank.
  19477. * @returns the new fallback rank.
  19478. */
  19479. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19480. /**
  19481. * Add the required uniforms to the current list.
  19482. * @param uniforms defines the current uniform list.
  19483. */
  19484. static AddUniforms(uniforms: string[]): void;
  19485. /**
  19486. * Add the required samplers to the current list.
  19487. * @param samplers defines the current sampler list.
  19488. */
  19489. static AddSamplers(samplers: string[]): void;
  19490. /**
  19491. * Add the required uniforms to the current buffer.
  19492. * @param uniformBuffer defines the current uniform buffer.
  19493. */
  19494. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19495. /**
  19496. * Makes a duplicate of the current configuration into another one.
  19497. * @param clearCoatConfiguration define the config where to copy the info
  19498. */
  19499. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19500. /**
  19501. * Serializes this clear coat configuration.
  19502. * @returns - An object with the serialized config.
  19503. */
  19504. serialize(): any;
  19505. /**
  19506. * Parses a anisotropy Configuration from a serialized object.
  19507. * @param source - Serialized object.
  19508. * @param scene Defines the scene we are parsing for
  19509. * @param rootUrl Defines the rootUrl to load from
  19510. */
  19511. parse(source: any, scene: Scene, rootUrl: string): void;
  19512. }
  19513. }
  19514. declare module BABYLON {
  19515. /**
  19516. * @hidden
  19517. */
  19518. export interface IMaterialAnisotropicDefines {
  19519. ANISOTROPIC: boolean;
  19520. ANISOTROPIC_TEXTURE: boolean;
  19521. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19522. MAINUV1: boolean;
  19523. _areTexturesDirty: boolean;
  19524. _needUVs: boolean;
  19525. }
  19526. /**
  19527. * Define the code related to the anisotropic parameters of the pbr material.
  19528. */
  19529. export class PBRAnisotropicConfiguration {
  19530. private _isEnabled;
  19531. /**
  19532. * Defines if the anisotropy is enabled in the material.
  19533. */
  19534. isEnabled: boolean;
  19535. /**
  19536. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19537. */
  19538. intensity: number;
  19539. /**
  19540. * Defines if the effect is along the tangents, bitangents or in between.
  19541. * By default, the effect is "strectching" the highlights along the tangents.
  19542. */
  19543. direction: Vector2;
  19544. private _texture;
  19545. /**
  19546. * Stores the anisotropy values in a texture.
  19547. * rg is direction (like normal from -1 to 1)
  19548. * b is a intensity
  19549. */
  19550. texture: Nullable<BaseTexture>;
  19551. /** @hidden */
  19552. private _internalMarkAllSubMeshesAsTexturesDirty;
  19553. /** @hidden */
  19554. _markAllSubMeshesAsTexturesDirty(): void;
  19555. /**
  19556. * Instantiate a new istance of anisotropy configuration.
  19557. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19558. */
  19559. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19560. /**
  19561. * Specifies that the submesh is ready to be used.
  19562. * @param defines the list of "defines" to update.
  19563. * @param scene defines the scene the material belongs to.
  19564. * @returns - boolean indicating that the submesh is ready or not.
  19565. */
  19566. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19567. /**
  19568. * Checks to see if a texture is used in the material.
  19569. * @param defines the list of "defines" to update.
  19570. * @param mesh the mesh we are preparing the defines for.
  19571. * @param scene defines the scene the material belongs to.
  19572. */
  19573. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19574. /**
  19575. * Binds the material data.
  19576. * @param uniformBuffer defines the Uniform buffer to fill in.
  19577. * @param scene defines the scene the material belongs to.
  19578. * @param isFrozen defines wether the material is frozen or not.
  19579. */
  19580. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19581. /**
  19582. * Checks to see if a texture is used in the material.
  19583. * @param texture - Base texture to use.
  19584. * @returns - Boolean specifying if a texture is used in the material.
  19585. */
  19586. hasTexture(texture: BaseTexture): boolean;
  19587. /**
  19588. * Returns an array of the actively used textures.
  19589. * @param activeTextures Array of BaseTextures
  19590. */
  19591. getActiveTextures(activeTextures: BaseTexture[]): void;
  19592. /**
  19593. * Returns the animatable textures.
  19594. * @param animatables Array of animatable textures.
  19595. */
  19596. getAnimatables(animatables: IAnimatable[]): void;
  19597. /**
  19598. * Disposes the resources of the material.
  19599. * @param forceDisposeTextures - Forces the disposal of all textures.
  19600. */
  19601. dispose(forceDisposeTextures?: boolean): void;
  19602. /**
  19603. * Get the current class name of the texture useful for serialization or dynamic coding.
  19604. * @returns "PBRAnisotropicConfiguration"
  19605. */
  19606. getClassName(): string;
  19607. /**
  19608. * Add fallbacks to the effect fallbacks list.
  19609. * @param defines defines the Base texture to use.
  19610. * @param fallbacks defines the current fallback list.
  19611. * @param currentRank defines the current fallback rank.
  19612. * @returns the new fallback rank.
  19613. */
  19614. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19615. /**
  19616. * Add the required uniforms to the current list.
  19617. * @param uniforms defines the current uniform list.
  19618. */
  19619. static AddUniforms(uniforms: string[]): void;
  19620. /**
  19621. * Add the required uniforms to the current buffer.
  19622. * @param uniformBuffer defines the current uniform buffer.
  19623. */
  19624. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19625. /**
  19626. * Add the required samplers to the current list.
  19627. * @param samplers defines the current sampler list.
  19628. */
  19629. static AddSamplers(samplers: string[]): void;
  19630. /**
  19631. * Makes a duplicate of the current configuration into another one.
  19632. * @param anisotropicConfiguration define the config where to copy the info
  19633. */
  19634. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19635. /**
  19636. * Serializes this anisotropy configuration.
  19637. * @returns - An object with the serialized config.
  19638. */
  19639. serialize(): any;
  19640. /**
  19641. * Parses a anisotropy Configuration from a serialized object.
  19642. * @param source - Serialized object.
  19643. * @param scene Defines the scene we are parsing for
  19644. * @param rootUrl Defines the rootUrl to load from
  19645. */
  19646. parse(source: any, scene: Scene, rootUrl: string): void;
  19647. }
  19648. }
  19649. declare module BABYLON {
  19650. /**
  19651. * @hidden
  19652. */
  19653. export interface IMaterialBRDFDefines {
  19654. BRDF_V_HEIGHT_CORRELATED: boolean;
  19655. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19656. SPHERICAL_HARMONICS: boolean;
  19657. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19658. /** @hidden */
  19659. _areMiscDirty: boolean;
  19660. }
  19661. /**
  19662. * Define the code related to the BRDF parameters of the pbr material.
  19663. */
  19664. export class PBRBRDFConfiguration {
  19665. /**
  19666. * Default value used for the energy conservation.
  19667. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19668. */
  19669. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19670. /**
  19671. * Default value used for the Smith Visibility Height Correlated mode.
  19672. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19673. */
  19674. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19675. /**
  19676. * Default value used for the IBL diffuse part.
  19677. * This can help switching back to the polynomials mode globally which is a tiny bit
  19678. * less GPU intensive at the drawback of a lower quality.
  19679. */
  19680. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19681. /**
  19682. * Default value used for activating energy conservation for the specular workflow.
  19683. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19684. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19685. */
  19686. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19687. private _useEnergyConservation;
  19688. /**
  19689. * Defines if the material uses energy conservation.
  19690. */
  19691. useEnergyConservation: boolean;
  19692. private _useSmithVisibilityHeightCorrelated;
  19693. /**
  19694. * LEGACY Mode set to false
  19695. * Defines if the material uses height smith correlated visibility term.
  19696. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19697. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19698. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19699. * Not relying on height correlated will also disable energy conservation.
  19700. */
  19701. useSmithVisibilityHeightCorrelated: boolean;
  19702. private _useSphericalHarmonics;
  19703. /**
  19704. * LEGACY Mode set to false
  19705. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19706. * diffuse part of the IBL.
  19707. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19708. * to the ground truth.
  19709. */
  19710. useSphericalHarmonics: boolean;
  19711. private _useSpecularGlossinessInputEnergyConservation;
  19712. /**
  19713. * Defines if the material uses energy conservation, when the specular workflow is active.
  19714. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19715. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19716. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19717. */
  19718. useSpecularGlossinessInputEnergyConservation: boolean;
  19719. /** @hidden */
  19720. private _internalMarkAllSubMeshesAsMiscDirty;
  19721. /** @hidden */
  19722. _markAllSubMeshesAsMiscDirty(): void;
  19723. /**
  19724. * Instantiate a new istance of clear coat configuration.
  19725. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19726. */
  19727. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19728. /**
  19729. * Checks to see if a texture is used in the material.
  19730. * @param defines the list of "defines" to update.
  19731. */
  19732. prepareDefines(defines: IMaterialBRDFDefines): void;
  19733. /**
  19734. * Get the current class name of the texture useful for serialization or dynamic coding.
  19735. * @returns "PBRClearCoatConfiguration"
  19736. */
  19737. getClassName(): string;
  19738. /**
  19739. * Makes a duplicate of the current configuration into another one.
  19740. * @param brdfConfiguration define the config where to copy the info
  19741. */
  19742. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19743. /**
  19744. * Serializes this BRDF configuration.
  19745. * @returns - An object with the serialized config.
  19746. */
  19747. serialize(): any;
  19748. /**
  19749. * Parses a anisotropy Configuration from a serialized object.
  19750. * @param source - Serialized object.
  19751. * @param scene Defines the scene we are parsing for
  19752. * @param rootUrl Defines the rootUrl to load from
  19753. */
  19754. parse(source: any, scene: Scene, rootUrl: string): void;
  19755. }
  19756. }
  19757. declare module BABYLON {
  19758. /**
  19759. * @hidden
  19760. */
  19761. export interface IMaterialSheenDefines {
  19762. SHEEN: boolean;
  19763. SHEEN_TEXTURE: boolean;
  19764. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19765. SHEEN_TEXTUREDIRECTUV: number;
  19766. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19767. SHEEN_LINKWITHALBEDO: boolean;
  19768. SHEEN_ROUGHNESS: boolean;
  19769. SHEEN_ALBEDOSCALING: boolean;
  19770. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19771. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19772. /** @hidden */
  19773. _areTexturesDirty: boolean;
  19774. }
  19775. /**
  19776. * Define the code related to the Sheen parameters of the pbr material.
  19777. */
  19778. export class PBRSheenConfiguration {
  19779. private _isEnabled;
  19780. /**
  19781. * Defines if the material uses sheen.
  19782. */
  19783. isEnabled: boolean;
  19784. private _linkSheenWithAlbedo;
  19785. /**
  19786. * Defines if the sheen is linked to the sheen color.
  19787. */
  19788. linkSheenWithAlbedo: boolean;
  19789. /**
  19790. * Defines the sheen intensity.
  19791. */
  19792. intensity: number;
  19793. /**
  19794. * Defines the sheen color.
  19795. */
  19796. color: Color3;
  19797. private _texture;
  19798. /**
  19799. * Stores the sheen tint values in a texture.
  19800. * rgb is tint
  19801. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  19802. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19803. */
  19804. texture: Nullable<BaseTexture>;
  19805. private _useRoughnessFromMainTexture;
  19806. /**
  19807. * Indicates that the alpha channel of the texture property will be used for roughness.
  19808. * Has no effect if the roughness (and texture!) property is not defined
  19809. */
  19810. useRoughnessFromMainTexture: boolean;
  19811. private _roughness;
  19812. /**
  19813. * Defines the sheen roughness.
  19814. * It is not taken into account if linkSheenWithAlbedo is true.
  19815. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19816. */
  19817. roughness: Nullable<number>;
  19818. private _textureRoughness;
  19819. /**
  19820. * Stores the sheen roughness in a texture.
  19821. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19822. */
  19823. textureRoughness: Nullable<BaseTexture>;
  19824. private _albedoScaling;
  19825. /**
  19826. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19827. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19828. * making it easier to setup and tweak the effect
  19829. */
  19830. albedoScaling: boolean;
  19831. /** @hidden */
  19832. private _internalMarkAllSubMeshesAsTexturesDirty;
  19833. /** @hidden */
  19834. _markAllSubMeshesAsTexturesDirty(): void;
  19835. /**
  19836. * Instantiate a new istance of clear coat configuration.
  19837. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19838. */
  19839. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19840. /**
  19841. * Specifies that the submesh is ready to be used.
  19842. * @param defines the list of "defines" to update.
  19843. * @param scene defines the scene the material belongs to.
  19844. * @returns - boolean indicating that the submesh is ready or not.
  19845. */
  19846. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19847. /**
  19848. * Checks to see if a texture is used in the material.
  19849. * @param defines the list of "defines" to update.
  19850. * @param scene defines the scene the material belongs to.
  19851. */
  19852. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19853. /**
  19854. * Binds the material data.
  19855. * @param uniformBuffer defines the Uniform buffer to fill in.
  19856. * @param scene defines the scene the material belongs to.
  19857. * @param isFrozen defines wether the material is frozen or not.
  19858. * @param subMesh the submesh to bind data for
  19859. */
  19860. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19861. /**
  19862. * Checks to see if a texture is used in the material.
  19863. * @param texture - Base texture to use.
  19864. * @returns - Boolean specifying if a texture is used in the material.
  19865. */
  19866. hasTexture(texture: BaseTexture): boolean;
  19867. /**
  19868. * Returns an array of the actively used textures.
  19869. * @param activeTextures Array of BaseTextures
  19870. */
  19871. getActiveTextures(activeTextures: BaseTexture[]): void;
  19872. /**
  19873. * Returns the animatable textures.
  19874. * @param animatables Array of animatable textures.
  19875. */
  19876. getAnimatables(animatables: IAnimatable[]): void;
  19877. /**
  19878. * Disposes the resources of the material.
  19879. * @param forceDisposeTextures - Forces the disposal of all textures.
  19880. */
  19881. dispose(forceDisposeTextures?: boolean): void;
  19882. /**
  19883. * Get the current class name of the texture useful for serialization or dynamic coding.
  19884. * @returns "PBRSheenConfiguration"
  19885. */
  19886. getClassName(): string;
  19887. /**
  19888. * Add fallbacks to the effect fallbacks list.
  19889. * @param defines defines the Base texture to use.
  19890. * @param fallbacks defines the current fallback list.
  19891. * @param currentRank defines the current fallback rank.
  19892. * @returns the new fallback rank.
  19893. */
  19894. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19895. /**
  19896. * Add the required uniforms to the current list.
  19897. * @param uniforms defines the current uniform list.
  19898. */
  19899. static AddUniforms(uniforms: string[]): void;
  19900. /**
  19901. * Add the required uniforms to the current buffer.
  19902. * @param uniformBuffer defines the current uniform buffer.
  19903. */
  19904. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19905. /**
  19906. * Add the required samplers to the current list.
  19907. * @param samplers defines the current sampler list.
  19908. */
  19909. static AddSamplers(samplers: string[]): void;
  19910. /**
  19911. * Makes a duplicate of the current configuration into another one.
  19912. * @param sheenConfiguration define the config where to copy the info
  19913. */
  19914. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19915. /**
  19916. * Serializes this BRDF configuration.
  19917. * @returns - An object with the serialized config.
  19918. */
  19919. serialize(): any;
  19920. /**
  19921. * Parses a anisotropy Configuration from a serialized object.
  19922. * @param source - Serialized object.
  19923. * @param scene Defines the scene we are parsing for
  19924. * @param rootUrl Defines the rootUrl to load from
  19925. */
  19926. parse(source: any, scene: Scene, rootUrl: string): void;
  19927. }
  19928. }
  19929. declare module BABYLON {
  19930. /**
  19931. * @hidden
  19932. */
  19933. export interface IMaterialSubSurfaceDefines {
  19934. SUBSURFACE: boolean;
  19935. SS_REFRACTION: boolean;
  19936. SS_TRANSLUCENCY: boolean;
  19937. SS_SCATTERING: boolean;
  19938. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19939. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19940. SS_REFRACTIONMAP_3D: boolean;
  19941. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19942. SS_LODINREFRACTIONALPHA: boolean;
  19943. SS_GAMMAREFRACTION: boolean;
  19944. SS_RGBDREFRACTION: boolean;
  19945. SS_LINEARSPECULARREFRACTION: boolean;
  19946. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19947. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19948. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19949. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19950. /** @hidden */
  19951. _areTexturesDirty: boolean;
  19952. }
  19953. /**
  19954. * Define the code related to the sub surface parameters of the pbr material.
  19955. */
  19956. export class PBRSubSurfaceConfiguration {
  19957. private _isRefractionEnabled;
  19958. /**
  19959. * Defines if the refraction is enabled in the material.
  19960. */
  19961. isRefractionEnabled: boolean;
  19962. private _isTranslucencyEnabled;
  19963. /**
  19964. * Defines if the translucency is enabled in the material.
  19965. */
  19966. isTranslucencyEnabled: boolean;
  19967. private _isScatteringEnabled;
  19968. /**
  19969. * Defines if the sub surface scattering is enabled in the material.
  19970. */
  19971. isScatteringEnabled: boolean;
  19972. private _scatteringDiffusionProfileIndex;
  19973. /**
  19974. * Diffusion profile for subsurface scattering.
  19975. * Useful for better scattering in the skins or foliages.
  19976. */
  19977. get scatteringDiffusionProfile(): Nullable<Color3>;
  19978. set scatteringDiffusionProfile(c: Nullable<Color3>);
  19979. /**
  19980. * Defines the refraction intensity of the material.
  19981. * The refraction when enabled replaces the Diffuse part of the material.
  19982. * The intensity helps transitionning between diffuse and refraction.
  19983. */
  19984. refractionIntensity: number;
  19985. /**
  19986. * Defines the translucency intensity of the material.
  19987. * When translucency has been enabled, this defines how much of the "translucency"
  19988. * is addded to the diffuse part of the material.
  19989. */
  19990. translucencyIntensity: number;
  19991. /**
  19992. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  19993. */
  19994. useAlbedoToTintRefraction: boolean;
  19995. private _thicknessTexture;
  19996. /**
  19997. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  19998. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  19999. * 0 would mean minimumThickness
  20000. * 1 would mean maximumThickness
  20001. * The other channels might be use as a mask to vary the different effects intensity.
  20002. */
  20003. thicknessTexture: Nullable<BaseTexture>;
  20004. private _refractionTexture;
  20005. /**
  20006. * Defines the texture to use for refraction.
  20007. */
  20008. refractionTexture: Nullable<BaseTexture>;
  20009. private _indexOfRefraction;
  20010. /**
  20011. * Index of refraction of the material base layer.
  20012. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20013. *
  20014. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20015. *
  20016. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20017. */
  20018. indexOfRefraction: number;
  20019. private _volumeIndexOfRefraction;
  20020. /**
  20021. * Index of refraction of the material's volume.
  20022. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20023. *
  20024. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20025. * the volume will use the same IOR as the surface.
  20026. */
  20027. get volumeIndexOfRefraction(): number;
  20028. set volumeIndexOfRefraction(value: number);
  20029. private _invertRefractionY;
  20030. /**
  20031. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20032. */
  20033. invertRefractionY: boolean;
  20034. private _linkRefractionWithTransparency;
  20035. /**
  20036. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20037. * Materials half opaque for instance using refraction could benefit from this control.
  20038. */
  20039. linkRefractionWithTransparency: boolean;
  20040. /**
  20041. * Defines the minimum thickness stored in the thickness map.
  20042. * If no thickness map is defined, this value will be used to simulate thickness.
  20043. */
  20044. minimumThickness: number;
  20045. /**
  20046. * Defines the maximum thickness stored in the thickness map.
  20047. */
  20048. maximumThickness: number;
  20049. /**
  20050. * Defines the volume tint of the material.
  20051. * This is used for both translucency and scattering.
  20052. */
  20053. tintColor: Color3;
  20054. /**
  20055. * Defines the distance at which the tint color should be found in the media.
  20056. * This is used for refraction only.
  20057. */
  20058. tintColorAtDistance: number;
  20059. /**
  20060. * Defines how far each channel transmit through the media.
  20061. * It is defined as a color to simplify it selection.
  20062. */
  20063. diffusionDistance: Color3;
  20064. private _useMaskFromThicknessTexture;
  20065. /**
  20066. * Stores the intensity of the different subsurface effects in the thickness texture.
  20067. * * the green channel is the translucency intensity.
  20068. * * the blue channel is the scattering intensity.
  20069. * * the alpha channel is the refraction intensity.
  20070. */
  20071. useMaskFromThicknessTexture: boolean;
  20072. private _scene;
  20073. private _useMaskFromThicknessTextureGltf;
  20074. /**
  20075. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20076. * matches the channel-packing that is used by glTF.
  20077. * * the red channel is the transmission/translucency intensity.
  20078. * * the green channel is the thickness.
  20079. */
  20080. useMaskFromThicknessTextureGltf: boolean;
  20081. /** @hidden */
  20082. private _internalMarkAllSubMeshesAsTexturesDirty;
  20083. private _internalMarkScenePrePassDirty;
  20084. /** @hidden */
  20085. _markAllSubMeshesAsTexturesDirty(): void;
  20086. /** @hidden */
  20087. _markScenePrePassDirty(): void;
  20088. /**
  20089. * Instantiate a new istance of sub surface configuration.
  20090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20091. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20092. * @param scene The scene
  20093. */
  20094. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20095. /**
  20096. * Gets wehter the submesh is ready to be used or not.
  20097. * @param defines the list of "defines" to update.
  20098. * @param scene defines the scene the material belongs to.
  20099. * @returns - boolean indicating that the submesh is ready or not.
  20100. */
  20101. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20102. /**
  20103. * Checks to see if a texture is used in the material.
  20104. * @param defines the list of "defines" to update.
  20105. * @param scene defines the scene to the material belongs to.
  20106. */
  20107. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20108. /**
  20109. * Binds the material data.
  20110. * @param uniformBuffer defines the Uniform buffer to fill in.
  20111. * @param scene defines the scene the material belongs to.
  20112. * @param engine defines the engine the material belongs to.
  20113. * @param isFrozen defines whether the material is frozen or not.
  20114. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20115. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20116. */
  20117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20118. /**
  20119. * Unbinds the material from the mesh.
  20120. * @param activeEffect defines the effect that should be unbound from.
  20121. * @returns true if unbound, otherwise false
  20122. */
  20123. unbind(activeEffect: Effect): boolean;
  20124. /**
  20125. * Returns the texture used for refraction or null if none is used.
  20126. * @param scene defines the scene the material belongs to.
  20127. * @returns - Refraction texture if present. If no refraction texture and refraction
  20128. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20129. */
  20130. private _getRefractionTexture;
  20131. /**
  20132. * Returns true if alpha blending should be disabled.
  20133. */
  20134. get disableAlphaBlending(): boolean;
  20135. /**
  20136. * Fills the list of render target textures.
  20137. * @param renderTargets the list of render targets to update
  20138. */
  20139. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20140. /**
  20141. * Checks to see if a texture is used in the material.
  20142. * @param texture - Base texture to use.
  20143. * @returns - Boolean specifying if a texture is used in the material.
  20144. */
  20145. hasTexture(texture: BaseTexture): boolean;
  20146. /**
  20147. * Gets a boolean indicating that current material needs to register RTT
  20148. * @returns true if this uses a render target otherwise false.
  20149. */
  20150. hasRenderTargetTextures(): boolean;
  20151. /**
  20152. * Returns an array of the actively used textures.
  20153. * @param activeTextures Array of BaseTextures
  20154. */
  20155. getActiveTextures(activeTextures: BaseTexture[]): void;
  20156. /**
  20157. * Returns the animatable textures.
  20158. * @param animatables Array of animatable textures.
  20159. */
  20160. getAnimatables(animatables: IAnimatable[]): void;
  20161. /**
  20162. * Disposes the resources of the material.
  20163. * @param forceDisposeTextures - Forces the disposal of all textures.
  20164. */
  20165. dispose(forceDisposeTextures?: boolean): void;
  20166. /**
  20167. * Get the current class name of the texture useful for serialization or dynamic coding.
  20168. * @returns "PBRSubSurfaceConfiguration"
  20169. */
  20170. getClassName(): string;
  20171. /**
  20172. * Add fallbacks to the effect fallbacks list.
  20173. * @param defines defines the Base texture to use.
  20174. * @param fallbacks defines the current fallback list.
  20175. * @param currentRank defines the current fallback rank.
  20176. * @returns the new fallback rank.
  20177. */
  20178. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20179. /**
  20180. * Add the required uniforms to the current list.
  20181. * @param uniforms defines the current uniform list.
  20182. */
  20183. static AddUniforms(uniforms: string[]): void;
  20184. /**
  20185. * Add the required samplers to the current list.
  20186. * @param samplers defines the current sampler list.
  20187. */
  20188. static AddSamplers(samplers: string[]): void;
  20189. /**
  20190. * Add the required uniforms to the current buffer.
  20191. * @param uniformBuffer defines the current uniform buffer.
  20192. */
  20193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20194. /**
  20195. * Makes a duplicate of the current configuration into another one.
  20196. * @param configuration define the config where to copy the info
  20197. */
  20198. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20199. /**
  20200. * Serializes this Sub Surface configuration.
  20201. * @returns - An object with the serialized config.
  20202. */
  20203. serialize(): any;
  20204. /**
  20205. * Parses a anisotropy Configuration from a serialized object.
  20206. * @param source - Serialized object.
  20207. * @param scene Defines the scene we are parsing for
  20208. * @param rootUrl Defines the rootUrl to load from
  20209. */
  20210. parse(source: any, scene: Scene, rootUrl: string): void;
  20211. }
  20212. }
  20213. declare module BABYLON {
  20214. /**
  20215. * Class representing spherical harmonics coefficients to the 3rd degree
  20216. */
  20217. export class SphericalHarmonics {
  20218. /**
  20219. * Defines whether or not the harmonics have been prescaled for rendering.
  20220. */
  20221. preScaled: boolean;
  20222. /**
  20223. * The l0,0 coefficients of the spherical harmonics
  20224. */
  20225. l00: Vector3;
  20226. /**
  20227. * The l1,-1 coefficients of the spherical harmonics
  20228. */
  20229. l1_1: Vector3;
  20230. /**
  20231. * The l1,0 coefficients of the spherical harmonics
  20232. */
  20233. l10: Vector3;
  20234. /**
  20235. * The l1,1 coefficients of the spherical harmonics
  20236. */
  20237. l11: Vector3;
  20238. /**
  20239. * The l2,-2 coefficients of the spherical harmonics
  20240. */
  20241. l2_2: Vector3;
  20242. /**
  20243. * The l2,-1 coefficients of the spherical harmonics
  20244. */
  20245. l2_1: Vector3;
  20246. /**
  20247. * The l2,0 coefficients of the spherical harmonics
  20248. */
  20249. l20: Vector3;
  20250. /**
  20251. * The l2,1 coefficients of the spherical harmonics
  20252. */
  20253. l21: Vector3;
  20254. /**
  20255. * The l2,2 coefficients of the spherical harmonics
  20256. */
  20257. l22: Vector3;
  20258. /**
  20259. * Adds a light to the spherical harmonics
  20260. * @param direction the direction of the light
  20261. * @param color the color of the light
  20262. * @param deltaSolidAngle the delta solid angle of the light
  20263. */
  20264. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20265. /**
  20266. * Scales the spherical harmonics by the given amount
  20267. * @param scale the amount to scale
  20268. */
  20269. scaleInPlace(scale: number): void;
  20270. /**
  20271. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20272. *
  20273. * ```
  20274. * E_lm = A_l * L_lm
  20275. * ```
  20276. *
  20277. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20278. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20279. * the scaling factors are given in equation 9.
  20280. */
  20281. convertIncidentRadianceToIrradiance(): void;
  20282. /**
  20283. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20284. *
  20285. * ```
  20286. * L = (1/pi) * E * rho
  20287. * ```
  20288. *
  20289. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20290. */
  20291. convertIrradianceToLambertianRadiance(): void;
  20292. /**
  20293. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20294. * required operations at run time.
  20295. *
  20296. * This is simply done by scaling back the SH with Ylm constants parameter.
  20297. * The trigonometric part being applied by the shader at run time.
  20298. */
  20299. preScaleForRendering(): void;
  20300. /**
  20301. * Constructs a spherical harmonics from an array.
  20302. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20303. * @returns the spherical harmonics
  20304. */
  20305. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20306. /**
  20307. * Gets the spherical harmonics from polynomial
  20308. * @param polynomial the spherical polynomial
  20309. * @returns the spherical harmonics
  20310. */
  20311. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20312. }
  20313. /**
  20314. * Class representing spherical polynomial coefficients to the 3rd degree
  20315. */
  20316. export class SphericalPolynomial {
  20317. private _harmonics;
  20318. /**
  20319. * The spherical harmonics used to create the polynomials.
  20320. */
  20321. get preScaledHarmonics(): SphericalHarmonics;
  20322. /**
  20323. * The x coefficients of the spherical polynomial
  20324. */
  20325. x: Vector3;
  20326. /**
  20327. * The y coefficients of the spherical polynomial
  20328. */
  20329. y: Vector3;
  20330. /**
  20331. * The z coefficients of the spherical polynomial
  20332. */
  20333. z: Vector3;
  20334. /**
  20335. * The xx coefficients of the spherical polynomial
  20336. */
  20337. xx: Vector3;
  20338. /**
  20339. * The yy coefficients of the spherical polynomial
  20340. */
  20341. yy: Vector3;
  20342. /**
  20343. * The zz coefficients of the spherical polynomial
  20344. */
  20345. zz: Vector3;
  20346. /**
  20347. * The xy coefficients of the spherical polynomial
  20348. */
  20349. xy: Vector3;
  20350. /**
  20351. * The yz coefficients of the spherical polynomial
  20352. */
  20353. yz: Vector3;
  20354. /**
  20355. * The zx coefficients of the spherical polynomial
  20356. */
  20357. zx: Vector3;
  20358. /**
  20359. * Adds an ambient color to the spherical polynomial
  20360. * @param color the color to add
  20361. */
  20362. addAmbient(color: Color3): void;
  20363. /**
  20364. * Scales the spherical polynomial by the given amount
  20365. * @param scale the amount to scale
  20366. */
  20367. scaleInPlace(scale: number): void;
  20368. /**
  20369. * Gets the spherical polynomial from harmonics
  20370. * @param harmonics the spherical harmonics
  20371. * @returns the spherical polynomial
  20372. */
  20373. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20374. /**
  20375. * Constructs a spherical polynomial from an array.
  20376. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20377. * @returns the spherical polynomial
  20378. */
  20379. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20380. }
  20381. }
  20382. declare module BABYLON {
  20383. /**
  20384. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20385. */
  20386. export interface CubeMapInfo {
  20387. /**
  20388. * The pixel array for the front face.
  20389. * This is stored in format, left to right, up to down format.
  20390. */
  20391. front: Nullable<ArrayBufferView>;
  20392. /**
  20393. * The pixel array for the back face.
  20394. * This is stored in format, left to right, up to down format.
  20395. */
  20396. back: Nullable<ArrayBufferView>;
  20397. /**
  20398. * The pixel array for the left face.
  20399. * This is stored in format, left to right, up to down format.
  20400. */
  20401. left: Nullable<ArrayBufferView>;
  20402. /**
  20403. * The pixel array for the right face.
  20404. * This is stored in format, left to right, up to down format.
  20405. */
  20406. right: Nullable<ArrayBufferView>;
  20407. /**
  20408. * The pixel array for the up face.
  20409. * This is stored in format, left to right, up to down format.
  20410. */
  20411. up: Nullable<ArrayBufferView>;
  20412. /**
  20413. * The pixel array for the down face.
  20414. * This is stored in format, left to right, up to down format.
  20415. */
  20416. down: Nullable<ArrayBufferView>;
  20417. /**
  20418. * The size of the cubemap stored.
  20419. *
  20420. * Each faces will be size * size pixels.
  20421. */
  20422. size: number;
  20423. /**
  20424. * The format of the texture.
  20425. *
  20426. * RGBA, RGB.
  20427. */
  20428. format: number;
  20429. /**
  20430. * The type of the texture data.
  20431. *
  20432. * UNSIGNED_INT, FLOAT.
  20433. */
  20434. type: number;
  20435. /**
  20436. * Specifies whether the texture is in gamma space.
  20437. */
  20438. gammaSpace: boolean;
  20439. }
  20440. /**
  20441. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20442. */
  20443. export class PanoramaToCubeMapTools {
  20444. private static FACE_LEFT;
  20445. private static FACE_RIGHT;
  20446. private static FACE_FRONT;
  20447. private static FACE_BACK;
  20448. private static FACE_DOWN;
  20449. private static FACE_UP;
  20450. /**
  20451. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20452. *
  20453. * @param float32Array The source data.
  20454. * @param inputWidth The width of the input panorama.
  20455. * @param inputHeight The height of the input panorama.
  20456. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20457. * @return The cubemap data
  20458. */
  20459. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20460. private static CreateCubemapTexture;
  20461. private static CalcProjectionSpherical;
  20462. }
  20463. }
  20464. declare module BABYLON {
  20465. /**
  20466. * Helper class dealing with the extraction of spherical polynomial dataArray
  20467. * from a cube map.
  20468. */
  20469. export class CubeMapToSphericalPolynomialTools {
  20470. private static FileFaces;
  20471. /**
  20472. * Converts a texture to the according Spherical Polynomial data.
  20473. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20474. *
  20475. * @param texture The texture to extract the information from.
  20476. * @return The Spherical Polynomial data.
  20477. */
  20478. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20479. /**
  20480. * Converts a cubemap to the according Spherical Polynomial data.
  20481. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20482. *
  20483. * @param cubeInfo The Cube map to extract the information from.
  20484. * @return The Spherical Polynomial data.
  20485. */
  20486. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20487. }
  20488. }
  20489. declare module BABYLON {
  20490. interface BaseTexture {
  20491. /**
  20492. * Get the polynomial representation of the texture data.
  20493. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20494. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20495. */
  20496. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20497. }
  20498. }
  20499. declare module BABYLON {
  20500. /** @hidden */
  20501. export var pbrFragmentDeclaration: {
  20502. name: string;
  20503. shader: string;
  20504. };
  20505. }
  20506. declare module BABYLON {
  20507. /** @hidden */
  20508. export var pbrUboDeclaration: {
  20509. name: string;
  20510. shader: string;
  20511. };
  20512. }
  20513. declare module BABYLON {
  20514. /** @hidden */
  20515. export var pbrFragmentExtraDeclaration: {
  20516. name: string;
  20517. shader: string;
  20518. };
  20519. }
  20520. declare module BABYLON {
  20521. /** @hidden */
  20522. export var pbrFragmentSamplersDeclaration: {
  20523. name: string;
  20524. shader: string;
  20525. };
  20526. }
  20527. declare module BABYLON {
  20528. /** @hidden */
  20529. export var subSurfaceScatteringFunctions: {
  20530. name: string;
  20531. shader: string;
  20532. };
  20533. }
  20534. declare module BABYLON {
  20535. /** @hidden */
  20536. export var importanceSampling: {
  20537. name: string;
  20538. shader: string;
  20539. };
  20540. }
  20541. declare module BABYLON {
  20542. /** @hidden */
  20543. export var pbrHelperFunctions: {
  20544. name: string;
  20545. shader: string;
  20546. };
  20547. }
  20548. declare module BABYLON {
  20549. /** @hidden */
  20550. export var harmonicsFunctions: {
  20551. name: string;
  20552. shader: string;
  20553. };
  20554. }
  20555. declare module BABYLON {
  20556. /** @hidden */
  20557. export var pbrDirectLightingSetupFunctions: {
  20558. name: string;
  20559. shader: string;
  20560. };
  20561. }
  20562. declare module BABYLON {
  20563. /** @hidden */
  20564. export var pbrDirectLightingFalloffFunctions: {
  20565. name: string;
  20566. shader: string;
  20567. };
  20568. }
  20569. declare module BABYLON {
  20570. /** @hidden */
  20571. export var pbrBRDFFunctions: {
  20572. name: string;
  20573. shader: string;
  20574. };
  20575. }
  20576. declare module BABYLON {
  20577. /** @hidden */
  20578. export var hdrFilteringFunctions: {
  20579. name: string;
  20580. shader: string;
  20581. };
  20582. }
  20583. declare module BABYLON {
  20584. /** @hidden */
  20585. export var pbrDirectLightingFunctions: {
  20586. name: string;
  20587. shader: string;
  20588. };
  20589. }
  20590. declare module BABYLON {
  20591. /** @hidden */
  20592. export var pbrIBLFunctions: {
  20593. name: string;
  20594. shader: string;
  20595. };
  20596. }
  20597. declare module BABYLON {
  20598. /** @hidden */
  20599. export var pbrBlockAlbedoOpacity: {
  20600. name: string;
  20601. shader: string;
  20602. };
  20603. }
  20604. declare module BABYLON {
  20605. /** @hidden */
  20606. export var pbrBlockReflectivity: {
  20607. name: string;
  20608. shader: string;
  20609. };
  20610. }
  20611. declare module BABYLON {
  20612. /** @hidden */
  20613. export var pbrBlockAmbientOcclusion: {
  20614. name: string;
  20615. shader: string;
  20616. };
  20617. }
  20618. declare module BABYLON {
  20619. /** @hidden */
  20620. export var pbrBlockAlphaFresnel: {
  20621. name: string;
  20622. shader: string;
  20623. };
  20624. }
  20625. declare module BABYLON {
  20626. /** @hidden */
  20627. export var pbrBlockAnisotropic: {
  20628. name: string;
  20629. shader: string;
  20630. };
  20631. }
  20632. declare module BABYLON {
  20633. /** @hidden */
  20634. export var pbrBlockReflection: {
  20635. name: string;
  20636. shader: string;
  20637. };
  20638. }
  20639. declare module BABYLON {
  20640. /** @hidden */
  20641. export var pbrBlockSheen: {
  20642. name: string;
  20643. shader: string;
  20644. };
  20645. }
  20646. declare module BABYLON {
  20647. /** @hidden */
  20648. export var pbrBlockClearcoat: {
  20649. name: string;
  20650. shader: string;
  20651. };
  20652. }
  20653. declare module BABYLON {
  20654. /** @hidden */
  20655. export var pbrBlockSubSurface: {
  20656. name: string;
  20657. shader: string;
  20658. };
  20659. }
  20660. declare module BABYLON {
  20661. /** @hidden */
  20662. export var pbrBlockNormalGeometric: {
  20663. name: string;
  20664. shader: string;
  20665. };
  20666. }
  20667. declare module BABYLON {
  20668. /** @hidden */
  20669. export var pbrBlockNormalFinal: {
  20670. name: string;
  20671. shader: string;
  20672. };
  20673. }
  20674. declare module BABYLON {
  20675. /** @hidden */
  20676. export var pbrBlockLightmapInit: {
  20677. name: string;
  20678. shader: string;
  20679. };
  20680. }
  20681. declare module BABYLON {
  20682. /** @hidden */
  20683. export var pbrBlockGeometryInfo: {
  20684. name: string;
  20685. shader: string;
  20686. };
  20687. }
  20688. declare module BABYLON {
  20689. /** @hidden */
  20690. export var pbrBlockReflectance0: {
  20691. name: string;
  20692. shader: string;
  20693. };
  20694. }
  20695. declare module BABYLON {
  20696. /** @hidden */
  20697. export var pbrBlockReflectance: {
  20698. name: string;
  20699. shader: string;
  20700. };
  20701. }
  20702. declare module BABYLON {
  20703. /** @hidden */
  20704. export var pbrBlockDirectLighting: {
  20705. name: string;
  20706. shader: string;
  20707. };
  20708. }
  20709. declare module BABYLON {
  20710. /** @hidden */
  20711. export var pbrBlockFinalLitComponents: {
  20712. name: string;
  20713. shader: string;
  20714. };
  20715. }
  20716. declare module BABYLON {
  20717. /** @hidden */
  20718. export var pbrBlockFinalUnlitComponents: {
  20719. name: string;
  20720. shader: string;
  20721. };
  20722. }
  20723. declare module BABYLON {
  20724. /** @hidden */
  20725. export var pbrBlockFinalColorComposition: {
  20726. name: string;
  20727. shader: string;
  20728. };
  20729. }
  20730. declare module BABYLON {
  20731. /** @hidden */
  20732. export var pbrBlockImageProcessing: {
  20733. name: string;
  20734. shader: string;
  20735. };
  20736. }
  20737. declare module BABYLON {
  20738. /** @hidden */
  20739. export var pbrDebug: {
  20740. name: string;
  20741. shader: string;
  20742. };
  20743. }
  20744. declare module BABYLON {
  20745. /** @hidden */
  20746. export var pbrPixelShader: {
  20747. name: string;
  20748. shader: string;
  20749. };
  20750. }
  20751. declare module BABYLON {
  20752. /** @hidden */
  20753. export var pbrVertexDeclaration: {
  20754. name: string;
  20755. shader: string;
  20756. };
  20757. }
  20758. declare module BABYLON {
  20759. /** @hidden */
  20760. export var pbrVertexShader: {
  20761. name: string;
  20762. shader: string;
  20763. };
  20764. }
  20765. declare module BABYLON {
  20766. /**
  20767. * Manages the defines for the PBR Material.
  20768. * @hidden
  20769. */
  20770. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20771. PBR: boolean;
  20772. NUM_SAMPLES: string;
  20773. REALTIME_FILTERING: boolean;
  20774. MAINUV1: boolean;
  20775. MAINUV2: boolean;
  20776. UV1: boolean;
  20777. UV2: boolean;
  20778. ALBEDO: boolean;
  20779. GAMMAALBEDO: boolean;
  20780. ALBEDODIRECTUV: number;
  20781. VERTEXCOLOR: boolean;
  20782. DETAIL: boolean;
  20783. DETAILDIRECTUV: number;
  20784. DETAIL_NORMALBLENDMETHOD: number;
  20785. AMBIENT: boolean;
  20786. AMBIENTDIRECTUV: number;
  20787. AMBIENTINGRAYSCALE: boolean;
  20788. OPACITY: boolean;
  20789. VERTEXALPHA: boolean;
  20790. OPACITYDIRECTUV: number;
  20791. OPACITYRGB: boolean;
  20792. ALPHATEST: boolean;
  20793. DEPTHPREPASS: boolean;
  20794. ALPHABLEND: boolean;
  20795. ALPHAFROMALBEDO: boolean;
  20796. ALPHATESTVALUE: string;
  20797. SPECULAROVERALPHA: boolean;
  20798. RADIANCEOVERALPHA: boolean;
  20799. ALPHAFRESNEL: boolean;
  20800. LINEARALPHAFRESNEL: boolean;
  20801. PREMULTIPLYALPHA: boolean;
  20802. EMISSIVE: boolean;
  20803. EMISSIVEDIRECTUV: number;
  20804. REFLECTIVITY: boolean;
  20805. REFLECTIVITYDIRECTUV: number;
  20806. SPECULARTERM: boolean;
  20807. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20808. MICROSURFACEAUTOMATIC: boolean;
  20809. LODBASEDMICROSFURACE: boolean;
  20810. MICROSURFACEMAP: boolean;
  20811. MICROSURFACEMAPDIRECTUV: number;
  20812. METALLICWORKFLOW: boolean;
  20813. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20814. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20815. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20816. AOSTOREINMETALMAPRED: boolean;
  20817. METALLIC_REFLECTANCE: boolean;
  20818. METALLIC_REFLECTANCEDIRECTUV: number;
  20819. ENVIRONMENTBRDF: boolean;
  20820. ENVIRONMENTBRDF_RGBD: boolean;
  20821. NORMAL: boolean;
  20822. TANGENT: boolean;
  20823. BUMP: boolean;
  20824. BUMPDIRECTUV: number;
  20825. OBJECTSPACE_NORMALMAP: boolean;
  20826. PARALLAX: boolean;
  20827. PARALLAXOCCLUSION: boolean;
  20828. NORMALXYSCALE: boolean;
  20829. LIGHTMAP: boolean;
  20830. LIGHTMAPDIRECTUV: number;
  20831. USELIGHTMAPASSHADOWMAP: boolean;
  20832. GAMMALIGHTMAP: boolean;
  20833. RGBDLIGHTMAP: boolean;
  20834. REFLECTION: boolean;
  20835. REFLECTIONMAP_3D: boolean;
  20836. REFLECTIONMAP_SPHERICAL: boolean;
  20837. REFLECTIONMAP_PLANAR: boolean;
  20838. REFLECTIONMAP_CUBIC: boolean;
  20839. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20840. REFLECTIONMAP_PROJECTION: boolean;
  20841. REFLECTIONMAP_SKYBOX: boolean;
  20842. REFLECTIONMAP_EXPLICIT: boolean;
  20843. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20844. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20845. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20846. INVERTCUBICMAP: boolean;
  20847. USESPHERICALFROMREFLECTIONMAP: boolean;
  20848. USEIRRADIANCEMAP: boolean;
  20849. SPHERICAL_HARMONICS: boolean;
  20850. USESPHERICALINVERTEX: boolean;
  20851. REFLECTIONMAP_OPPOSITEZ: boolean;
  20852. LODINREFLECTIONALPHA: boolean;
  20853. GAMMAREFLECTION: boolean;
  20854. RGBDREFLECTION: boolean;
  20855. LINEARSPECULARREFLECTION: boolean;
  20856. RADIANCEOCCLUSION: boolean;
  20857. HORIZONOCCLUSION: boolean;
  20858. INSTANCES: boolean;
  20859. THIN_INSTANCES: boolean;
  20860. PREPASS: boolean;
  20861. PREPASS_IRRADIANCE: boolean;
  20862. PREPASS_IRRADIANCE_INDEX: number;
  20863. PREPASS_ALBEDO: boolean;
  20864. PREPASS_ALBEDO_INDEX: number;
  20865. PREPASS_DEPTHNORMAL: boolean;
  20866. PREPASS_DEPTHNORMAL_INDEX: number;
  20867. PREPASS_POSITION: boolean;
  20868. PREPASS_POSITION_INDEX: number;
  20869. PREPASS_VELOCITY: boolean;
  20870. PREPASS_VELOCITY_INDEX: number;
  20871. PREPASS_REFLECTIVITY: boolean;
  20872. PREPASS_REFLECTIVITY_INDEX: number;
  20873. SCENE_MRT_COUNT: number;
  20874. NUM_BONE_INFLUENCERS: number;
  20875. BonesPerMesh: number;
  20876. BONETEXTURE: boolean;
  20877. BONES_VELOCITY_ENABLED: boolean;
  20878. NONUNIFORMSCALING: boolean;
  20879. MORPHTARGETS: boolean;
  20880. MORPHTARGETS_NORMAL: boolean;
  20881. MORPHTARGETS_TANGENT: boolean;
  20882. MORPHTARGETS_UV: boolean;
  20883. NUM_MORPH_INFLUENCERS: number;
  20884. IMAGEPROCESSING: boolean;
  20885. VIGNETTE: boolean;
  20886. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20887. VIGNETTEBLENDMODEOPAQUE: boolean;
  20888. TONEMAPPING: boolean;
  20889. TONEMAPPING_ACES: boolean;
  20890. CONTRAST: boolean;
  20891. COLORCURVES: boolean;
  20892. COLORGRADING: boolean;
  20893. COLORGRADING3D: boolean;
  20894. SAMPLER3DGREENDEPTH: boolean;
  20895. SAMPLER3DBGRMAP: boolean;
  20896. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20897. EXPOSURE: boolean;
  20898. MULTIVIEW: boolean;
  20899. USEPHYSICALLIGHTFALLOFF: boolean;
  20900. USEGLTFLIGHTFALLOFF: boolean;
  20901. TWOSIDEDLIGHTING: boolean;
  20902. SHADOWFLOAT: boolean;
  20903. CLIPPLANE: boolean;
  20904. CLIPPLANE2: boolean;
  20905. CLIPPLANE3: boolean;
  20906. CLIPPLANE4: boolean;
  20907. CLIPPLANE5: boolean;
  20908. CLIPPLANE6: boolean;
  20909. POINTSIZE: boolean;
  20910. FOG: boolean;
  20911. LOGARITHMICDEPTH: boolean;
  20912. FORCENORMALFORWARD: boolean;
  20913. SPECULARAA: boolean;
  20914. CLEARCOAT: boolean;
  20915. CLEARCOAT_DEFAULTIOR: boolean;
  20916. CLEARCOAT_TEXTURE: boolean;
  20917. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20918. CLEARCOAT_TEXTUREDIRECTUV: number;
  20919. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20920. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20921. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20922. CLEARCOAT_BUMP: boolean;
  20923. CLEARCOAT_BUMPDIRECTUV: number;
  20924. CLEARCOAT_REMAP_F0: boolean;
  20925. CLEARCOAT_TINT: boolean;
  20926. CLEARCOAT_TINT_TEXTURE: boolean;
  20927. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20928. ANISOTROPIC: boolean;
  20929. ANISOTROPIC_TEXTURE: boolean;
  20930. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20931. BRDF_V_HEIGHT_CORRELATED: boolean;
  20932. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20933. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20934. SHEEN: boolean;
  20935. SHEEN_TEXTURE: boolean;
  20936. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20937. SHEEN_TEXTUREDIRECTUV: number;
  20938. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20939. SHEEN_LINKWITHALBEDO: boolean;
  20940. SHEEN_ROUGHNESS: boolean;
  20941. SHEEN_ALBEDOSCALING: boolean;
  20942. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20943. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20944. SUBSURFACE: boolean;
  20945. SS_REFRACTION: boolean;
  20946. SS_TRANSLUCENCY: boolean;
  20947. SS_SCATTERING: boolean;
  20948. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20949. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20950. SS_REFRACTIONMAP_3D: boolean;
  20951. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20952. SS_LODINREFRACTIONALPHA: boolean;
  20953. SS_GAMMAREFRACTION: boolean;
  20954. SS_RGBDREFRACTION: boolean;
  20955. SS_LINEARSPECULARREFRACTION: boolean;
  20956. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20957. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20958. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20959. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20960. UNLIT: boolean;
  20961. DEBUGMODE: number;
  20962. /**
  20963. * Initializes the PBR Material defines.
  20964. */
  20965. constructor();
  20966. /**
  20967. * Resets the PBR Material defines.
  20968. */
  20969. reset(): void;
  20970. }
  20971. /**
  20972. * The Physically based material base class of BJS.
  20973. *
  20974. * This offers the main features of a standard PBR material.
  20975. * For more information, please refer to the documentation :
  20976. * https://doc.babylonjs.com/how_to/physically_based_rendering
  20977. */
  20978. export abstract class PBRBaseMaterial extends PushMaterial {
  20979. /**
  20980. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20981. */
  20982. static readonly PBRMATERIAL_OPAQUE: number;
  20983. /**
  20984. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20985. */
  20986. static readonly PBRMATERIAL_ALPHATEST: number;
  20987. /**
  20988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20989. */
  20990. static readonly PBRMATERIAL_ALPHABLEND: number;
  20991. /**
  20992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20993. * They are also discarded below the alpha cutoff threshold to improve performances.
  20994. */
  20995. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20996. /**
  20997. * Defines the default value of how much AO map is occluding the analytical lights
  20998. * (point spot...).
  20999. */
  21000. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21001. /**
  21002. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21003. */
  21004. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21005. /**
  21006. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21007. * to enhance interoperability with other engines.
  21008. */
  21009. static readonly LIGHTFALLOFF_GLTF: number;
  21010. /**
  21011. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21012. * to enhance interoperability with other materials.
  21013. */
  21014. static readonly LIGHTFALLOFF_STANDARD: number;
  21015. /**
  21016. * Intensity of the direct lights e.g. the four lights available in your scene.
  21017. * This impacts both the direct diffuse and specular highlights.
  21018. */
  21019. protected _directIntensity: number;
  21020. /**
  21021. * Intensity of the emissive part of the material.
  21022. * This helps controlling the emissive effect without modifying the emissive color.
  21023. */
  21024. protected _emissiveIntensity: number;
  21025. /**
  21026. * Intensity of the environment e.g. how much the environment will light the object
  21027. * either through harmonics for rough material or through the refelction for shiny ones.
  21028. */
  21029. protected _environmentIntensity: number;
  21030. /**
  21031. * This is a special control allowing the reduction of the specular highlights coming from the
  21032. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21033. */
  21034. protected _specularIntensity: number;
  21035. /**
  21036. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21037. */
  21038. private _lightingInfos;
  21039. /**
  21040. * Debug Control allowing disabling the bump map on this material.
  21041. */
  21042. protected _disableBumpMap: boolean;
  21043. /**
  21044. * AKA Diffuse Texture in standard nomenclature.
  21045. */
  21046. protected _albedoTexture: Nullable<BaseTexture>;
  21047. /**
  21048. * AKA Occlusion Texture in other nomenclature.
  21049. */
  21050. protected _ambientTexture: Nullable<BaseTexture>;
  21051. /**
  21052. * AKA Occlusion Texture Intensity in other nomenclature.
  21053. */
  21054. protected _ambientTextureStrength: number;
  21055. /**
  21056. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21057. * 1 means it completely occludes it
  21058. * 0 mean it has no impact
  21059. */
  21060. protected _ambientTextureImpactOnAnalyticalLights: number;
  21061. /**
  21062. * Stores the alpha values in a texture.
  21063. */
  21064. protected _opacityTexture: Nullable<BaseTexture>;
  21065. /**
  21066. * Stores the reflection values in a texture.
  21067. */
  21068. protected _reflectionTexture: Nullable<BaseTexture>;
  21069. /**
  21070. * Stores the emissive values in a texture.
  21071. */
  21072. protected _emissiveTexture: Nullable<BaseTexture>;
  21073. /**
  21074. * AKA Specular texture in other nomenclature.
  21075. */
  21076. protected _reflectivityTexture: Nullable<BaseTexture>;
  21077. /**
  21078. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21079. */
  21080. protected _metallicTexture: Nullable<BaseTexture>;
  21081. /**
  21082. * Specifies the metallic scalar of the metallic/roughness workflow.
  21083. * Can also be used to scale the metalness values of the metallic texture.
  21084. */
  21085. protected _metallic: Nullable<number>;
  21086. /**
  21087. * Specifies the roughness scalar of the metallic/roughness workflow.
  21088. * Can also be used to scale the roughness values of the metallic texture.
  21089. */
  21090. protected _roughness: Nullable<number>;
  21091. /**
  21092. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21093. * By default the indexOfrefraction is used to compute F0;
  21094. *
  21095. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21096. *
  21097. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21098. * F90 = metallicReflectanceColor;
  21099. */
  21100. protected _metallicF0Factor: number;
  21101. /**
  21102. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21103. * By default the F90 is always 1;
  21104. *
  21105. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21106. *
  21107. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21108. * F90 = metallicReflectanceColor;
  21109. */
  21110. protected _metallicReflectanceColor: Color3;
  21111. /**
  21112. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21113. * This is multiply against the scalar values defined in the material.
  21114. */
  21115. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21116. /**
  21117. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21118. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21119. */
  21120. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21121. /**
  21122. * Stores surface normal data used to displace a mesh in a texture.
  21123. */
  21124. protected _bumpTexture: Nullable<BaseTexture>;
  21125. /**
  21126. * Stores the pre-calculated light information of a mesh in a texture.
  21127. */
  21128. protected _lightmapTexture: Nullable<BaseTexture>;
  21129. /**
  21130. * The color of a material in ambient lighting.
  21131. */
  21132. protected _ambientColor: Color3;
  21133. /**
  21134. * AKA Diffuse Color in other nomenclature.
  21135. */
  21136. protected _albedoColor: Color3;
  21137. /**
  21138. * AKA Specular Color in other nomenclature.
  21139. */
  21140. protected _reflectivityColor: Color3;
  21141. /**
  21142. * The color applied when light is reflected from a material.
  21143. */
  21144. protected _reflectionColor: Color3;
  21145. /**
  21146. * The color applied when light is emitted from a material.
  21147. */
  21148. protected _emissiveColor: Color3;
  21149. /**
  21150. * AKA Glossiness in other nomenclature.
  21151. */
  21152. protected _microSurface: number;
  21153. /**
  21154. * Specifies that the material will use the light map as a show map.
  21155. */
  21156. protected _useLightmapAsShadowmap: boolean;
  21157. /**
  21158. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21159. * makes the reflect vector face the model (under horizon).
  21160. */
  21161. protected _useHorizonOcclusion: boolean;
  21162. /**
  21163. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21164. * too much the area relying on ambient texture to define their ambient occlusion.
  21165. */
  21166. protected _useRadianceOcclusion: boolean;
  21167. /**
  21168. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21169. */
  21170. protected _useAlphaFromAlbedoTexture: boolean;
  21171. /**
  21172. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21173. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21174. */
  21175. protected _useSpecularOverAlpha: boolean;
  21176. /**
  21177. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21178. */
  21179. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21180. /**
  21181. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21182. */
  21183. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21184. /**
  21185. * Specifies if the metallic texture contains the roughness information in its green channel.
  21186. */
  21187. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21188. /**
  21189. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21190. */
  21191. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21192. /**
  21193. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21194. */
  21195. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21196. /**
  21197. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21198. */
  21199. protected _useAmbientInGrayScale: boolean;
  21200. /**
  21201. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21202. * The material will try to infer what glossiness each pixel should be.
  21203. */
  21204. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21205. /**
  21206. * Defines the falloff type used in this material.
  21207. * It by default is Physical.
  21208. */
  21209. protected _lightFalloff: number;
  21210. /**
  21211. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21212. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21213. */
  21214. protected _useRadianceOverAlpha: boolean;
  21215. /**
  21216. * Allows using an object space normal map (instead of tangent space).
  21217. */
  21218. protected _useObjectSpaceNormalMap: boolean;
  21219. /**
  21220. * Allows using the bump map in parallax mode.
  21221. */
  21222. protected _useParallax: boolean;
  21223. /**
  21224. * Allows using the bump map in parallax occlusion mode.
  21225. */
  21226. protected _useParallaxOcclusion: boolean;
  21227. /**
  21228. * Controls the scale bias of the parallax mode.
  21229. */
  21230. protected _parallaxScaleBias: number;
  21231. /**
  21232. * If sets to true, disables all the lights affecting the material.
  21233. */
  21234. protected _disableLighting: boolean;
  21235. /**
  21236. * Number of Simultaneous lights allowed on the material.
  21237. */
  21238. protected _maxSimultaneousLights: number;
  21239. /**
  21240. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21241. */
  21242. protected _invertNormalMapX: boolean;
  21243. /**
  21244. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21245. */
  21246. protected _invertNormalMapY: boolean;
  21247. /**
  21248. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21249. */
  21250. protected _twoSidedLighting: boolean;
  21251. /**
  21252. * Defines the alpha limits in alpha test mode.
  21253. */
  21254. protected _alphaCutOff: number;
  21255. /**
  21256. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21257. */
  21258. protected _forceAlphaTest: boolean;
  21259. /**
  21260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21261. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21262. */
  21263. protected _useAlphaFresnel: boolean;
  21264. /**
  21265. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21266. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21267. */
  21268. protected _useLinearAlphaFresnel: boolean;
  21269. /**
  21270. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21271. * from cos thetav and roughness:
  21272. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21273. */
  21274. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21275. /**
  21276. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21277. */
  21278. protected _forceIrradianceInFragment: boolean;
  21279. private _realTimeFiltering;
  21280. /**
  21281. * Enables realtime filtering on the texture.
  21282. */
  21283. get realTimeFiltering(): boolean;
  21284. set realTimeFiltering(b: boolean);
  21285. private _realTimeFilteringQuality;
  21286. /**
  21287. * Quality switch for realtime filtering
  21288. */
  21289. get realTimeFilteringQuality(): number;
  21290. set realTimeFilteringQuality(n: number);
  21291. /**
  21292. * Can this material render to several textures at once
  21293. */
  21294. get canRenderToMRT(): boolean;
  21295. /**
  21296. * Force normal to face away from face.
  21297. */
  21298. protected _forceNormalForward: boolean;
  21299. /**
  21300. * Enables specular anti aliasing in the PBR shader.
  21301. * It will both interacts on the Geometry for analytical and IBL lighting.
  21302. * It also prefilter the roughness map based on the bump values.
  21303. */
  21304. protected _enableSpecularAntiAliasing: boolean;
  21305. /**
  21306. * Default configuration related to image processing available in the PBR Material.
  21307. */
  21308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21309. /**
  21310. * Keep track of the image processing observer to allow dispose and replace.
  21311. */
  21312. private _imageProcessingObserver;
  21313. /**
  21314. * Attaches a new image processing configuration to the PBR Material.
  21315. * @param configuration
  21316. */
  21317. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21318. /**
  21319. * Stores the available render targets.
  21320. */
  21321. private _renderTargets;
  21322. /**
  21323. * Sets the global ambient color for the material used in lighting calculations.
  21324. */
  21325. private _globalAmbientColor;
  21326. /**
  21327. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21328. */
  21329. private _useLogarithmicDepth;
  21330. /**
  21331. * If set to true, no lighting calculations will be applied.
  21332. */
  21333. private _unlit;
  21334. private _debugMode;
  21335. /**
  21336. * @hidden
  21337. * This is reserved for the inspector.
  21338. * Defines the material debug mode.
  21339. * It helps seeing only some components of the material while troubleshooting.
  21340. */
  21341. debugMode: number;
  21342. /**
  21343. * @hidden
  21344. * This is reserved for the inspector.
  21345. * Specify from where on screen the debug mode should start.
  21346. * The value goes from -1 (full screen) to 1 (not visible)
  21347. * It helps with side by side comparison against the final render
  21348. * This defaults to -1
  21349. */
  21350. private debugLimit;
  21351. /**
  21352. * @hidden
  21353. * This is reserved for the inspector.
  21354. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21355. * You can use the factor to better multiply the final value.
  21356. */
  21357. private debugFactor;
  21358. /**
  21359. * Defines the clear coat layer parameters for the material.
  21360. */
  21361. readonly clearCoat: PBRClearCoatConfiguration;
  21362. /**
  21363. * Defines the anisotropic parameters for the material.
  21364. */
  21365. readonly anisotropy: PBRAnisotropicConfiguration;
  21366. /**
  21367. * Defines the BRDF parameters for the material.
  21368. */
  21369. readonly brdf: PBRBRDFConfiguration;
  21370. /**
  21371. * Defines the Sheen parameters for the material.
  21372. */
  21373. readonly sheen: PBRSheenConfiguration;
  21374. /**
  21375. * Defines the SubSurface parameters for the material.
  21376. */
  21377. readonly subSurface: PBRSubSurfaceConfiguration;
  21378. /**
  21379. * Defines additionnal PrePass parameters for the material.
  21380. */
  21381. readonly prePassConfiguration: PrePassConfiguration;
  21382. /**
  21383. * Defines the detail map parameters for the material.
  21384. */
  21385. readonly detailMap: DetailMapConfiguration;
  21386. protected _rebuildInParallel: boolean;
  21387. /**
  21388. * Instantiates a new PBRMaterial instance.
  21389. *
  21390. * @param name The material name
  21391. * @param scene The scene the material will be use in.
  21392. */
  21393. constructor(name: string, scene: Scene);
  21394. /**
  21395. * Gets a boolean indicating that current material needs to register RTT
  21396. */
  21397. get hasRenderTargetTextures(): boolean;
  21398. /**
  21399. * Gets the name of the material class.
  21400. */
  21401. getClassName(): string;
  21402. /**
  21403. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21404. */
  21405. get useLogarithmicDepth(): boolean;
  21406. /**
  21407. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21408. */
  21409. set useLogarithmicDepth(value: boolean);
  21410. /**
  21411. * Returns true if alpha blending should be disabled.
  21412. */
  21413. protected get _disableAlphaBlending(): boolean;
  21414. /**
  21415. * Specifies whether or not this material should be rendered in alpha blend mode.
  21416. */
  21417. needAlphaBlending(): boolean;
  21418. /**
  21419. * Specifies whether or not this material should be rendered in alpha test mode.
  21420. */
  21421. needAlphaTesting(): boolean;
  21422. /**
  21423. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21424. */
  21425. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21426. /**
  21427. * Specifies whether or not there is a usable alpha channel for transparency.
  21428. */
  21429. protected _hasAlphaChannel(): boolean;
  21430. /**
  21431. * Gets the texture used for the alpha test.
  21432. */
  21433. getAlphaTestTexture(): Nullable<BaseTexture>;
  21434. /**
  21435. * Specifies that the submesh is ready to be used.
  21436. * @param mesh - BJS mesh.
  21437. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21438. * @param useInstances - Specifies that instances should be used.
  21439. * @returns - boolean indicating that the submesh is ready or not.
  21440. */
  21441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21442. /**
  21443. * Specifies if the material uses metallic roughness workflow.
  21444. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21445. */
  21446. isMetallicWorkflow(): boolean;
  21447. private _prepareEffect;
  21448. private _prepareDefines;
  21449. /**
  21450. * Force shader compilation
  21451. */
  21452. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21453. /**
  21454. * Initializes the uniform buffer layout for the shader.
  21455. */
  21456. buildUniformLayout(): void;
  21457. /**
  21458. * Unbinds the material from the mesh
  21459. */
  21460. unbind(): void;
  21461. /**
  21462. * Binds the submesh data.
  21463. * @param world - The world matrix.
  21464. * @param mesh - The BJS mesh.
  21465. * @param subMesh - A submesh of the BJS mesh.
  21466. */
  21467. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21468. /**
  21469. * Returns the animatable textures.
  21470. * @returns - Array of animatable textures.
  21471. */
  21472. getAnimatables(): IAnimatable[];
  21473. /**
  21474. * Returns the texture used for reflections.
  21475. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21476. */
  21477. private _getReflectionTexture;
  21478. /**
  21479. * Returns an array of the actively used textures.
  21480. * @returns - Array of BaseTextures
  21481. */
  21482. getActiveTextures(): BaseTexture[];
  21483. /**
  21484. * Checks to see if a texture is used in the material.
  21485. * @param texture - Base texture to use.
  21486. * @returns - Boolean specifying if a texture is used in the material.
  21487. */
  21488. hasTexture(texture: BaseTexture): boolean;
  21489. /**
  21490. * Sets the required values to the prepass renderer.
  21491. * @param prePassRenderer defines the prepass renderer to setup
  21492. */
  21493. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21494. /**
  21495. * Disposes the resources of the material.
  21496. * @param forceDisposeEffect - Forces the disposal of effects.
  21497. * @param forceDisposeTextures - Forces the disposal of all textures.
  21498. */
  21499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21500. }
  21501. }
  21502. declare module BABYLON {
  21503. /**
  21504. * The Physically based material of BJS.
  21505. *
  21506. * This offers the main features of a standard PBR material.
  21507. * For more information, please refer to the documentation :
  21508. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21509. */
  21510. export class PBRMaterial extends PBRBaseMaterial {
  21511. /**
  21512. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21513. */
  21514. static readonly PBRMATERIAL_OPAQUE: number;
  21515. /**
  21516. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21517. */
  21518. static readonly PBRMATERIAL_ALPHATEST: number;
  21519. /**
  21520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21521. */
  21522. static readonly PBRMATERIAL_ALPHABLEND: number;
  21523. /**
  21524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21525. * They are also discarded below the alpha cutoff threshold to improve performances.
  21526. */
  21527. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21528. /**
  21529. * Defines the default value of how much AO map is occluding the analytical lights
  21530. * (point spot...).
  21531. */
  21532. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21533. /**
  21534. * Intensity of the direct lights e.g. the four lights available in your scene.
  21535. * This impacts both the direct diffuse and specular highlights.
  21536. */
  21537. directIntensity: number;
  21538. /**
  21539. * Intensity of the emissive part of the material.
  21540. * This helps controlling the emissive effect without modifying the emissive color.
  21541. */
  21542. emissiveIntensity: number;
  21543. /**
  21544. * Intensity of the environment e.g. how much the environment will light the object
  21545. * either through harmonics for rough material or through the refelction for shiny ones.
  21546. */
  21547. environmentIntensity: number;
  21548. /**
  21549. * This is a special control allowing the reduction of the specular highlights coming from the
  21550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21551. */
  21552. specularIntensity: number;
  21553. /**
  21554. * Debug Control allowing disabling the bump map on this material.
  21555. */
  21556. disableBumpMap: boolean;
  21557. /**
  21558. * AKA Diffuse Texture in standard nomenclature.
  21559. */
  21560. albedoTexture: BaseTexture;
  21561. /**
  21562. * AKA Occlusion Texture in other nomenclature.
  21563. */
  21564. ambientTexture: BaseTexture;
  21565. /**
  21566. * AKA Occlusion Texture Intensity in other nomenclature.
  21567. */
  21568. ambientTextureStrength: number;
  21569. /**
  21570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21571. * 1 means it completely occludes it
  21572. * 0 mean it has no impact
  21573. */
  21574. ambientTextureImpactOnAnalyticalLights: number;
  21575. /**
  21576. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21577. */
  21578. opacityTexture: BaseTexture;
  21579. /**
  21580. * Stores the reflection values in a texture.
  21581. */
  21582. reflectionTexture: Nullable<BaseTexture>;
  21583. /**
  21584. * Stores the emissive values in a texture.
  21585. */
  21586. emissiveTexture: BaseTexture;
  21587. /**
  21588. * AKA Specular texture in other nomenclature.
  21589. */
  21590. reflectivityTexture: BaseTexture;
  21591. /**
  21592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21593. */
  21594. metallicTexture: BaseTexture;
  21595. /**
  21596. * Specifies the metallic scalar of the metallic/roughness workflow.
  21597. * Can also be used to scale the metalness values of the metallic texture.
  21598. */
  21599. metallic: Nullable<number>;
  21600. /**
  21601. * Specifies the roughness scalar of the metallic/roughness workflow.
  21602. * Can also be used to scale the roughness values of the metallic texture.
  21603. */
  21604. roughness: Nullable<number>;
  21605. /**
  21606. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21607. * By default the indexOfrefraction is used to compute F0;
  21608. *
  21609. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21610. *
  21611. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21612. * F90 = metallicReflectanceColor;
  21613. */
  21614. metallicF0Factor: number;
  21615. /**
  21616. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21617. * By default the F90 is always 1;
  21618. *
  21619. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21620. *
  21621. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21622. * F90 = metallicReflectanceColor;
  21623. */
  21624. metallicReflectanceColor: Color3;
  21625. /**
  21626. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21627. * This is multiply against the scalar values defined in the material.
  21628. */
  21629. metallicReflectanceTexture: Nullable<BaseTexture>;
  21630. /**
  21631. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21632. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21633. */
  21634. microSurfaceTexture: BaseTexture;
  21635. /**
  21636. * Stores surface normal data used to displace a mesh in a texture.
  21637. */
  21638. bumpTexture: BaseTexture;
  21639. /**
  21640. * Stores the pre-calculated light information of a mesh in a texture.
  21641. */
  21642. lightmapTexture: BaseTexture;
  21643. /**
  21644. * Stores the refracted light information in a texture.
  21645. */
  21646. get refractionTexture(): Nullable<BaseTexture>;
  21647. set refractionTexture(value: Nullable<BaseTexture>);
  21648. /**
  21649. * The color of a material in ambient lighting.
  21650. */
  21651. ambientColor: Color3;
  21652. /**
  21653. * AKA Diffuse Color in other nomenclature.
  21654. */
  21655. albedoColor: Color3;
  21656. /**
  21657. * AKA Specular Color in other nomenclature.
  21658. */
  21659. reflectivityColor: Color3;
  21660. /**
  21661. * The color reflected from the material.
  21662. */
  21663. reflectionColor: Color3;
  21664. /**
  21665. * The color emitted from the material.
  21666. */
  21667. emissiveColor: Color3;
  21668. /**
  21669. * AKA Glossiness in other nomenclature.
  21670. */
  21671. microSurface: number;
  21672. /**
  21673. * Index of refraction of the material base layer.
  21674. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21675. *
  21676. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21677. *
  21678. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21679. */
  21680. get indexOfRefraction(): number;
  21681. set indexOfRefraction(value: number);
  21682. /**
  21683. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21684. */
  21685. get invertRefractionY(): boolean;
  21686. set invertRefractionY(value: boolean);
  21687. /**
  21688. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21689. * Materials half opaque for instance using refraction could benefit from this control.
  21690. */
  21691. get linkRefractionWithTransparency(): boolean;
  21692. set linkRefractionWithTransparency(value: boolean);
  21693. /**
  21694. * If true, the light map contains occlusion information instead of lighting info.
  21695. */
  21696. useLightmapAsShadowmap: boolean;
  21697. /**
  21698. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21699. */
  21700. useAlphaFromAlbedoTexture: boolean;
  21701. /**
  21702. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21703. */
  21704. forceAlphaTest: boolean;
  21705. /**
  21706. * Defines the alpha limits in alpha test mode.
  21707. */
  21708. alphaCutOff: number;
  21709. /**
  21710. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21711. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21712. */
  21713. useSpecularOverAlpha: boolean;
  21714. /**
  21715. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21716. */
  21717. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21718. /**
  21719. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21720. */
  21721. useRoughnessFromMetallicTextureAlpha: boolean;
  21722. /**
  21723. * Specifies if the metallic texture contains the roughness information in its green channel.
  21724. */
  21725. useRoughnessFromMetallicTextureGreen: boolean;
  21726. /**
  21727. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21728. */
  21729. useMetallnessFromMetallicTextureBlue: boolean;
  21730. /**
  21731. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21732. */
  21733. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21734. /**
  21735. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21736. */
  21737. useAmbientInGrayScale: boolean;
  21738. /**
  21739. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21740. * The material will try to infer what glossiness each pixel should be.
  21741. */
  21742. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21743. /**
  21744. * BJS is using an harcoded light falloff based on a manually sets up range.
  21745. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21746. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21747. */
  21748. get usePhysicalLightFalloff(): boolean;
  21749. /**
  21750. * BJS is using an harcoded light falloff based on a manually sets up range.
  21751. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21752. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21753. */
  21754. set usePhysicalLightFalloff(value: boolean);
  21755. /**
  21756. * In order to support the falloff compatibility with gltf, a special mode has been added
  21757. * to reproduce the gltf light falloff.
  21758. */
  21759. get useGLTFLightFalloff(): boolean;
  21760. /**
  21761. * In order to support the falloff compatibility with gltf, a special mode has been added
  21762. * to reproduce the gltf light falloff.
  21763. */
  21764. set useGLTFLightFalloff(value: boolean);
  21765. /**
  21766. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21767. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21768. */
  21769. useRadianceOverAlpha: boolean;
  21770. /**
  21771. * Allows using an object space normal map (instead of tangent space).
  21772. */
  21773. useObjectSpaceNormalMap: boolean;
  21774. /**
  21775. * Allows using the bump map in parallax mode.
  21776. */
  21777. useParallax: boolean;
  21778. /**
  21779. * Allows using the bump map in parallax occlusion mode.
  21780. */
  21781. useParallaxOcclusion: boolean;
  21782. /**
  21783. * Controls the scale bias of the parallax mode.
  21784. */
  21785. parallaxScaleBias: number;
  21786. /**
  21787. * If sets to true, disables all the lights affecting the material.
  21788. */
  21789. disableLighting: boolean;
  21790. /**
  21791. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21792. */
  21793. forceIrradianceInFragment: boolean;
  21794. /**
  21795. * Number of Simultaneous lights allowed on the material.
  21796. */
  21797. maxSimultaneousLights: number;
  21798. /**
  21799. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21800. */
  21801. invertNormalMapX: boolean;
  21802. /**
  21803. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21804. */
  21805. invertNormalMapY: boolean;
  21806. /**
  21807. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21808. */
  21809. twoSidedLighting: boolean;
  21810. /**
  21811. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21812. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21813. */
  21814. useAlphaFresnel: boolean;
  21815. /**
  21816. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21817. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21818. */
  21819. useLinearAlphaFresnel: boolean;
  21820. /**
  21821. * Let user defines the brdf lookup texture used for IBL.
  21822. * A default 8bit version is embedded but you could point at :
  21823. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21824. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21825. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21826. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21827. */
  21828. environmentBRDFTexture: Nullable<BaseTexture>;
  21829. /**
  21830. * Force normal to face away from face.
  21831. */
  21832. forceNormalForward: boolean;
  21833. /**
  21834. * Enables specular anti aliasing in the PBR shader.
  21835. * It will both interacts on the Geometry for analytical and IBL lighting.
  21836. * It also prefilter the roughness map based on the bump values.
  21837. */
  21838. enableSpecularAntiAliasing: boolean;
  21839. /**
  21840. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21841. * makes the reflect vector face the model (under horizon).
  21842. */
  21843. useHorizonOcclusion: boolean;
  21844. /**
  21845. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21846. * too much the area relying on ambient texture to define their ambient occlusion.
  21847. */
  21848. useRadianceOcclusion: boolean;
  21849. /**
  21850. * If set to true, no lighting calculations will be applied.
  21851. */
  21852. unlit: boolean;
  21853. /**
  21854. * Gets the image processing configuration used either in this material.
  21855. */
  21856. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21857. /**
  21858. * Sets the Default image processing configuration used either in the this material.
  21859. *
  21860. * If sets to null, the scene one is in use.
  21861. */
  21862. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21863. /**
  21864. * Gets wether the color curves effect is enabled.
  21865. */
  21866. get cameraColorCurvesEnabled(): boolean;
  21867. /**
  21868. * Sets wether the color curves effect is enabled.
  21869. */
  21870. set cameraColorCurvesEnabled(value: boolean);
  21871. /**
  21872. * Gets wether the color grading effect is enabled.
  21873. */
  21874. get cameraColorGradingEnabled(): boolean;
  21875. /**
  21876. * Gets wether the color grading effect is enabled.
  21877. */
  21878. set cameraColorGradingEnabled(value: boolean);
  21879. /**
  21880. * Gets wether tonemapping is enabled or not.
  21881. */
  21882. get cameraToneMappingEnabled(): boolean;
  21883. /**
  21884. * Sets wether tonemapping is enabled or not
  21885. */
  21886. set cameraToneMappingEnabled(value: boolean);
  21887. /**
  21888. * The camera exposure used on this material.
  21889. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21890. * This corresponds to a photographic exposure.
  21891. */
  21892. get cameraExposure(): number;
  21893. /**
  21894. * The camera exposure used on this material.
  21895. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21896. * This corresponds to a photographic exposure.
  21897. */
  21898. set cameraExposure(value: number);
  21899. /**
  21900. * Gets The camera contrast used on this material.
  21901. */
  21902. get cameraContrast(): number;
  21903. /**
  21904. * Sets The camera contrast used on this material.
  21905. */
  21906. set cameraContrast(value: number);
  21907. /**
  21908. * Gets the Color Grading 2D Lookup Texture.
  21909. */
  21910. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21911. /**
  21912. * Sets the Color Grading 2D Lookup Texture.
  21913. */
  21914. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21915. /**
  21916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21918. * 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;
  21919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21920. */
  21921. get cameraColorCurves(): Nullable<ColorCurves>;
  21922. /**
  21923. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21924. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21925. * 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;
  21926. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21927. */
  21928. set cameraColorCurves(value: Nullable<ColorCurves>);
  21929. /**
  21930. * Instantiates a new PBRMaterial instance.
  21931. *
  21932. * @param name The material name
  21933. * @param scene The scene the material will be use in.
  21934. */
  21935. constructor(name: string, scene: Scene);
  21936. /**
  21937. * Returns the name of this material class.
  21938. */
  21939. getClassName(): string;
  21940. /**
  21941. * Makes a duplicate of the current material.
  21942. * @param name - name to use for the new material.
  21943. */
  21944. clone(name: string): PBRMaterial;
  21945. /**
  21946. * Serializes this PBR Material.
  21947. * @returns - An object with the serialized material.
  21948. */
  21949. serialize(): any;
  21950. /**
  21951. * Parses a PBR Material from a serialized object.
  21952. * @param source - Serialized object.
  21953. * @param scene - BJS scene instance.
  21954. * @param rootUrl - url for the scene object
  21955. * @returns - PBRMaterial
  21956. */
  21957. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21958. }
  21959. }
  21960. declare module BABYLON {
  21961. /** @hidden */
  21962. export var mrtFragmentDeclaration: {
  21963. name: string;
  21964. shader: string;
  21965. };
  21966. }
  21967. declare module BABYLON {
  21968. /** @hidden */
  21969. export var geometryPixelShader: {
  21970. name: string;
  21971. shader: string;
  21972. };
  21973. }
  21974. declare module BABYLON {
  21975. /** @hidden */
  21976. export var geometryVertexShader: {
  21977. name: string;
  21978. shader: string;
  21979. };
  21980. }
  21981. declare module BABYLON {
  21982. /** @hidden */
  21983. interface ISavedTransformationMatrix {
  21984. world: Matrix;
  21985. viewProjection: Matrix;
  21986. }
  21987. /**
  21988. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21989. */
  21990. export class GeometryBufferRenderer {
  21991. /**
  21992. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  21993. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  21994. */
  21995. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  21996. /**
  21997. * Constant used to retrieve the position texture index in the G-Buffer textures array
  21998. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  21999. */
  22000. static readonly POSITION_TEXTURE_TYPE: number;
  22001. /**
  22002. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22003. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22004. */
  22005. static readonly VELOCITY_TEXTURE_TYPE: number;
  22006. /**
  22007. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22008. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22009. */
  22010. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22011. /**
  22012. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22013. * in order to compute objects velocities when enableVelocity is set to "true"
  22014. * @hidden
  22015. */
  22016. _previousTransformationMatrices: {
  22017. [index: number]: ISavedTransformationMatrix;
  22018. };
  22019. /**
  22020. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22021. * in order to compute objects velocities when enableVelocity is set to "true"
  22022. * @hidden
  22023. */
  22024. _previousBonesTransformationMatrices: {
  22025. [index: number]: Float32Array;
  22026. };
  22027. /**
  22028. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22029. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22030. */
  22031. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22032. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22033. renderTransparentMeshes: boolean;
  22034. private _scene;
  22035. private _resizeObserver;
  22036. private _multiRenderTarget;
  22037. private _ratio;
  22038. private _enablePosition;
  22039. private _enableVelocity;
  22040. private _enableReflectivity;
  22041. private _positionIndex;
  22042. private _velocityIndex;
  22043. private _reflectivityIndex;
  22044. private _depthNormalIndex;
  22045. private _linkedWithPrePass;
  22046. private _prePassRenderer;
  22047. private _attachments;
  22048. protected _effect: Effect;
  22049. protected _cachedDefines: string;
  22050. /**
  22051. * @hidden
  22052. * Sets up internal structures to share outputs with PrePassRenderer
  22053. * This method should only be called by the PrePassRenderer itself
  22054. */
  22055. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22056. /**
  22057. * @hidden
  22058. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22059. * This method should only be called by the PrePassRenderer itself
  22060. */
  22061. _unlinkPrePassRenderer(): void;
  22062. /**
  22063. * @hidden
  22064. * Resets the geometry buffer layout
  22065. */
  22066. _resetLayout(): void;
  22067. /**
  22068. * @hidden
  22069. * Replaces a texture in the geometry buffer renderer
  22070. * Useful when linking textures of the prepass renderer
  22071. */
  22072. _forceTextureType(geometryBufferType: number, index: number): void;
  22073. /**
  22074. * @hidden
  22075. * Sets texture attachments
  22076. * Useful when linking textures of the prepass renderer
  22077. */
  22078. _setAttachments(attachments: number[]): void;
  22079. /**
  22080. * @hidden
  22081. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22082. * Useful when linking textures of the prepass renderer
  22083. */
  22084. _linkInternalTexture(internalTexture: InternalTexture): void;
  22085. /**
  22086. * Gets the render list (meshes to be rendered) used in the G buffer.
  22087. */
  22088. get renderList(): Nullable<AbstractMesh[]>;
  22089. /**
  22090. * Set the render list (meshes to be rendered) used in the G buffer.
  22091. */
  22092. set renderList(meshes: Nullable<AbstractMesh[]>);
  22093. /**
  22094. * Gets wether or not G buffer are supported by the running hardware.
  22095. * This requires draw buffer supports
  22096. */
  22097. get isSupported(): boolean;
  22098. /**
  22099. * Returns the index of the given texture type in the G-Buffer textures array
  22100. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22101. * @returns the index of the given texture type in the G-Buffer textures array
  22102. */
  22103. getTextureIndex(textureType: number): number;
  22104. /**
  22105. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22106. */
  22107. get enablePosition(): boolean;
  22108. /**
  22109. * Sets whether or not objects positions are enabled for the G buffer.
  22110. */
  22111. set enablePosition(enable: boolean);
  22112. /**
  22113. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22114. */
  22115. get enableVelocity(): boolean;
  22116. /**
  22117. * Sets wether or not objects velocities are enabled for the G buffer.
  22118. */
  22119. set enableVelocity(enable: boolean);
  22120. /**
  22121. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22122. */
  22123. get enableReflectivity(): boolean;
  22124. /**
  22125. * Sets wether or not objects roughness are enabled for the G buffer.
  22126. */
  22127. set enableReflectivity(enable: boolean);
  22128. /**
  22129. * Gets the scene associated with the buffer.
  22130. */
  22131. get scene(): Scene;
  22132. /**
  22133. * Gets the ratio used by the buffer during its creation.
  22134. * How big is the buffer related to the main canvas.
  22135. */
  22136. get ratio(): number;
  22137. /** @hidden */
  22138. static _SceneComponentInitialization: (scene: Scene) => void;
  22139. /**
  22140. * Creates a new G Buffer for the scene
  22141. * @param scene The scene the buffer belongs to
  22142. * @param ratio How big is the buffer related to the main canvas.
  22143. */
  22144. constructor(scene: Scene, ratio?: number);
  22145. /**
  22146. * Checks wether everything is ready to render a submesh to the G buffer.
  22147. * @param subMesh the submesh to check readiness for
  22148. * @param useInstances is the mesh drawn using instance or not
  22149. * @returns true if ready otherwise false
  22150. */
  22151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22152. /**
  22153. * Gets the current underlying G Buffer.
  22154. * @returns the buffer
  22155. */
  22156. getGBuffer(): MultiRenderTarget;
  22157. /**
  22158. * Gets the number of samples used to render the buffer (anti aliasing).
  22159. */
  22160. get samples(): number;
  22161. /**
  22162. * Sets the number of samples used to render the buffer (anti aliasing).
  22163. */
  22164. set samples(value: number);
  22165. /**
  22166. * Disposes the renderer and frees up associated resources.
  22167. */
  22168. dispose(): void;
  22169. private _assignRenderTargetIndices;
  22170. protected _createRenderTargets(): void;
  22171. private _copyBonesTransformationMatrices;
  22172. }
  22173. }
  22174. declare module BABYLON {
  22175. /**
  22176. * Renders a pre pass of the scene
  22177. * This means every mesh in the scene will be rendered to a render target texture
  22178. * And then this texture will be composited to the rendering canvas with post processes
  22179. * It is necessary for effects like subsurface scattering or deferred shading
  22180. */
  22181. export class PrePassRenderer {
  22182. /** @hidden */
  22183. static _SceneComponentInitialization: (scene: Scene) => void;
  22184. private _textureFormats;
  22185. /**
  22186. * To save performance, we can excluded skinned meshes from the prepass
  22187. */
  22188. excludedSkinnedMesh: AbstractMesh[];
  22189. /**
  22190. * Force material to be excluded from the prepass
  22191. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22192. * and you don't want a material to show in the effect.
  22193. */
  22194. excludedMaterials: Material[];
  22195. private _textureIndices;
  22196. private _scene;
  22197. private _engine;
  22198. private _isDirty;
  22199. /**
  22200. * Number of textures in the multi render target texture where the scene is directly rendered
  22201. */
  22202. mrtCount: number;
  22203. /**
  22204. * The render target where the scene is directly rendered
  22205. */
  22206. prePassRT: MultiRenderTarget;
  22207. private _multiRenderAttachments;
  22208. private _defaultAttachments;
  22209. private _clearAttachments;
  22210. private _postProcesses;
  22211. private readonly _clearColor;
  22212. /**
  22213. * Image processing post process for composition
  22214. */
  22215. imageProcessingPostProcess: ImageProcessingPostProcess;
  22216. /**
  22217. * Configuration for prepass effects
  22218. */
  22219. private _effectConfigurations;
  22220. private _mrtFormats;
  22221. private _mrtLayout;
  22222. private _enabled;
  22223. /**
  22224. * Indicates if the prepass is enabled
  22225. */
  22226. get enabled(): boolean;
  22227. /**
  22228. * How many samples are used for MSAA of the scene render target
  22229. */
  22230. get samples(): number;
  22231. set samples(n: number);
  22232. private _geometryBuffer;
  22233. private _useGeometryBufferFallback;
  22234. /**
  22235. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22236. */
  22237. get useGeometryBufferFallback(): boolean;
  22238. set useGeometryBufferFallback(value: boolean);
  22239. /**
  22240. * Set to true to disable gamma transform in PrePass.
  22241. * Can be useful in case you already proceed to gamma transform on a material level
  22242. * and your post processes don't need to be in linear color space.
  22243. */
  22244. disableGammaTransform: boolean;
  22245. /**
  22246. * Instanciates a prepass renderer
  22247. * @param scene The scene
  22248. */
  22249. constructor(scene: Scene);
  22250. private _initializeAttachments;
  22251. private _createCompositionEffect;
  22252. /**
  22253. * Indicates if rendering a prepass is supported
  22254. */
  22255. get isSupported(): boolean;
  22256. /**
  22257. * Sets the proper output textures to draw in the engine.
  22258. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22259. * @param subMesh Submesh on which the effect is applied
  22260. */
  22261. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22262. /**
  22263. * Restores attachments for single texture draw.
  22264. */
  22265. restoreAttachments(): void;
  22266. /**
  22267. * @hidden
  22268. */
  22269. _beforeCameraDraw(): void;
  22270. /**
  22271. * @hidden
  22272. */
  22273. _afterCameraDraw(): void;
  22274. private _checkRTSize;
  22275. private _bindFrameBuffer;
  22276. /**
  22277. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22278. */
  22279. clear(): void;
  22280. private _setState;
  22281. private _updateGeometryBufferLayout;
  22282. /**
  22283. * Adds an effect configuration to the prepass.
  22284. * If an effect has already been added, it won't add it twice and will return the configuration
  22285. * already present.
  22286. * @param cfg the effect configuration
  22287. * @return the effect configuration now used by the prepass
  22288. */
  22289. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22290. /**
  22291. * Returns the index of a texture in the multi render target texture array.
  22292. * @param type Texture type
  22293. * @return The index
  22294. */
  22295. getIndex(type: number): number;
  22296. private _enable;
  22297. private _disable;
  22298. private _resetLayout;
  22299. private _resetPostProcessChain;
  22300. private _bindPostProcessChain;
  22301. /**
  22302. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22303. */
  22304. markAsDirty(): void;
  22305. /**
  22306. * Enables a texture on the MultiRenderTarget for prepass
  22307. */
  22308. private _enableTextures;
  22309. private _update;
  22310. private _markAllMaterialsAsPrePassDirty;
  22311. /**
  22312. * Disposes the prepass renderer.
  22313. */
  22314. dispose(): void;
  22315. }
  22316. }
  22317. declare module BABYLON {
  22318. /**
  22319. * Size options for a post process
  22320. */
  22321. export type PostProcessOptions = {
  22322. width: number;
  22323. height: number;
  22324. };
  22325. /**
  22326. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22327. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22328. */
  22329. export class PostProcess {
  22330. /**
  22331. * Gets or sets the unique id of the post process
  22332. */
  22333. uniqueId: number;
  22334. /** Name of the PostProcess. */
  22335. name: string;
  22336. /**
  22337. * Width of the texture to apply the post process on
  22338. */
  22339. width: number;
  22340. /**
  22341. * Height of the texture to apply the post process on
  22342. */
  22343. height: number;
  22344. /**
  22345. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22346. */
  22347. nodeMaterialSource: Nullable<NodeMaterial>;
  22348. /**
  22349. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22350. * @hidden
  22351. */
  22352. _outputTexture: Nullable<InternalTexture>;
  22353. /**
  22354. * Sampling mode used by the shader
  22355. * See https://doc.babylonjs.com/classes/3.1/texture
  22356. */
  22357. renderTargetSamplingMode: number;
  22358. /**
  22359. * Clear color to use when screen clearing
  22360. */
  22361. clearColor: Color4;
  22362. /**
  22363. * If the buffer needs to be cleared before applying the post process. (default: true)
  22364. * Should be set to false if shader will overwrite all previous pixels.
  22365. */
  22366. autoClear: boolean;
  22367. /**
  22368. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22369. */
  22370. alphaMode: number;
  22371. /**
  22372. * Sets the setAlphaBlendConstants of the babylon engine
  22373. */
  22374. alphaConstants: Color4;
  22375. /**
  22376. * Animations to be used for the post processing
  22377. */
  22378. animations: Animation[];
  22379. /**
  22380. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22381. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22382. */
  22383. enablePixelPerfectMode: boolean;
  22384. /**
  22385. * Force the postprocess to be applied without taking in account viewport
  22386. */
  22387. forceFullscreenViewport: boolean;
  22388. /**
  22389. * List of inspectable custom properties (used by the Inspector)
  22390. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22391. */
  22392. inspectableCustomProperties: IInspectable[];
  22393. /**
  22394. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22395. *
  22396. * | Value | Type | Description |
  22397. * | ----- | ----------------------------------- | ----------- |
  22398. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22399. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22400. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22401. *
  22402. */
  22403. scaleMode: number;
  22404. /**
  22405. * Force textures to be a power of two (default: false)
  22406. */
  22407. alwaysForcePOT: boolean;
  22408. private _samples;
  22409. /**
  22410. * Number of sample textures (default: 1)
  22411. */
  22412. get samples(): number;
  22413. set samples(n: number);
  22414. /**
  22415. * Modify the scale of the post process to be the same as the viewport (default: false)
  22416. */
  22417. adaptScaleToCurrentViewport: boolean;
  22418. private _camera;
  22419. protected _scene: Scene;
  22420. private _engine;
  22421. private _options;
  22422. private _reusable;
  22423. private _textureType;
  22424. private _textureFormat;
  22425. /**
  22426. * Smart array of input and output textures for the post process.
  22427. * @hidden
  22428. */
  22429. _textures: SmartArray<InternalTexture>;
  22430. /**
  22431. * The index in _textures that corresponds to the output texture.
  22432. * @hidden
  22433. */
  22434. _currentRenderTextureInd: number;
  22435. private _effect;
  22436. private _samplers;
  22437. private _fragmentUrl;
  22438. private _vertexUrl;
  22439. private _parameters;
  22440. private _scaleRatio;
  22441. protected _indexParameters: any;
  22442. private _shareOutputWithPostProcess;
  22443. private _texelSize;
  22444. private _forcedOutputTexture;
  22445. /**
  22446. * Prepass configuration in case this post process needs a texture from prepass
  22447. * @hidden
  22448. */
  22449. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22450. /**
  22451. * Returns the fragment url or shader name used in the post process.
  22452. * @returns the fragment url or name in the shader store.
  22453. */
  22454. getEffectName(): string;
  22455. /**
  22456. * An event triggered when the postprocess is activated.
  22457. */
  22458. onActivateObservable: Observable<Camera>;
  22459. private _onActivateObserver;
  22460. /**
  22461. * A function that is added to the onActivateObservable
  22462. */
  22463. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22464. /**
  22465. * An event triggered when the postprocess changes its size.
  22466. */
  22467. onSizeChangedObservable: Observable<PostProcess>;
  22468. private _onSizeChangedObserver;
  22469. /**
  22470. * A function that is added to the onSizeChangedObservable
  22471. */
  22472. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22473. /**
  22474. * An event triggered when the postprocess applies its effect.
  22475. */
  22476. onApplyObservable: Observable<Effect>;
  22477. private _onApplyObserver;
  22478. /**
  22479. * A function that is added to the onApplyObservable
  22480. */
  22481. set onApply(callback: (effect: Effect) => void);
  22482. /**
  22483. * An event triggered before rendering the postprocess
  22484. */
  22485. onBeforeRenderObservable: Observable<Effect>;
  22486. private _onBeforeRenderObserver;
  22487. /**
  22488. * A function that is added to the onBeforeRenderObservable
  22489. */
  22490. set onBeforeRender(callback: (effect: Effect) => void);
  22491. /**
  22492. * An event triggered after rendering the postprocess
  22493. */
  22494. onAfterRenderObservable: Observable<Effect>;
  22495. private _onAfterRenderObserver;
  22496. /**
  22497. * A function that is added to the onAfterRenderObservable
  22498. */
  22499. set onAfterRender(callback: (efect: Effect) => void);
  22500. /**
  22501. * 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
  22502. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22503. */
  22504. get inputTexture(): InternalTexture;
  22505. set inputTexture(value: InternalTexture);
  22506. /**
  22507. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22508. * the only way to unset it is to use this function to restore its internal state
  22509. */
  22510. restoreDefaultInputTexture(): void;
  22511. /**
  22512. * Gets the camera which post process is applied to.
  22513. * @returns The camera the post process is applied to.
  22514. */
  22515. getCamera(): Camera;
  22516. /**
  22517. * Gets the texel size of the postprocess.
  22518. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22519. */
  22520. get texelSize(): Vector2;
  22521. /**
  22522. * Creates a new instance PostProcess
  22523. * @param name The name of the PostProcess.
  22524. * @param fragmentUrl The url of the fragment shader to be used.
  22525. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22526. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22527. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22528. * @param camera The camera to apply the render pass to.
  22529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22530. * @param engine The engine which the post process will be applied. (default: current engine)
  22531. * @param reusable If the post process can be reused on the same frame. (default: false)
  22532. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22533. * @param textureType Type of textures used when performing the post process. (default: 0)
  22534. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22535. * @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
  22536. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22537. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22538. */
  22539. 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);
  22540. /**
  22541. * Gets a string identifying the name of the class
  22542. * @returns "PostProcess" string
  22543. */
  22544. getClassName(): string;
  22545. /**
  22546. * Gets the engine which this post process belongs to.
  22547. * @returns The engine the post process was enabled with.
  22548. */
  22549. getEngine(): Engine;
  22550. /**
  22551. * The effect that is created when initializing the post process.
  22552. * @returns The created effect corresponding the the postprocess.
  22553. */
  22554. getEffect(): Effect;
  22555. /**
  22556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22557. * @param postProcess The post process to share the output with.
  22558. * @returns This post process.
  22559. */
  22560. shareOutputWith(postProcess: PostProcess): PostProcess;
  22561. /**
  22562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22564. */
  22565. useOwnOutput(): void;
  22566. /**
  22567. * Updates the effect with the current post process compile time values and recompiles the shader.
  22568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22571. * @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
  22572. * @param onCompiled Called when the shader has been compiled.
  22573. * @param onError Called if there is an error when compiling a shader.
  22574. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22575. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22576. */
  22577. 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;
  22578. /**
  22579. * The post process is reusable if it can be used multiple times within one frame.
  22580. * @returns If the post process is reusable
  22581. */
  22582. isReusable(): boolean;
  22583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22584. markTextureDirty(): void;
  22585. /**
  22586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22587. * 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.
  22588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22591. * @returns The target texture that was bound to be written to.
  22592. */
  22593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22594. /**
  22595. * If the post process is supported.
  22596. */
  22597. get isSupported(): boolean;
  22598. /**
  22599. * The aspect ratio of the output texture.
  22600. */
  22601. get aspectRatio(): number;
  22602. /**
  22603. * Get a value indicating if the post-process is ready to be used
  22604. * @returns true if the post-process is ready (shader is compiled)
  22605. */
  22606. isReady(): boolean;
  22607. /**
  22608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22610. */
  22611. apply(): Nullable<Effect>;
  22612. private _disposeTextures;
  22613. /**
  22614. * Sets the required values to the prepass renderer.
  22615. * @param prePassRenderer defines the prepass renderer to setup.
  22616. * @returns true if the pre pass is needed.
  22617. */
  22618. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22619. /**
  22620. * Disposes the post process.
  22621. * @param camera The camera to dispose the post process on.
  22622. */
  22623. dispose(camera?: Camera): void;
  22624. /**
  22625. * Serializes the particle system to a JSON object
  22626. * @returns the JSON object
  22627. */
  22628. serialize(): any;
  22629. /**
  22630. * Creates a material from parsed material data
  22631. * @param parsedPostProcess defines parsed post process data
  22632. * @param scene defines the hosting scene
  22633. * @param rootUrl defines the root URL to use to load textures
  22634. * @returns a new post process
  22635. */
  22636. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22637. }
  22638. }
  22639. declare module BABYLON {
  22640. /** @hidden */
  22641. export var kernelBlurVaryingDeclaration: {
  22642. name: string;
  22643. shader: string;
  22644. };
  22645. }
  22646. declare module BABYLON {
  22647. /** @hidden */
  22648. export var packingFunctions: {
  22649. name: string;
  22650. shader: string;
  22651. };
  22652. }
  22653. declare module BABYLON {
  22654. /** @hidden */
  22655. export var kernelBlurFragment: {
  22656. name: string;
  22657. shader: string;
  22658. };
  22659. }
  22660. declare module BABYLON {
  22661. /** @hidden */
  22662. export var kernelBlurFragment2: {
  22663. name: string;
  22664. shader: string;
  22665. };
  22666. }
  22667. declare module BABYLON {
  22668. /** @hidden */
  22669. export var kernelBlurPixelShader: {
  22670. name: string;
  22671. shader: string;
  22672. };
  22673. }
  22674. declare module BABYLON {
  22675. /** @hidden */
  22676. export var kernelBlurVertex: {
  22677. name: string;
  22678. shader: string;
  22679. };
  22680. }
  22681. declare module BABYLON {
  22682. /** @hidden */
  22683. export var kernelBlurVertexShader: {
  22684. name: string;
  22685. shader: string;
  22686. };
  22687. }
  22688. declare module BABYLON {
  22689. /**
  22690. * The Blur Post Process which blurs an image based on a kernel and direction.
  22691. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22692. */
  22693. export class BlurPostProcess extends PostProcess {
  22694. private blockCompilation;
  22695. protected _kernel: number;
  22696. protected _idealKernel: number;
  22697. protected _packedFloat: boolean;
  22698. private _staticDefines;
  22699. /** The direction in which to blur the image. */
  22700. direction: Vector2;
  22701. /**
  22702. * Sets the length in pixels of the blur sample region
  22703. */
  22704. set kernel(v: number);
  22705. /**
  22706. * Gets the length in pixels of the blur sample region
  22707. */
  22708. get kernel(): number;
  22709. /**
  22710. * Sets wether or not the blur needs to unpack/repack floats
  22711. */
  22712. set packedFloat(v: boolean);
  22713. /**
  22714. * Gets wether or not the blur is unpacking/repacking floats
  22715. */
  22716. get packedFloat(): boolean;
  22717. /**
  22718. * Gets a string identifying the name of the class
  22719. * @returns "BlurPostProcess" string
  22720. */
  22721. getClassName(): string;
  22722. /**
  22723. * Creates a new instance BlurPostProcess
  22724. * @param name The name of the effect.
  22725. * @param direction The direction in which to blur the image.
  22726. * @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.
  22727. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22728. * @param camera The camera to apply the render pass to.
  22729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22730. * @param engine The engine which the post process will be applied. (default: current engine)
  22731. * @param reusable If the post process can be reused on the same frame. (default: false)
  22732. * @param textureType Type of textures used when performing the post process. (default: 0)
  22733. * @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)
  22734. */
  22735. 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);
  22736. /**
  22737. * Updates the effect with the current post process compile time values and recompiles the shader.
  22738. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22739. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22740. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22741. * @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
  22742. * @param onCompiled Called when the shader has been compiled.
  22743. * @param onError Called if there is an error when compiling a shader.
  22744. */
  22745. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22746. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22747. /**
  22748. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22749. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22750. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22751. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22752. * The gaps between physical kernels are compensated for in the weighting of the samples
  22753. * @param idealKernel Ideal blur kernel.
  22754. * @return Nearest best kernel.
  22755. */
  22756. protected _nearestBestKernel(idealKernel: number): number;
  22757. /**
  22758. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22759. * @param x The point on the Gaussian distribution to sample.
  22760. * @return the value of the Gaussian function at x.
  22761. */
  22762. protected _gaussianWeight(x: number): number;
  22763. /**
  22764. * Generates a string that can be used as a floating point number in GLSL.
  22765. * @param x Value to print.
  22766. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22767. * @return GLSL float string.
  22768. */
  22769. protected _glslFloat(x: number, decimalFigures?: number): string;
  22770. /** @hidden */
  22771. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22772. }
  22773. }
  22774. declare module BABYLON {
  22775. /**
  22776. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22777. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22778. * You can then easily use it as a reflectionTexture on a flat surface.
  22779. * In case the surface is not a plane, please consider relying on reflection probes.
  22780. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22781. */
  22782. export class MirrorTexture extends RenderTargetTexture {
  22783. private scene;
  22784. /**
  22785. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22786. * 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.
  22787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22788. */
  22789. mirrorPlane: Plane;
  22790. /**
  22791. * Define the blur ratio used to blur the reflection if needed.
  22792. */
  22793. set blurRatio(value: number);
  22794. get blurRatio(): number;
  22795. /**
  22796. * Define the adaptive blur kernel used to blur the reflection if needed.
  22797. * This will autocompute the closest best match for the `blurKernel`
  22798. */
  22799. set adaptiveBlurKernel(value: number);
  22800. /**
  22801. * Define the blur kernel used to blur the reflection if needed.
  22802. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22803. */
  22804. set blurKernel(value: number);
  22805. /**
  22806. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22807. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22808. */
  22809. set blurKernelX(value: number);
  22810. get blurKernelX(): number;
  22811. /**
  22812. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22814. */
  22815. set blurKernelY(value: number);
  22816. get blurKernelY(): number;
  22817. private _autoComputeBlurKernel;
  22818. protected _onRatioRescale(): void;
  22819. private _updateGammaSpace;
  22820. private _imageProcessingConfigChangeObserver;
  22821. private _transformMatrix;
  22822. private _mirrorMatrix;
  22823. private _savedViewMatrix;
  22824. private _blurX;
  22825. private _blurY;
  22826. private _adaptiveBlurKernel;
  22827. private _blurKernelX;
  22828. private _blurKernelY;
  22829. private _blurRatio;
  22830. /**
  22831. * Instantiates a Mirror Texture.
  22832. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22833. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22834. * You can then easily use it as a reflectionTexture on a flat surface.
  22835. * In case the surface is not a plane, please consider relying on reflection probes.
  22836. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22837. * @param name
  22838. * @param size
  22839. * @param scene
  22840. * @param generateMipMaps
  22841. * @param type
  22842. * @param samplingMode
  22843. * @param generateDepthBuffer
  22844. */
  22845. constructor(name: string, size: number | {
  22846. width: number;
  22847. height: number;
  22848. } | {
  22849. ratio: number;
  22850. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22851. private _preparePostProcesses;
  22852. /**
  22853. * Clone the mirror texture.
  22854. * @returns the cloned texture
  22855. */
  22856. clone(): MirrorTexture;
  22857. /**
  22858. * Serialize the texture to a JSON representation you could use in Parse later on
  22859. * @returns the serialized JSON representation
  22860. */
  22861. serialize(): any;
  22862. /**
  22863. * Dispose the texture and release its associated resources.
  22864. */
  22865. dispose(): void;
  22866. }
  22867. }
  22868. declare module BABYLON {
  22869. /**
  22870. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22871. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22872. */
  22873. export class Texture extends BaseTexture {
  22874. /**
  22875. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22876. */
  22877. static SerializeBuffers: boolean;
  22878. /**
  22879. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22880. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22881. */
  22882. static ForceSerializeBuffers: boolean;
  22883. /** @hidden */
  22884. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22885. /** @hidden */
  22886. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22887. /** @hidden */
  22888. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22889. /** nearest is mag = nearest and min = nearest and mip = linear */
  22890. static readonly NEAREST_SAMPLINGMODE: number;
  22891. /** nearest is mag = nearest and min = nearest and mip = linear */
  22892. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22893. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22894. static readonly BILINEAR_SAMPLINGMODE: number;
  22895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22896. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22897. /** Trilinear is mag = linear and min = linear and mip = linear */
  22898. static readonly TRILINEAR_SAMPLINGMODE: number;
  22899. /** Trilinear is mag = linear and min = linear and mip = linear */
  22900. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22901. /** mag = nearest and min = nearest and mip = nearest */
  22902. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22903. /** mag = nearest and min = linear and mip = nearest */
  22904. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22905. /** mag = nearest and min = linear and mip = linear */
  22906. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22907. /** mag = nearest and min = linear and mip = none */
  22908. static readonly NEAREST_LINEAR: number;
  22909. /** mag = nearest and min = nearest and mip = none */
  22910. static readonly NEAREST_NEAREST: number;
  22911. /** mag = linear and min = nearest and mip = nearest */
  22912. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22913. /** mag = linear and min = nearest and mip = linear */
  22914. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22915. /** mag = linear and min = linear and mip = none */
  22916. static readonly LINEAR_LINEAR: number;
  22917. /** mag = linear and min = nearest and mip = none */
  22918. static readonly LINEAR_NEAREST: number;
  22919. /** Explicit coordinates mode */
  22920. static readonly EXPLICIT_MODE: number;
  22921. /** Spherical coordinates mode */
  22922. static readonly SPHERICAL_MODE: number;
  22923. /** Planar coordinates mode */
  22924. static readonly PLANAR_MODE: number;
  22925. /** Cubic coordinates mode */
  22926. static readonly CUBIC_MODE: number;
  22927. /** Projection coordinates mode */
  22928. static readonly PROJECTION_MODE: number;
  22929. /** Inverse Cubic coordinates mode */
  22930. static readonly SKYBOX_MODE: number;
  22931. /** Inverse Cubic coordinates mode */
  22932. static readonly INVCUBIC_MODE: number;
  22933. /** Equirectangular coordinates mode */
  22934. static readonly EQUIRECTANGULAR_MODE: number;
  22935. /** Equirectangular Fixed coordinates mode */
  22936. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22937. /** Equirectangular Fixed Mirrored coordinates mode */
  22938. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22939. /** Texture is not repeating outside of 0..1 UVs */
  22940. static readonly CLAMP_ADDRESSMODE: number;
  22941. /** Texture is repeating outside of 0..1 UVs */
  22942. static readonly WRAP_ADDRESSMODE: number;
  22943. /** Texture is repeating and mirrored */
  22944. static readonly MIRROR_ADDRESSMODE: number;
  22945. /**
  22946. * 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
  22947. */
  22948. static UseSerializedUrlIfAny: boolean;
  22949. /**
  22950. * Define the url of the texture.
  22951. */
  22952. url: Nullable<string>;
  22953. /**
  22954. * Define an offset on the texture to offset the u coordinates of the UVs
  22955. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22956. */
  22957. uOffset: number;
  22958. /**
  22959. * Define an offset on the texture to offset the v coordinates of the UVs
  22960. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22961. */
  22962. vOffset: number;
  22963. /**
  22964. * Define an offset on the texture to scale the u coordinates of the UVs
  22965. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22966. */
  22967. uScale: number;
  22968. /**
  22969. * Define an offset on the texture to scale the v coordinates of the UVs
  22970. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22971. */
  22972. vScale: number;
  22973. /**
  22974. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22975. * @see https://doc.babylonjs.com/how_to/more_materials
  22976. */
  22977. uAng: number;
  22978. /**
  22979. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22980. * @see https://doc.babylonjs.com/how_to/more_materials
  22981. */
  22982. vAng: number;
  22983. /**
  22984. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22985. * @see https://doc.babylonjs.com/how_to/more_materials
  22986. */
  22987. wAng: number;
  22988. /**
  22989. * Defines the center of rotation (U)
  22990. */
  22991. uRotationCenter: number;
  22992. /**
  22993. * Defines the center of rotation (V)
  22994. */
  22995. vRotationCenter: number;
  22996. /**
  22997. * Defines the center of rotation (W)
  22998. */
  22999. wRotationCenter: number;
  23000. /**
  23001. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23002. */
  23003. homogeneousRotationInUVTransform: boolean;
  23004. /**
  23005. * Are mip maps generated for this texture or not.
  23006. */
  23007. get noMipmap(): boolean;
  23008. /**
  23009. * List of inspectable custom properties (used by the Inspector)
  23010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23011. */
  23012. inspectableCustomProperties: Nullable<IInspectable[]>;
  23013. private _noMipmap;
  23014. /** @hidden */
  23015. _invertY: boolean;
  23016. private _rowGenerationMatrix;
  23017. private _cachedTextureMatrix;
  23018. private _projectionModeMatrix;
  23019. private _t0;
  23020. private _t1;
  23021. private _t2;
  23022. private _cachedUOffset;
  23023. private _cachedVOffset;
  23024. private _cachedUScale;
  23025. private _cachedVScale;
  23026. private _cachedUAng;
  23027. private _cachedVAng;
  23028. private _cachedWAng;
  23029. private _cachedProjectionMatrixId;
  23030. private _cachedURotationCenter;
  23031. private _cachedVRotationCenter;
  23032. private _cachedWRotationCenter;
  23033. private _cachedHomogeneousRotationInUVTransform;
  23034. private _cachedCoordinatesMode;
  23035. /** @hidden */
  23036. protected _initialSamplingMode: number;
  23037. /** @hidden */
  23038. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23039. private _deleteBuffer;
  23040. protected _format: Nullable<number>;
  23041. private _delayedOnLoad;
  23042. private _delayedOnError;
  23043. private _mimeType?;
  23044. private _loaderOptions?;
  23045. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23046. get mimeType(): string | undefined;
  23047. /**
  23048. * Observable triggered once the texture has been loaded.
  23049. */
  23050. onLoadObservable: Observable<Texture>;
  23051. protected _isBlocking: boolean;
  23052. /**
  23053. * Is the texture preventing material to render while loading.
  23054. * If false, a default texture will be used instead of the loading one during the preparation step.
  23055. */
  23056. set isBlocking(value: boolean);
  23057. get isBlocking(): boolean;
  23058. /**
  23059. * Get the current sampling mode associated with the texture.
  23060. */
  23061. get samplingMode(): number;
  23062. /**
  23063. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23064. */
  23065. get invertY(): boolean;
  23066. /**
  23067. * Instantiates a new texture.
  23068. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23069. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23070. * @param url defines the url of the picture to load as a texture
  23071. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23072. * @param noMipmap defines if the texture will require mip maps or not
  23073. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23074. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23075. * @param onLoad defines a callback triggered when the texture has been loaded
  23076. * @param onError defines a callback triggered when an error occurred during the loading session
  23077. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23078. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23079. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23080. * @param mimeType defines an optional mime type information
  23081. * @param loaderOptions options to be passed to the loader
  23082. */
  23083. 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, loaderOptions?: any);
  23084. /**
  23085. * Update the url (and optional buffer) of this texture if url was null during construction.
  23086. * @param url the url of the texture
  23087. * @param buffer the buffer of the texture (defaults to null)
  23088. * @param onLoad callback called when the texture is loaded (defaults to null)
  23089. */
  23090. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23091. /**
  23092. * Finish the loading sequence of a texture flagged as delayed load.
  23093. * @hidden
  23094. */
  23095. delayLoad(): void;
  23096. private _prepareRowForTextureGeneration;
  23097. /**
  23098. * Checks if the texture has the same transform matrix than another texture
  23099. * @param texture texture to check against
  23100. * @returns true if the transforms are the same, else false
  23101. */
  23102. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23103. /**
  23104. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23105. * @returns the transform matrix of the texture.
  23106. */
  23107. getTextureMatrix(uBase?: number): Matrix;
  23108. /**
  23109. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23110. * @returns The reflection texture transform
  23111. */
  23112. getReflectionTextureMatrix(): Matrix;
  23113. /**
  23114. * Clones the texture.
  23115. * @returns the cloned texture
  23116. */
  23117. clone(): Texture;
  23118. /**
  23119. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23120. * @returns The JSON representation of the texture
  23121. */
  23122. serialize(): any;
  23123. /**
  23124. * Get the current class name of the texture useful for serialization or dynamic coding.
  23125. * @returns "Texture"
  23126. */
  23127. getClassName(): string;
  23128. /**
  23129. * Dispose the texture and release its associated resources.
  23130. */
  23131. dispose(): void;
  23132. /**
  23133. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23134. * @param parsedTexture Define the JSON representation of the texture
  23135. * @param scene Define the scene the parsed texture should be instantiated in
  23136. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23137. * @returns The parsed texture if successful
  23138. */
  23139. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23140. /**
  23141. * Creates a texture from its base 64 representation.
  23142. * @param data Define the base64 payload without the data: prefix
  23143. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23144. * @param scene Define the scene the texture should belong to
  23145. * @param noMipmap Forces the texture to not create mip map information if true
  23146. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23147. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23148. * @param onLoad define a callback triggered when the texture has been loaded
  23149. * @param onError define a callback triggered when an error occurred during the loading session
  23150. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23151. * @returns the created texture
  23152. */
  23153. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23154. /**
  23155. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23156. * @param data Define the base64 payload without the data: prefix
  23157. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23158. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23159. * @param scene Define the scene the texture should belong to
  23160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23161. * @param noMipmap Forces the texture to not create mip map information if true
  23162. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23163. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23164. * @param onLoad define a callback triggered when the texture has been loaded
  23165. * @param onError define a callback triggered when an error occurred during the loading session
  23166. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23167. * @returns the created texture
  23168. */
  23169. 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;
  23170. }
  23171. }
  23172. declare module BABYLON {
  23173. /**
  23174. * ThinSprite Class used to represent a thin sprite
  23175. * This is the base class for sprites but can also directly be used with ThinEngine
  23176. * @see https://doc.babylonjs.com/babylon101/sprites
  23177. */
  23178. export class ThinSprite {
  23179. /** Gets or sets the cell index in the sprite sheet */
  23180. cellIndex: number;
  23181. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23182. cellRef: string;
  23183. /** Gets or sets the current world position */
  23184. position: IVector3Like;
  23185. /** Gets or sets the main color */
  23186. color: IColor4Like;
  23187. /** Gets or sets the width */
  23188. width: number;
  23189. /** Gets or sets the height */
  23190. height: number;
  23191. /** Gets or sets rotation angle */
  23192. angle: number;
  23193. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23194. invertU: boolean;
  23195. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23196. invertV: boolean;
  23197. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23198. isVisible: boolean;
  23199. /**
  23200. * Returns a boolean indicating if the animation is started
  23201. */
  23202. get animationStarted(): boolean;
  23203. /** Gets the initial key for the animation (setting it will restart the animation) */
  23204. get fromIndex(): number;
  23205. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23206. get toIndex(): number;
  23207. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23208. get loopAnimation(): boolean;
  23209. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23210. get delay(): number;
  23211. /** @hidden */
  23212. _xOffset: number;
  23213. /** @hidden */
  23214. _yOffset: number;
  23215. /** @hidden */
  23216. _xSize: number;
  23217. /** @hidden */
  23218. _ySize: number;
  23219. private _animationStarted;
  23220. protected _loopAnimation: boolean;
  23221. protected _fromIndex: number;
  23222. protected _toIndex: number;
  23223. protected _delay: number;
  23224. private _direction;
  23225. private _time;
  23226. private _onBaseAnimationEnd;
  23227. /**
  23228. * Creates a new Thin Sprite
  23229. */
  23230. constructor();
  23231. /**
  23232. * Starts an animation
  23233. * @param from defines the initial key
  23234. * @param to defines the end key
  23235. * @param loop defines if the animation must loop
  23236. * @param delay defines the start delay (in ms)
  23237. * @param onAnimationEnd defines a callback for when the animation ends
  23238. */
  23239. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23240. /** Stops current animation (if any) */
  23241. stopAnimation(): void;
  23242. /** @hidden */
  23243. _animate(deltaTime: number): void;
  23244. }
  23245. }
  23246. declare module BABYLON {
  23247. /** @hidden */
  23248. export var imageProcessingCompatibility: {
  23249. name: string;
  23250. shader: string;
  23251. };
  23252. }
  23253. declare module BABYLON {
  23254. /** @hidden */
  23255. export var spritesPixelShader: {
  23256. name: string;
  23257. shader: string;
  23258. };
  23259. }
  23260. declare module BABYLON {
  23261. /** @hidden */
  23262. export var spritesVertexShader: {
  23263. name: string;
  23264. shader: string;
  23265. };
  23266. }
  23267. declare module BABYLON {
  23268. /**
  23269. * Class used to render sprites.
  23270. *
  23271. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23272. */
  23273. export class SpriteRenderer {
  23274. /**
  23275. * Defines the texture of the spritesheet
  23276. */
  23277. texture: Nullable<ThinTexture>;
  23278. /**
  23279. * Defines the default width of a cell in the spritesheet
  23280. */
  23281. cellWidth: number;
  23282. /**
  23283. * Defines the default height of a cell in the spritesheet
  23284. */
  23285. cellHeight: number;
  23286. /**
  23287. * Blend mode use to render the particle, it can be any of
  23288. * the static Constants.ALPHA_x properties provided in this class.
  23289. * Default value is Constants.ALPHA_COMBINE
  23290. */
  23291. blendMode: number;
  23292. /**
  23293. * Gets or sets a boolean indicating if alpha mode is automatically
  23294. * reset.
  23295. */
  23296. autoResetAlpha: boolean;
  23297. /**
  23298. * Disables writing to the depth buffer when rendering the sprites.
  23299. * It can be handy to disable depth writing when using textures without alpha channel
  23300. * and setting some specific blend modes.
  23301. */
  23302. disableDepthWrite: boolean;
  23303. /**
  23304. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23305. */
  23306. fogEnabled: boolean;
  23307. /**
  23308. * Gets the capacity of the manager
  23309. */
  23310. get capacity(): number;
  23311. private readonly _engine;
  23312. private readonly _useVAO;
  23313. private readonly _useInstancing;
  23314. private readonly _scene;
  23315. private readonly _capacity;
  23316. private readonly _epsilon;
  23317. private _vertexBufferSize;
  23318. private _vertexData;
  23319. private _buffer;
  23320. private _vertexBuffers;
  23321. private _spriteBuffer;
  23322. private _indexBuffer;
  23323. private _effectBase;
  23324. private _effectFog;
  23325. private _vertexArrayObject;
  23326. /**
  23327. * Creates a new sprite Renderer
  23328. * @param engine defines the engine the renderer works with
  23329. * @param capacity defines the maximum allowed number of sprites
  23330. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23331. * @param scene defines the hosting scene
  23332. */
  23333. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23334. /**
  23335. * Render all child sprites
  23336. * @param sprites defines the list of sprites to render
  23337. * @param deltaTime defines the time since last frame
  23338. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23339. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23340. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23341. */
  23342. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23343. private _appendSpriteVertex;
  23344. /**
  23345. * Release associated resources
  23346. */
  23347. dispose(): void;
  23348. }
  23349. }
  23350. declare module BABYLON {
  23351. /**
  23352. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23353. */
  23354. export interface ISpriteManager extends IDisposable {
  23355. /**
  23356. * Gets manager's name
  23357. */
  23358. name: string;
  23359. /**
  23360. * Restricts the camera to viewing objects with the same layerMask.
  23361. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23362. */
  23363. layerMask: number;
  23364. /**
  23365. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23366. */
  23367. isPickable: boolean;
  23368. /**
  23369. * Gets the hosting scene
  23370. */
  23371. scene: Scene;
  23372. /**
  23373. * Specifies the rendering group id for this mesh (0 by default)
  23374. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23375. */
  23376. renderingGroupId: number;
  23377. /**
  23378. * Defines the list of sprites managed by the manager.
  23379. */
  23380. sprites: Array<Sprite>;
  23381. /**
  23382. * Gets or sets the spritesheet texture
  23383. */
  23384. texture: Texture;
  23385. /** Defines the default width of a cell in the spritesheet */
  23386. cellWidth: number;
  23387. /** Defines the default height of a cell in the spritesheet */
  23388. cellHeight: number;
  23389. /**
  23390. * Tests the intersection of a sprite with a specific ray.
  23391. * @param ray The ray we are sending to test the collision
  23392. * @param camera The camera space we are sending rays in
  23393. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23394. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23395. * @returns picking info or null.
  23396. */
  23397. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23398. /**
  23399. * Intersects the sprites with a ray
  23400. * @param ray defines the ray to intersect with
  23401. * @param camera defines the current active camera
  23402. * @param predicate defines a predicate used to select candidate sprites
  23403. * @returns null if no hit or a PickingInfo array
  23404. */
  23405. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23406. /**
  23407. * Renders the list of sprites on screen.
  23408. */
  23409. render(): void;
  23410. }
  23411. /**
  23412. * Class used to manage multiple sprites on the same spritesheet
  23413. * @see https://doc.babylonjs.com/babylon101/sprites
  23414. */
  23415. export class SpriteManager implements ISpriteManager {
  23416. /** defines the manager's name */
  23417. name: string;
  23418. /** Define the Url to load snippets */
  23419. static SnippetUrl: string;
  23420. /** Snippet ID if the manager was created from the snippet server */
  23421. snippetId: string;
  23422. /** Gets the list of sprites */
  23423. sprites: Sprite[];
  23424. /** Gets or sets the rendering group id (0 by default) */
  23425. renderingGroupId: number;
  23426. /** Gets or sets camera layer mask */
  23427. layerMask: number;
  23428. /** Gets or sets a boolean indicating if the sprites are pickable */
  23429. isPickable: boolean;
  23430. /**
  23431. * An event triggered when the manager is disposed.
  23432. */
  23433. onDisposeObservable: Observable<SpriteManager>;
  23434. /**
  23435. * Callback called when the manager is disposed
  23436. */
  23437. set onDispose(callback: () => void);
  23438. /**
  23439. * Gets or sets the unique id of the sprite
  23440. */
  23441. uniqueId: number;
  23442. /**
  23443. * Gets the array of sprites
  23444. */
  23445. get children(): Sprite[];
  23446. /**
  23447. * Gets the hosting scene
  23448. */
  23449. get scene(): Scene;
  23450. /**
  23451. * Gets the capacity of the manager
  23452. */
  23453. get capacity(): number;
  23454. /**
  23455. * Gets or sets the spritesheet texture
  23456. */
  23457. get texture(): Texture;
  23458. set texture(value: Texture);
  23459. /** Defines the default width of a cell in the spritesheet */
  23460. get cellWidth(): number;
  23461. set cellWidth(value: number);
  23462. /** Defines the default height of a cell in the spritesheet */
  23463. get cellHeight(): number;
  23464. set cellHeight(value: number);
  23465. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23466. get fogEnabled(): boolean;
  23467. set fogEnabled(value: boolean);
  23468. /**
  23469. * Blend mode use to render the particle, it can be any of
  23470. * the static Constants.ALPHA_x properties provided in this class.
  23471. * Default value is Constants.ALPHA_COMBINE
  23472. */
  23473. get blendMode(): number;
  23474. set blendMode(blendMode: number);
  23475. /** Disables writing to the depth buffer when rendering the sprites.
  23476. * It can be handy to disable depth writing when using textures without alpha channel
  23477. * and setting some specific blend modes.
  23478. */
  23479. disableDepthWrite: boolean;
  23480. private _spriteRenderer;
  23481. /** Associative array from JSON sprite data file */
  23482. private _cellData;
  23483. /** Array of sprite names from JSON sprite data file */
  23484. private _spriteMap;
  23485. /** True when packed cell data from JSON file is ready*/
  23486. private _packedAndReady;
  23487. private _textureContent;
  23488. private _onDisposeObserver;
  23489. private _fromPacked;
  23490. private _scene;
  23491. /**
  23492. * Creates a new sprite manager
  23493. * @param name defines the manager's name
  23494. * @param imgUrl defines the sprite sheet url
  23495. * @param capacity defines the maximum allowed number of sprites
  23496. * @param cellSize defines the size of a sprite cell
  23497. * @param scene defines the hosting scene
  23498. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23499. * @param samplingMode defines the smapling mode to use with spritesheet
  23500. * @param fromPacked set to false; do not alter
  23501. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23502. */
  23503. constructor(
  23504. /** defines the manager's name */
  23505. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23506. /**
  23507. * Returns the string "SpriteManager"
  23508. * @returns "SpriteManager"
  23509. */
  23510. getClassName(): string;
  23511. private _makePacked;
  23512. private _checkTextureAlpha;
  23513. /**
  23514. * Intersects the sprites with a ray
  23515. * @param ray defines the ray to intersect with
  23516. * @param camera defines the current active camera
  23517. * @param predicate defines a predicate used to select candidate sprites
  23518. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23519. * @returns null if no hit or a PickingInfo
  23520. */
  23521. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23522. /**
  23523. * Intersects the sprites with a ray
  23524. * @param ray defines the ray to intersect with
  23525. * @param camera defines the current active camera
  23526. * @param predicate defines a predicate used to select candidate sprites
  23527. * @returns null if no hit or a PickingInfo array
  23528. */
  23529. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23530. /**
  23531. * Render all child sprites
  23532. */
  23533. render(): void;
  23534. private _customUpdate;
  23535. /**
  23536. * Release associated resources
  23537. */
  23538. dispose(): void;
  23539. /**
  23540. * Serializes the sprite manager to a JSON object
  23541. * @param serializeTexture defines if the texture must be serialized as well
  23542. * @returns the JSON object
  23543. */
  23544. serialize(serializeTexture?: boolean): any;
  23545. /**
  23546. * Parses a JSON object to create a new sprite manager.
  23547. * @param parsedManager The JSON object to parse
  23548. * @param scene The scene to create the sprite managerin
  23549. * @param rootUrl The root url to use to load external dependencies like texture
  23550. * @returns the new sprite manager
  23551. */
  23552. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23553. /**
  23554. * Creates a sprite manager from a snippet saved in a remote file
  23555. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23556. * @param url defines the url to load from
  23557. * @param scene defines the hosting scene
  23558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23559. * @returns a promise that will resolve to the new sprite manager
  23560. */
  23561. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23562. /**
  23563. * Creates a sprite manager from a snippet saved by the sprite editor
  23564. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23565. * @param scene defines the hosting scene
  23566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23567. * @returns a promise that will resolve to the new sprite manager
  23568. */
  23569. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23570. }
  23571. }
  23572. declare module BABYLON {
  23573. /**
  23574. * Class used to represent a sprite
  23575. * @see https://doc.babylonjs.com/babylon101/sprites
  23576. */
  23577. export class Sprite extends ThinSprite implements IAnimatable {
  23578. /** defines the name */
  23579. name: string;
  23580. /** Gets or sets the current world position */
  23581. position: Vector3;
  23582. /** Gets or sets the main color */
  23583. color: Color4;
  23584. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23585. disposeWhenFinishedAnimating: boolean;
  23586. /** Gets the list of attached animations */
  23587. animations: Nullable<Array<Animation>>;
  23588. /** Gets or sets a boolean indicating if the sprite can be picked */
  23589. isPickable: boolean;
  23590. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23591. useAlphaForPicking: boolean;
  23592. /**
  23593. * Gets or sets the associated action manager
  23594. */
  23595. actionManager: Nullable<ActionManager>;
  23596. /**
  23597. * An event triggered when the control has been disposed
  23598. */
  23599. onDisposeObservable: Observable<Sprite>;
  23600. private _manager;
  23601. private _onAnimationEnd;
  23602. /**
  23603. * Gets or sets the sprite size
  23604. */
  23605. get size(): number;
  23606. set size(value: number);
  23607. /**
  23608. * Gets or sets the unique id of the sprite
  23609. */
  23610. uniqueId: number;
  23611. /**
  23612. * Gets the manager of this sprite
  23613. */
  23614. get manager(): ISpriteManager;
  23615. /**
  23616. * Creates a new Sprite
  23617. * @param name defines the name
  23618. * @param manager defines the manager
  23619. */
  23620. constructor(
  23621. /** defines the name */
  23622. name: string, manager: ISpriteManager);
  23623. /**
  23624. * Returns the string "Sprite"
  23625. * @returns "Sprite"
  23626. */
  23627. getClassName(): string;
  23628. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23629. get fromIndex(): number;
  23630. set fromIndex(value: number);
  23631. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23632. get toIndex(): number;
  23633. set toIndex(value: number);
  23634. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23635. get loopAnimation(): boolean;
  23636. set loopAnimation(value: boolean);
  23637. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23638. get delay(): number;
  23639. set delay(value: number);
  23640. /**
  23641. * Starts an animation
  23642. * @param from defines the initial key
  23643. * @param to defines the end key
  23644. * @param loop defines if the animation must loop
  23645. * @param delay defines the start delay (in ms)
  23646. * @param onAnimationEnd defines a callback to call when animation ends
  23647. */
  23648. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23649. private _endAnimation;
  23650. /** Release associated resources */
  23651. dispose(): void;
  23652. /**
  23653. * Serializes the sprite to a JSON object
  23654. * @returns the JSON object
  23655. */
  23656. serialize(): any;
  23657. /**
  23658. * Parses a JSON object to create a new sprite
  23659. * @param parsedSprite The JSON object to parse
  23660. * @param manager defines the hosting manager
  23661. * @returns the new sprite
  23662. */
  23663. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23664. }
  23665. }
  23666. declare module BABYLON {
  23667. /**
  23668. * Information about the result of picking within a scene
  23669. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23670. */
  23671. export class PickingInfo {
  23672. /** @hidden */
  23673. _pickingUnavailable: boolean;
  23674. /**
  23675. * If the pick collided with an object
  23676. */
  23677. hit: boolean;
  23678. /**
  23679. * Distance away where the pick collided
  23680. */
  23681. distance: number;
  23682. /**
  23683. * The location of pick collision
  23684. */
  23685. pickedPoint: Nullable<Vector3>;
  23686. /**
  23687. * The mesh corresponding the the pick collision
  23688. */
  23689. pickedMesh: Nullable<AbstractMesh>;
  23690. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23691. bu: number;
  23692. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23693. bv: number;
  23694. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23695. faceId: number;
  23696. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23697. subMeshFaceId: number;
  23698. /** Id of the the submesh that was picked */
  23699. subMeshId: number;
  23700. /** If a sprite was picked, this will be the sprite the pick collided with */
  23701. pickedSprite: Nullable<Sprite>;
  23702. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23703. thinInstanceIndex: number;
  23704. /**
  23705. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23706. */
  23707. originMesh: Nullable<AbstractMesh>;
  23708. /**
  23709. * The ray that was used to perform the picking.
  23710. */
  23711. ray: Nullable<Ray>;
  23712. /**
  23713. * Gets the normal correspodning to the face the pick collided with
  23714. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23715. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23716. * @returns The normal correspodning to the face the pick collided with
  23717. */
  23718. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23719. /**
  23720. * Gets the texture coordinates of where the pick occured
  23721. * @returns the vector containing the coordnates of the texture
  23722. */
  23723. getTextureCoordinates(): Nullable<Vector2>;
  23724. }
  23725. }
  23726. declare module BABYLON {
  23727. /**
  23728. * Gather the list of pointer event types as constants.
  23729. */
  23730. export class PointerEventTypes {
  23731. /**
  23732. * 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.
  23733. */
  23734. static readonly POINTERDOWN: number;
  23735. /**
  23736. * The pointerup event is fired when a pointer is no longer active.
  23737. */
  23738. static readonly POINTERUP: number;
  23739. /**
  23740. * The pointermove event is fired when a pointer changes coordinates.
  23741. */
  23742. static readonly POINTERMOVE: number;
  23743. /**
  23744. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23745. */
  23746. static readonly POINTERWHEEL: number;
  23747. /**
  23748. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23749. */
  23750. static readonly POINTERPICK: number;
  23751. /**
  23752. * The pointertap event is fired when a the object has been touched and released without drag.
  23753. */
  23754. static readonly POINTERTAP: number;
  23755. /**
  23756. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23757. */
  23758. static readonly POINTERDOUBLETAP: number;
  23759. }
  23760. /**
  23761. * Base class of pointer info types.
  23762. */
  23763. export class PointerInfoBase {
  23764. /**
  23765. * Defines the type of event (PointerEventTypes)
  23766. */
  23767. type: number;
  23768. /**
  23769. * Defines the related dom event
  23770. */
  23771. event: PointerEvent | MouseWheelEvent;
  23772. /**
  23773. * Instantiates the base class of pointers info.
  23774. * @param type Defines the type of event (PointerEventTypes)
  23775. * @param event Defines the related dom event
  23776. */
  23777. constructor(
  23778. /**
  23779. * Defines the type of event (PointerEventTypes)
  23780. */
  23781. type: number,
  23782. /**
  23783. * Defines the related dom event
  23784. */
  23785. event: PointerEvent | MouseWheelEvent);
  23786. }
  23787. /**
  23788. * This class is used to store pointer related info for the onPrePointerObservable event.
  23789. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23790. */
  23791. export class PointerInfoPre extends PointerInfoBase {
  23792. /**
  23793. * Ray from a pointer if availible (eg. 6dof controller)
  23794. */
  23795. ray: Nullable<Ray>;
  23796. /**
  23797. * Defines the local position of the pointer on the canvas.
  23798. */
  23799. localPosition: Vector2;
  23800. /**
  23801. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23802. */
  23803. skipOnPointerObservable: boolean;
  23804. /**
  23805. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23806. * @param type Defines the type of event (PointerEventTypes)
  23807. * @param event Defines the related dom event
  23808. * @param localX Defines the local x coordinates of the pointer when the event occured
  23809. * @param localY Defines the local y coordinates of the pointer when the event occured
  23810. */
  23811. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23812. }
  23813. /**
  23814. * This type contains all the data related to a pointer event in Babylon.js.
  23815. * 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.
  23816. */
  23817. export class PointerInfo extends PointerInfoBase {
  23818. /**
  23819. * Defines the picking info associated to the info (if any)\
  23820. */
  23821. pickInfo: Nullable<PickingInfo>;
  23822. /**
  23823. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23824. * @param type Defines the type of event (PointerEventTypes)
  23825. * @param event Defines the related dom event
  23826. * @param pickInfo Defines the picking info associated to the info (if any)\
  23827. */
  23828. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23829. /**
  23830. * Defines the picking info associated to the info (if any)\
  23831. */
  23832. pickInfo: Nullable<PickingInfo>);
  23833. }
  23834. /**
  23835. * Data relating to a touch event on the screen.
  23836. */
  23837. export interface PointerTouch {
  23838. /**
  23839. * X coordinate of touch.
  23840. */
  23841. x: number;
  23842. /**
  23843. * Y coordinate of touch.
  23844. */
  23845. y: number;
  23846. /**
  23847. * Id of touch. Unique for each finger.
  23848. */
  23849. pointerId: number;
  23850. /**
  23851. * Event type passed from DOM.
  23852. */
  23853. type: any;
  23854. }
  23855. }
  23856. declare module BABYLON {
  23857. /**
  23858. * Manage the mouse inputs to control the movement of a free camera.
  23859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23860. */
  23861. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23862. /**
  23863. * Define if touch is enabled in the mouse input
  23864. */
  23865. touchEnabled: boolean;
  23866. /**
  23867. * Defines the camera the input is attached to.
  23868. */
  23869. camera: FreeCamera;
  23870. /**
  23871. * Defines the buttons associated with the input to handle camera move.
  23872. */
  23873. buttons: number[];
  23874. /**
  23875. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23876. */
  23877. angularSensibility: number;
  23878. private _pointerInput;
  23879. private _onMouseMove;
  23880. private _observer;
  23881. private previousPosition;
  23882. /**
  23883. * Observable for when a pointer move event occurs containing the move offset
  23884. */
  23885. onPointerMovedObservable: Observable<{
  23886. offsetX: number;
  23887. offsetY: number;
  23888. }>;
  23889. /**
  23890. * @hidden
  23891. * If the camera should be rotated automatically based on pointer movement
  23892. */
  23893. _allowCameraRotation: boolean;
  23894. /**
  23895. * Manage the mouse inputs to control the movement of a free camera.
  23896. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23897. * @param touchEnabled Defines if touch is enabled or not
  23898. */
  23899. constructor(
  23900. /**
  23901. * Define if touch is enabled in the mouse input
  23902. */
  23903. touchEnabled?: boolean);
  23904. /**
  23905. * Attach the input controls to a specific dom element to get the input from.
  23906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23907. */
  23908. attachControl(noPreventDefault?: boolean): void;
  23909. /**
  23910. * Called on JS contextmenu event.
  23911. * Override this method to provide functionality.
  23912. */
  23913. protected onContextMenu(evt: PointerEvent): void;
  23914. /**
  23915. * Detach the current controls from the specified dom element.
  23916. */
  23917. detachControl(): void;
  23918. /**
  23919. * Gets the class name of the current intput.
  23920. * @returns the class name
  23921. */
  23922. getClassName(): string;
  23923. /**
  23924. * Get the friendly name associated with the input class.
  23925. * @returns the input friendly name
  23926. */
  23927. getSimpleName(): string;
  23928. }
  23929. }
  23930. declare module BABYLON {
  23931. /**
  23932. * Base class for mouse wheel input..
  23933. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23934. * for example usage.
  23935. */
  23936. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23937. /**
  23938. * Defines the camera the input is attached to.
  23939. */
  23940. abstract camera: Camera;
  23941. /**
  23942. * How fast is the camera moves in relation to X axis mouseWheel events.
  23943. * Use negative value to reverse direction.
  23944. */
  23945. wheelPrecisionX: number;
  23946. /**
  23947. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23948. * Use negative value to reverse direction.
  23949. */
  23950. wheelPrecisionY: number;
  23951. /**
  23952. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23953. * Use negative value to reverse direction.
  23954. */
  23955. wheelPrecisionZ: number;
  23956. /**
  23957. * Observable for when a mouse wheel move event occurs.
  23958. */
  23959. onChangedObservable: Observable<{
  23960. wheelDeltaX: number;
  23961. wheelDeltaY: number;
  23962. wheelDeltaZ: number;
  23963. }>;
  23964. private _wheel;
  23965. private _observer;
  23966. /**
  23967. * Attach the input controls to a specific dom element to get the input from.
  23968. * @param noPreventDefault Defines whether event caught by the controls
  23969. * should call preventdefault().
  23970. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23971. */
  23972. attachControl(noPreventDefault?: boolean): void;
  23973. /**
  23974. * Detach the current controls from the specified dom element.
  23975. */
  23976. detachControl(): void;
  23977. /**
  23978. * Called for each rendered frame.
  23979. */
  23980. checkInputs(): void;
  23981. /**
  23982. * Gets the class name of the current intput.
  23983. * @returns the class name
  23984. */
  23985. getClassName(): string;
  23986. /**
  23987. * Get the friendly name associated with the input class.
  23988. * @returns the input friendly name
  23989. */
  23990. getSimpleName(): string;
  23991. /**
  23992. * Incremental value of multiple mouse wheel movements of the X axis.
  23993. * Should be zero-ed when read.
  23994. */
  23995. protected _wheelDeltaX: number;
  23996. /**
  23997. * Incremental value of multiple mouse wheel movements of the Y axis.
  23998. * Should be zero-ed when read.
  23999. */
  24000. protected _wheelDeltaY: number;
  24001. /**
  24002. * Incremental value of multiple mouse wheel movements of the Z axis.
  24003. * Should be zero-ed when read.
  24004. */
  24005. protected _wheelDeltaZ: number;
  24006. /**
  24007. * Firefox uses a different scheme to report scroll distances to other
  24008. * browsers. Rather than use complicated methods to calculate the exact
  24009. * multiple we need to apply, let's just cheat and use a constant.
  24010. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24011. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24012. */
  24013. private readonly _ffMultiplier;
  24014. /**
  24015. * Different event attributes for wheel data fall into a few set ranges.
  24016. * Some relevant but dated date here:
  24017. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24018. */
  24019. private readonly _normalize;
  24020. }
  24021. }
  24022. declare module BABYLON {
  24023. /**
  24024. * Manage the mouse wheel inputs to control a free camera.
  24025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24026. */
  24027. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24028. /**
  24029. * Defines the camera the input is attached to.
  24030. */
  24031. camera: FreeCamera;
  24032. /**
  24033. * Gets the class name of the current input.
  24034. * @returns the class name
  24035. */
  24036. getClassName(): string;
  24037. /**
  24038. * Set which movement axis (relative to camera's orientation) the mouse
  24039. * wheel's X axis controls.
  24040. * @param axis The axis to be moved. Set null to clear.
  24041. */
  24042. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24043. /**
  24044. * Get the configured movement axis (relative to camera's orientation) the
  24045. * mouse wheel's X axis controls.
  24046. * @returns The configured axis or null if none.
  24047. */
  24048. get wheelXMoveRelative(): Nullable<Coordinate>;
  24049. /**
  24050. * Set which movement axis (relative to camera's orientation) the mouse
  24051. * wheel's Y axis controls.
  24052. * @param axis The axis to be moved. Set null to clear.
  24053. */
  24054. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24055. /**
  24056. * Get the configured movement axis (relative to camera's orientation) the
  24057. * mouse wheel's Y axis controls.
  24058. * @returns The configured axis or null if none.
  24059. */
  24060. get wheelYMoveRelative(): Nullable<Coordinate>;
  24061. /**
  24062. * Set which movement axis (relative to camera's orientation) the mouse
  24063. * wheel's Z axis controls.
  24064. * @param axis The axis to be moved. Set null to clear.
  24065. */
  24066. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24067. /**
  24068. * Get the configured movement axis (relative to camera's orientation) the
  24069. * mouse wheel's Z axis controls.
  24070. * @returns The configured axis or null if none.
  24071. */
  24072. get wheelZMoveRelative(): Nullable<Coordinate>;
  24073. /**
  24074. * Set which rotation axis (relative to camera's orientation) the mouse
  24075. * wheel's X axis controls.
  24076. * @param axis The axis to be moved. Set null to clear.
  24077. */
  24078. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24079. /**
  24080. * Get the configured rotation axis (relative to camera's orientation) the
  24081. * mouse wheel's X axis controls.
  24082. * @returns The configured axis or null if none.
  24083. */
  24084. get wheelXRotateRelative(): Nullable<Coordinate>;
  24085. /**
  24086. * Set which rotation axis (relative to camera's orientation) the mouse
  24087. * wheel's Y axis controls.
  24088. * @param axis The axis to be moved. Set null to clear.
  24089. */
  24090. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24091. /**
  24092. * Get the configured rotation axis (relative to camera's orientation) the
  24093. * mouse wheel's Y axis controls.
  24094. * @returns The configured axis or null if none.
  24095. */
  24096. get wheelYRotateRelative(): Nullable<Coordinate>;
  24097. /**
  24098. * Set which rotation axis (relative to camera's orientation) the mouse
  24099. * wheel's Z axis controls.
  24100. * @param axis The axis to be moved. Set null to clear.
  24101. */
  24102. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24103. /**
  24104. * Get the configured rotation axis (relative to camera's orientation) the
  24105. * mouse wheel's Z axis controls.
  24106. * @returns The configured axis or null if none.
  24107. */
  24108. get wheelZRotateRelative(): Nullable<Coordinate>;
  24109. /**
  24110. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24111. * controls.
  24112. * @param axis The axis to be moved. Set null to clear.
  24113. */
  24114. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24115. /**
  24116. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24117. * X axis controls.
  24118. * @returns The configured axis or null if none.
  24119. */
  24120. get wheelXMoveScene(): Nullable<Coordinate>;
  24121. /**
  24122. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24123. * controls.
  24124. * @param axis The axis to be moved. Set null to clear.
  24125. */
  24126. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24127. /**
  24128. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24129. * Y axis controls.
  24130. * @returns The configured axis or null if none.
  24131. */
  24132. get wheelYMoveScene(): Nullable<Coordinate>;
  24133. /**
  24134. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24135. * controls.
  24136. * @param axis The axis to be moved. Set null to clear.
  24137. */
  24138. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24139. /**
  24140. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24141. * Z axis controls.
  24142. * @returns The configured axis or null if none.
  24143. */
  24144. get wheelZMoveScene(): Nullable<Coordinate>;
  24145. /**
  24146. * Called for each rendered frame.
  24147. */
  24148. checkInputs(): void;
  24149. private _moveRelative;
  24150. private _rotateRelative;
  24151. private _moveScene;
  24152. /**
  24153. * These are set to the desired default behaviour.
  24154. */
  24155. private _wheelXAction;
  24156. private _wheelXActionCoordinate;
  24157. private _wheelYAction;
  24158. private _wheelYActionCoordinate;
  24159. private _wheelZAction;
  24160. private _wheelZActionCoordinate;
  24161. /**
  24162. * Update the camera according to any configured properties for the 3
  24163. * mouse-wheel axis.
  24164. */
  24165. private _updateCamera;
  24166. }
  24167. }
  24168. declare module BABYLON {
  24169. /**
  24170. * Manage the touch inputs to control the movement of a free camera.
  24171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24172. */
  24173. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24174. /**
  24175. * Define if mouse events can be treated as touch events
  24176. */
  24177. allowMouse: boolean;
  24178. /**
  24179. * Defines the camera the input is attached to.
  24180. */
  24181. camera: FreeCamera;
  24182. /**
  24183. * Defines the touch sensibility for rotation.
  24184. * The higher the faster.
  24185. */
  24186. touchAngularSensibility: number;
  24187. /**
  24188. * Defines the touch sensibility for move.
  24189. * The higher the faster.
  24190. */
  24191. touchMoveSensibility: number;
  24192. private _offsetX;
  24193. private _offsetY;
  24194. private _pointerPressed;
  24195. private _pointerInput?;
  24196. private _observer;
  24197. private _onLostFocus;
  24198. /**
  24199. * Manage the touch inputs to control the movement of a free camera.
  24200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24201. * @param allowMouse Defines if mouse events can be treated as touch events
  24202. */
  24203. constructor(
  24204. /**
  24205. * Define if mouse events can be treated as touch events
  24206. */
  24207. allowMouse?: boolean);
  24208. /**
  24209. * Attach the input controls to a specific dom element to get the input from.
  24210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24211. */
  24212. attachControl(noPreventDefault?: boolean): void;
  24213. /**
  24214. * Detach the current controls from the specified dom element.
  24215. */
  24216. detachControl(): void;
  24217. /**
  24218. * Update the current camera state depending on the inputs that have been used this frame.
  24219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24220. */
  24221. checkInputs(): void;
  24222. /**
  24223. * Gets the class name of the current intput.
  24224. * @returns the class name
  24225. */
  24226. getClassName(): string;
  24227. /**
  24228. * Get the friendly name associated with the input class.
  24229. * @returns the input friendly name
  24230. */
  24231. getSimpleName(): string;
  24232. }
  24233. }
  24234. declare module BABYLON {
  24235. /**
  24236. * Default Inputs manager for the FreeCamera.
  24237. * It groups all the default supported inputs for ease of use.
  24238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24239. */
  24240. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24241. /**
  24242. * @hidden
  24243. */
  24244. _mouseInput: Nullable<FreeCameraMouseInput>;
  24245. /**
  24246. * @hidden
  24247. */
  24248. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24249. /**
  24250. * Instantiates a new FreeCameraInputsManager.
  24251. * @param camera Defines the camera the inputs belong to
  24252. */
  24253. constructor(camera: FreeCamera);
  24254. /**
  24255. * Add keyboard input support to the input manager.
  24256. * @returns the current input manager
  24257. */
  24258. addKeyboard(): FreeCameraInputsManager;
  24259. /**
  24260. * Add mouse input support to the input manager.
  24261. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24262. * @returns the current input manager
  24263. */
  24264. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24265. /**
  24266. * Removes the mouse input support from the manager
  24267. * @returns the current input manager
  24268. */
  24269. removeMouse(): FreeCameraInputsManager;
  24270. /**
  24271. * Add mouse wheel input support to the input manager.
  24272. * @returns the current input manager
  24273. */
  24274. addMouseWheel(): FreeCameraInputsManager;
  24275. /**
  24276. * Removes the mouse wheel input support from the manager
  24277. * @returns the current input manager
  24278. */
  24279. removeMouseWheel(): FreeCameraInputsManager;
  24280. /**
  24281. * Add touch input support to the input manager.
  24282. * @returns the current input manager
  24283. */
  24284. addTouch(): FreeCameraInputsManager;
  24285. /**
  24286. * Remove all attached input methods from a camera
  24287. */
  24288. clear(): void;
  24289. }
  24290. }
  24291. declare module BABYLON {
  24292. /**
  24293. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24294. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24295. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24296. */
  24297. export class FreeCamera extends TargetCamera {
  24298. /**
  24299. * Define the collision ellipsoid of the camera.
  24300. * This is helpful to simulate a camera body like the player body around the camera
  24301. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24302. */
  24303. ellipsoid: Vector3;
  24304. /**
  24305. * Define an offset for the position of the ellipsoid around the camera.
  24306. * This can be helpful to determine the center of the body near the gravity center of the body
  24307. * instead of its head.
  24308. */
  24309. ellipsoidOffset: Vector3;
  24310. /**
  24311. * Enable or disable collisions of the camera with the rest of the scene objects.
  24312. */
  24313. checkCollisions: boolean;
  24314. /**
  24315. * Enable or disable gravity on the camera.
  24316. */
  24317. applyGravity: boolean;
  24318. /**
  24319. * Define the input manager associated to the camera.
  24320. */
  24321. inputs: FreeCameraInputsManager;
  24322. /**
  24323. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24324. * Higher values reduce sensitivity.
  24325. */
  24326. get angularSensibility(): number;
  24327. /**
  24328. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24329. * Higher values reduce sensitivity.
  24330. */
  24331. set angularSensibility(value: number);
  24332. /**
  24333. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24334. */
  24335. get keysUp(): number[];
  24336. set keysUp(value: number[]);
  24337. /**
  24338. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24339. */
  24340. get keysUpward(): number[];
  24341. set keysUpward(value: number[]);
  24342. /**
  24343. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24344. */
  24345. get keysDown(): number[];
  24346. set keysDown(value: number[]);
  24347. /**
  24348. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24349. */
  24350. get keysDownward(): number[];
  24351. set keysDownward(value: number[]);
  24352. /**
  24353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24354. */
  24355. get keysLeft(): number[];
  24356. set keysLeft(value: number[]);
  24357. /**
  24358. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24359. */
  24360. get keysRight(): number[];
  24361. set keysRight(value: number[]);
  24362. /**
  24363. * Event raised when the camera collide with a mesh in the scene.
  24364. */
  24365. onCollide: (collidedMesh: AbstractMesh) => void;
  24366. private _collider;
  24367. private _needMoveForGravity;
  24368. private _oldPosition;
  24369. private _diffPosition;
  24370. private _newPosition;
  24371. /** @hidden */
  24372. _localDirection: Vector3;
  24373. /** @hidden */
  24374. _transformedDirection: Vector3;
  24375. /**
  24376. * Instantiates a Free Camera.
  24377. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24378. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24379. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24380. * @param name Define the name of the camera in the scene
  24381. * @param position Define the start position of the camera in the scene
  24382. * @param scene Define the scene the camera belongs to
  24383. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24384. */
  24385. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24386. /**
  24387. * Attach the input controls to a specific dom element to get the input from.
  24388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24389. */
  24390. attachControl(noPreventDefault?: boolean): void;
  24391. /**
  24392. * Attach the input controls to a specific dom element to get the input from.
  24393. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24395. * BACK COMPAT SIGNATURE ONLY.
  24396. */
  24397. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24398. /**
  24399. * Detach the current controls from the specified dom element.
  24400. */
  24401. detachControl(): void;
  24402. /**
  24403. * Detach the current controls from the specified dom element.
  24404. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24405. */
  24406. detachControl(ignored: any): void;
  24407. private _collisionMask;
  24408. /**
  24409. * Define a collision mask to limit the list of object the camera can collide with
  24410. */
  24411. get collisionMask(): number;
  24412. set collisionMask(mask: number);
  24413. /** @hidden */
  24414. _collideWithWorld(displacement: Vector3): void;
  24415. private _onCollisionPositionChange;
  24416. /** @hidden */
  24417. _checkInputs(): void;
  24418. /** @hidden */
  24419. _decideIfNeedsToMove(): boolean;
  24420. /** @hidden */
  24421. _updatePosition(): void;
  24422. /**
  24423. * Destroy the camera and release the current resources hold by it.
  24424. */
  24425. dispose(): void;
  24426. /**
  24427. * Gets the current object class name.
  24428. * @return the class name
  24429. */
  24430. getClassName(): string;
  24431. }
  24432. }
  24433. declare module BABYLON {
  24434. /**
  24435. * Represents a gamepad control stick position
  24436. */
  24437. export class StickValues {
  24438. /**
  24439. * The x component of the control stick
  24440. */
  24441. x: number;
  24442. /**
  24443. * The y component of the control stick
  24444. */
  24445. y: number;
  24446. /**
  24447. * Initializes the gamepad x and y control stick values
  24448. * @param x The x component of the gamepad control stick value
  24449. * @param y The y component of the gamepad control stick value
  24450. */
  24451. constructor(
  24452. /**
  24453. * The x component of the control stick
  24454. */
  24455. x: number,
  24456. /**
  24457. * The y component of the control stick
  24458. */
  24459. y: number);
  24460. }
  24461. /**
  24462. * An interface which manages callbacks for gamepad button changes
  24463. */
  24464. export interface GamepadButtonChanges {
  24465. /**
  24466. * Called when a gamepad has been changed
  24467. */
  24468. changed: boolean;
  24469. /**
  24470. * Called when a gamepad press event has been triggered
  24471. */
  24472. pressChanged: boolean;
  24473. /**
  24474. * Called when a touch event has been triggered
  24475. */
  24476. touchChanged: boolean;
  24477. /**
  24478. * Called when a value has changed
  24479. */
  24480. valueChanged: boolean;
  24481. }
  24482. /**
  24483. * Represents a gamepad
  24484. */
  24485. export class Gamepad {
  24486. /**
  24487. * The id of the gamepad
  24488. */
  24489. id: string;
  24490. /**
  24491. * The index of the gamepad
  24492. */
  24493. index: number;
  24494. /**
  24495. * The browser gamepad
  24496. */
  24497. browserGamepad: any;
  24498. /**
  24499. * Specifies what type of gamepad this represents
  24500. */
  24501. type: number;
  24502. private _leftStick;
  24503. private _rightStick;
  24504. /** @hidden */
  24505. _isConnected: boolean;
  24506. private _leftStickAxisX;
  24507. private _leftStickAxisY;
  24508. private _rightStickAxisX;
  24509. private _rightStickAxisY;
  24510. /**
  24511. * Triggered when the left control stick has been changed
  24512. */
  24513. private _onleftstickchanged;
  24514. /**
  24515. * Triggered when the right control stick has been changed
  24516. */
  24517. private _onrightstickchanged;
  24518. /**
  24519. * Represents a gamepad controller
  24520. */
  24521. static GAMEPAD: number;
  24522. /**
  24523. * Represents a generic controller
  24524. */
  24525. static GENERIC: number;
  24526. /**
  24527. * Represents an XBox controller
  24528. */
  24529. static XBOX: number;
  24530. /**
  24531. * Represents a pose-enabled controller
  24532. */
  24533. static POSE_ENABLED: number;
  24534. /**
  24535. * Represents an Dual Shock controller
  24536. */
  24537. static DUALSHOCK: number;
  24538. /**
  24539. * Specifies whether the left control stick should be Y-inverted
  24540. */
  24541. protected _invertLeftStickY: boolean;
  24542. /**
  24543. * Specifies if the gamepad has been connected
  24544. */
  24545. get isConnected(): boolean;
  24546. /**
  24547. * Initializes the gamepad
  24548. * @param id The id of the gamepad
  24549. * @param index The index of the gamepad
  24550. * @param browserGamepad The browser gamepad
  24551. * @param leftStickX The x component of the left joystick
  24552. * @param leftStickY The y component of the left joystick
  24553. * @param rightStickX The x component of the right joystick
  24554. * @param rightStickY The y component of the right joystick
  24555. */
  24556. constructor(
  24557. /**
  24558. * The id of the gamepad
  24559. */
  24560. id: string,
  24561. /**
  24562. * The index of the gamepad
  24563. */
  24564. index: number,
  24565. /**
  24566. * The browser gamepad
  24567. */
  24568. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24569. /**
  24570. * Callback triggered when the left joystick has changed
  24571. * @param callback
  24572. */
  24573. onleftstickchanged(callback: (values: StickValues) => void): void;
  24574. /**
  24575. * Callback triggered when the right joystick has changed
  24576. * @param callback
  24577. */
  24578. onrightstickchanged(callback: (values: StickValues) => void): void;
  24579. /**
  24580. * Gets the left joystick
  24581. */
  24582. get leftStick(): StickValues;
  24583. /**
  24584. * Sets the left joystick values
  24585. */
  24586. set leftStick(newValues: StickValues);
  24587. /**
  24588. * Gets the right joystick
  24589. */
  24590. get rightStick(): StickValues;
  24591. /**
  24592. * Sets the right joystick value
  24593. */
  24594. set rightStick(newValues: StickValues);
  24595. /**
  24596. * Updates the gamepad joystick positions
  24597. */
  24598. update(): void;
  24599. /**
  24600. * Disposes the gamepad
  24601. */
  24602. dispose(): void;
  24603. }
  24604. /**
  24605. * Represents a generic gamepad
  24606. */
  24607. export class GenericPad extends Gamepad {
  24608. private _buttons;
  24609. private _onbuttondown;
  24610. private _onbuttonup;
  24611. /**
  24612. * Observable triggered when a button has been pressed
  24613. */
  24614. onButtonDownObservable: Observable<number>;
  24615. /**
  24616. * Observable triggered when a button has been released
  24617. */
  24618. onButtonUpObservable: Observable<number>;
  24619. /**
  24620. * Callback triggered when a button has been pressed
  24621. * @param callback Called when a button has been pressed
  24622. */
  24623. onbuttondown(callback: (buttonPressed: number) => void): void;
  24624. /**
  24625. * Callback triggered when a button has been released
  24626. * @param callback Called when a button has been released
  24627. */
  24628. onbuttonup(callback: (buttonReleased: number) => void): void;
  24629. /**
  24630. * Initializes the generic gamepad
  24631. * @param id The id of the generic gamepad
  24632. * @param index The index of the generic gamepad
  24633. * @param browserGamepad The browser gamepad
  24634. */
  24635. constructor(id: string, index: number, browserGamepad: any);
  24636. private _setButtonValue;
  24637. /**
  24638. * Updates the generic gamepad
  24639. */
  24640. update(): void;
  24641. /**
  24642. * Disposes the generic gamepad
  24643. */
  24644. dispose(): void;
  24645. }
  24646. }
  24647. declare module BABYLON {
  24648. /**
  24649. * Defines a runtime animation
  24650. */
  24651. export class RuntimeAnimation {
  24652. private _events;
  24653. /**
  24654. * The current frame of the runtime animation
  24655. */
  24656. private _currentFrame;
  24657. /**
  24658. * The animation used by the runtime animation
  24659. */
  24660. private _animation;
  24661. /**
  24662. * The target of the runtime animation
  24663. */
  24664. private _target;
  24665. /**
  24666. * The initiating animatable
  24667. */
  24668. private _host;
  24669. /**
  24670. * The original value of the runtime animation
  24671. */
  24672. private _originalValue;
  24673. /**
  24674. * The original blend value of the runtime animation
  24675. */
  24676. private _originalBlendValue;
  24677. /**
  24678. * The offsets cache of the runtime animation
  24679. */
  24680. private _offsetsCache;
  24681. /**
  24682. * The high limits cache of the runtime animation
  24683. */
  24684. private _highLimitsCache;
  24685. /**
  24686. * Specifies if the runtime animation has been stopped
  24687. */
  24688. private _stopped;
  24689. /**
  24690. * The blending factor of the runtime animation
  24691. */
  24692. private _blendingFactor;
  24693. /**
  24694. * The BabylonJS scene
  24695. */
  24696. private _scene;
  24697. /**
  24698. * The current value of the runtime animation
  24699. */
  24700. private _currentValue;
  24701. /** @hidden */
  24702. _animationState: _IAnimationState;
  24703. /**
  24704. * The active target of the runtime animation
  24705. */
  24706. private _activeTargets;
  24707. private _currentActiveTarget;
  24708. private _directTarget;
  24709. /**
  24710. * The target path of the runtime animation
  24711. */
  24712. private _targetPath;
  24713. /**
  24714. * The weight of the runtime animation
  24715. */
  24716. private _weight;
  24717. /**
  24718. * The ratio offset of the runtime animation
  24719. */
  24720. private _ratioOffset;
  24721. /**
  24722. * The previous delay of the runtime animation
  24723. */
  24724. private _previousDelay;
  24725. /**
  24726. * The previous ratio of the runtime animation
  24727. */
  24728. private _previousRatio;
  24729. private _enableBlending;
  24730. private _keys;
  24731. private _minFrame;
  24732. private _maxFrame;
  24733. private _minValue;
  24734. private _maxValue;
  24735. private _targetIsArray;
  24736. /**
  24737. * Gets the current frame of the runtime animation
  24738. */
  24739. get currentFrame(): number;
  24740. /**
  24741. * Gets the weight of the runtime animation
  24742. */
  24743. get weight(): number;
  24744. /**
  24745. * Gets the current value of the runtime animation
  24746. */
  24747. get currentValue(): any;
  24748. /**
  24749. * Gets the target path of the runtime animation
  24750. */
  24751. get targetPath(): string;
  24752. /**
  24753. * Gets the actual target of the runtime animation
  24754. */
  24755. get target(): any;
  24756. /**
  24757. * Gets the additive state of the runtime animation
  24758. */
  24759. get isAdditive(): boolean;
  24760. /** @hidden */
  24761. _onLoop: () => void;
  24762. /**
  24763. * Create a new RuntimeAnimation object
  24764. * @param target defines the target of the animation
  24765. * @param animation defines the source animation object
  24766. * @param scene defines the hosting scene
  24767. * @param host defines the initiating Animatable
  24768. */
  24769. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24770. private _preparePath;
  24771. /**
  24772. * Gets the animation from the runtime animation
  24773. */
  24774. get animation(): Animation;
  24775. /**
  24776. * Resets the runtime animation to the beginning
  24777. * @param restoreOriginal defines whether to restore the target property to the original value
  24778. */
  24779. reset(restoreOriginal?: boolean): void;
  24780. /**
  24781. * Specifies if the runtime animation is stopped
  24782. * @returns Boolean specifying if the runtime animation is stopped
  24783. */
  24784. isStopped(): boolean;
  24785. /**
  24786. * Disposes of the runtime animation
  24787. */
  24788. dispose(): void;
  24789. /**
  24790. * Apply the interpolated value to the target
  24791. * @param currentValue defines the value computed by the animation
  24792. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24793. */
  24794. setValue(currentValue: any, weight: number): void;
  24795. private _getOriginalValues;
  24796. private _setValue;
  24797. /**
  24798. * Gets the loop pmode of the runtime animation
  24799. * @returns Loop Mode
  24800. */
  24801. private _getCorrectLoopMode;
  24802. /**
  24803. * Move the current animation to a given frame
  24804. * @param frame defines the frame to move to
  24805. */
  24806. goToFrame(frame: number): void;
  24807. /**
  24808. * @hidden Internal use only
  24809. */
  24810. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24811. /**
  24812. * Execute the current animation
  24813. * @param delay defines the delay to add to the current frame
  24814. * @param from defines the lower bound of the animation range
  24815. * @param to defines the upper bound of the animation range
  24816. * @param loop defines if the current animation must loop
  24817. * @param speedRatio defines the current speed ratio
  24818. * @param weight defines the weight of the animation (default is -1 so no weight)
  24819. * @param onLoop optional callback called when animation loops
  24820. * @returns a boolean indicating if the animation is running
  24821. */
  24822. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24823. }
  24824. }
  24825. declare module BABYLON {
  24826. /**
  24827. * Class used to store an actual running animation
  24828. */
  24829. export class Animatable {
  24830. /** defines the target object */
  24831. target: any;
  24832. /** defines the starting frame number (default is 0) */
  24833. fromFrame: number;
  24834. /** defines the ending frame number (default is 100) */
  24835. toFrame: number;
  24836. /** defines if the animation must loop (default is false) */
  24837. loopAnimation: boolean;
  24838. /** defines a callback to call when animation ends if it is not looping */
  24839. onAnimationEnd?: (() => void) | null | undefined;
  24840. /** defines a callback to call when animation loops */
  24841. onAnimationLoop?: (() => void) | null | undefined;
  24842. /** defines whether the animation should be evaluated additively */
  24843. isAdditive: boolean;
  24844. private _localDelayOffset;
  24845. private _pausedDelay;
  24846. private _runtimeAnimations;
  24847. private _paused;
  24848. private _scene;
  24849. private _speedRatio;
  24850. private _weight;
  24851. private _syncRoot;
  24852. /**
  24853. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24854. * This will only apply for non looping animation (default is true)
  24855. */
  24856. disposeOnEnd: boolean;
  24857. /**
  24858. * Gets a boolean indicating if the animation has started
  24859. */
  24860. animationStarted: boolean;
  24861. /**
  24862. * Observer raised when the animation ends
  24863. */
  24864. onAnimationEndObservable: Observable<Animatable>;
  24865. /**
  24866. * Observer raised when the animation loops
  24867. */
  24868. onAnimationLoopObservable: Observable<Animatable>;
  24869. /**
  24870. * Gets the root Animatable used to synchronize and normalize animations
  24871. */
  24872. get syncRoot(): Nullable<Animatable>;
  24873. /**
  24874. * Gets the current frame of the first RuntimeAnimation
  24875. * Used to synchronize Animatables
  24876. */
  24877. get masterFrame(): number;
  24878. /**
  24879. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24880. */
  24881. get weight(): number;
  24882. set weight(value: number);
  24883. /**
  24884. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24885. */
  24886. get speedRatio(): number;
  24887. set speedRatio(value: number);
  24888. /**
  24889. * Creates a new Animatable
  24890. * @param scene defines the hosting scene
  24891. * @param target defines the target object
  24892. * @param fromFrame defines the starting frame number (default is 0)
  24893. * @param toFrame defines the ending frame number (default is 100)
  24894. * @param loopAnimation defines if the animation must loop (default is false)
  24895. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24896. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24897. * @param animations defines a group of animation to add to the new Animatable
  24898. * @param onAnimationLoop defines a callback to call when animation loops
  24899. * @param isAdditive defines whether the animation should be evaluated additively
  24900. */
  24901. constructor(scene: Scene,
  24902. /** defines the target object */
  24903. target: any,
  24904. /** defines the starting frame number (default is 0) */
  24905. fromFrame?: number,
  24906. /** defines the ending frame number (default is 100) */
  24907. toFrame?: number,
  24908. /** defines if the animation must loop (default is false) */
  24909. loopAnimation?: boolean, speedRatio?: number,
  24910. /** defines a callback to call when animation ends if it is not looping */
  24911. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24912. /** defines a callback to call when animation loops */
  24913. onAnimationLoop?: (() => void) | null | undefined,
  24914. /** defines whether the animation should be evaluated additively */
  24915. isAdditive?: boolean);
  24916. /**
  24917. * Synchronize and normalize current Animatable with a source Animatable
  24918. * This is useful when using animation weights and when animations are not of the same length
  24919. * @param root defines the root Animatable to synchronize with
  24920. * @returns the current Animatable
  24921. */
  24922. syncWith(root: Animatable): Animatable;
  24923. /**
  24924. * Gets the list of runtime animations
  24925. * @returns an array of RuntimeAnimation
  24926. */
  24927. getAnimations(): RuntimeAnimation[];
  24928. /**
  24929. * Adds more animations to the current animatable
  24930. * @param target defines the target of the animations
  24931. * @param animations defines the new animations to add
  24932. */
  24933. appendAnimations(target: any, animations: Animation[]): void;
  24934. /**
  24935. * Gets the source animation for a specific property
  24936. * @param property defines the propertyu to look for
  24937. * @returns null or the source animation for the given property
  24938. */
  24939. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24940. /**
  24941. * Gets the runtime animation for a specific property
  24942. * @param property defines the propertyu to look for
  24943. * @returns null or the runtime animation for the given property
  24944. */
  24945. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24946. /**
  24947. * Resets the animatable to its original state
  24948. */
  24949. reset(): void;
  24950. /**
  24951. * Allows the animatable to blend with current running animations
  24952. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24953. * @param blendingSpeed defines the blending speed to use
  24954. */
  24955. enableBlending(blendingSpeed: number): void;
  24956. /**
  24957. * Disable animation blending
  24958. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24959. */
  24960. disableBlending(): void;
  24961. /**
  24962. * Jump directly to a given frame
  24963. * @param frame defines the frame to jump to
  24964. */
  24965. goToFrame(frame: number): void;
  24966. /**
  24967. * Pause the animation
  24968. */
  24969. pause(): void;
  24970. /**
  24971. * Restart the animation
  24972. */
  24973. restart(): void;
  24974. private _raiseOnAnimationEnd;
  24975. /**
  24976. * Stop and delete the current animation
  24977. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24978. * @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)
  24979. */
  24980. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24981. /**
  24982. * Wait asynchronously for the animation to end
  24983. * @returns a promise which will be fullfilled when the animation ends
  24984. */
  24985. waitAsync(): Promise<Animatable>;
  24986. /** @hidden */
  24987. _animate(delay: number): boolean;
  24988. }
  24989. interface Scene {
  24990. /** @hidden */
  24991. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24992. /** @hidden */
  24993. _processLateAnimationBindingsForMatrices(holder: {
  24994. totalWeight: number;
  24995. totalAdditiveWeight: number;
  24996. animations: RuntimeAnimation[];
  24997. additiveAnimations: RuntimeAnimation[];
  24998. originalValue: Matrix;
  24999. }): any;
  25000. /** @hidden */
  25001. _processLateAnimationBindingsForQuaternions(holder: {
  25002. totalWeight: number;
  25003. totalAdditiveWeight: number;
  25004. animations: RuntimeAnimation[];
  25005. additiveAnimations: RuntimeAnimation[];
  25006. originalValue: Quaternion;
  25007. }, refQuaternion: Quaternion): Quaternion;
  25008. /** @hidden */
  25009. _processLateAnimationBindings(): void;
  25010. /**
  25011. * Will start the animation sequence of a given target
  25012. * @param target defines the target
  25013. * @param from defines from which frame should animation start
  25014. * @param to defines until which frame should animation run.
  25015. * @param weight defines the weight to apply to the animation (1.0 by default)
  25016. * @param loop defines if the animation loops
  25017. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25018. * @param onAnimationEnd defines the function to be executed when the animation ends
  25019. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25020. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25021. * @param onAnimationLoop defines the callback to call when an animation loops
  25022. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25023. * @returns the animatable object created for this animation
  25024. */
  25025. 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;
  25026. /**
  25027. * Will start the animation sequence of a given target
  25028. * @param target defines the target
  25029. * @param from defines from which frame should animation start
  25030. * @param to defines until which frame should animation run.
  25031. * @param loop defines if the animation loops
  25032. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25033. * @param onAnimationEnd defines the function to be executed when the animation ends
  25034. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25035. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25036. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25037. * @param onAnimationLoop defines the callback to call when an animation loops
  25038. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25039. * @returns the animatable object created for this animation
  25040. */
  25041. 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;
  25042. /**
  25043. * Will start the animation sequence of a given target and its hierarchy
  25044. * @param target defines the target
  25045. * @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.
  25046. * @param from defines from which frame should animation start
  25047. * @param to defines until which frame should animation run.
  25048. * @param loop defines if the animation loops
  25049. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25050. * @param onAnimationEnd defines the function to be executed when the animation ends
  25051. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25052. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25053. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25054. * @param onAnimationLoop defines the callback to call when an animation loops
  25055. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25056. * @returns the list of created animatables
  25057. */
  25058. 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[];
  25059. /**
  25060. * Begin a new animation on a given node
  25061. * @param target defines the target where the animation will take place
  25062. * @param animations defines the list of animations to start
  25063. * @param from defines the initial value
  25064. * @param to defines the final value
  25065. * @param loop defines if you want animation to loop (off by default)
  25066. * @param speedRatio defines the speed ratio to apply to all animations
  25067. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25068. * @param onAnimationLoop defines the callback to call when an animation loops
  25069. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25070. * @returns the list of created animatables
  25071. */
  25072. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25073. /**
  25074. * Begin a new animation on a given node and its hierarchy
  25075. * @param target defines the root node where the animation will take place
  25076. * @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.
  25077. * @param animations defines the list of animations to start
  25078. * @param from defines the initial value
  25079. * @param to defines the final value
  25080. * @param loop defines if you want animation to loop (off by default)
  25081. * @param speedRatio defines the speed ratio to apply to all animations
  25082. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25083. * @param onAnimationLoop defines the callback to call when an animation loops
  25084. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25085. * @returns the list of animatables created for all nodes
  25086. */
  25087. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25088. /**
  25089. * Gets the animatable associated with a specific target
  25090. * @param target defines the target of the animatable
  25091. * @returns the required animatable if found
  25092. */
  25093. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25094. /**
  25095. * Gets all animatables associated with a given target
  25096. * @param target defines the target to look animatables for
  25097. * @returns an array of Animatables
  25098. */
  25099. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25100. /**
  25101. * Stops and removes all animations that have been applied to the scene
  25102. */
  25103. stopAllAnimations(): void;
  25104. /**
  25105. * Gets the current delta time used by animation engine
  25106. */
  25107. deltaTime: number;
  25108. }
  25109. interface Bone {
  25110. /**
  25111. * Copy an animation range from another bone
  25112. * @param source defines the source bone
  25113. * @param rangeName defines the range name to copy
  25114. * @param frameOffset defines the frame offset
  25115. * @param rescaleAsRequired defines if rescaling must be applied if required
  25116. * @param skelDimensionsRatio defines the scaling ratio
  25117. * @returns true if operation was successful
  25118. */
  25119. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25120. }
  25121. }
  25122. declare module BABYLON {
  25123. /**
  25124. * Class used to override all child animations of a given target
  25125. */
  25126. export class AnimationPropertiesOverride {
  25127. /**
  25128. * Gets or sets a value indicating if animation blending must be used
  25129. */
  25130. enableBlending: boolean;
  25131. /**
  25132. * Gets or sets the blending speed to use when enableBlending is true
  25133. */
  25134. blendingSpeed: number;
  25135. /**
  25136. * Gets or sets the default loop mode to use
  25137. */
  25138. loopMode: number;
  25139. }
  25140. }
  25141. declare module BABYLON {
  25142. /**
  25143. * Class used to handle skinning animations
  25144. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25145. */
  25146. export class Skeleton implements IAnimatable {
  25147. /** defines the skeleton name */
  25148. name: string;
  25149. /** defines the skeleton Id */
  25150. id: string;
  25151. /**
  25152. * Defines the list of child bones
  25153. */
  25154. bones: Bone[];
  25155. /**
  25156. * Defines an estimate of the dimension of the skeleton at rest
  25157. */
  25158. dimensionsAtRest: Vector3;
  25159. /**
  25160. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25161. */
  25162. needInitialSkinMatrix: boolean;
  25163. /**
  25164. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25165. */
  25166. overrideMesh: Nullable<AbstractMesh>;
  25167. /**
  25168. * Gets the list of animations attached to this skeleton
  25169. */
  25170. animations: Array<Animation>;
  25171. private _scene;
  25172. private _isDirty;
  25173. private _transformMatrices;
  25174. private _transformMatrixTexture;
  25175. private _meshesWithPoseMatrix;
  25176. private _animatables;
  25177. private _identity;
  25178. private _synchronizedWithMesh;
  25179. private _ranges;
  25180. private _lastAbsoluteTransformsUpdateId;
  25181. private _canUseTextureForBones;
  25182. private _uniqueId;
  25183. /** @hidden */
  25184. _numBonesWithLinkedTransformNode: number;
  25185. /** @hidden */
  25186. _hasWaitingData: Nullable<boolean>;
  25187. /** @hidden */
  25188. _waitingOverrideMeshId: Nullable<string>;
  25189. /**
  25190. * Specifies if the skeleton should be serialized
  25191. */
  25192. doNotSerialize: boolean;
  25193. private _useTextureToStoreBoneMatrices;
  25194. /**
  25195. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25196. * Please note that this option is not available if the hardware does not support it
  25197. */
  25198. get useTextureToStoreBoneMatrices(): boolean;
  25199. set useTextureToStoreBoneMatrices(value: boolean);
  25200. private _animationPropertiesOverride;
  25201. /**
  25202. * Gets or sets the animation properties override
  25203. */
  25204. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25205. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25206. /**
  25207. * List of inspectable custom properties (used by the Inspector)
  25208. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25209. */
  25210. inspectableCustomProperties: IInspectable[];
  25211. /**
  25212. * An observable triggered before computing the skeleton's matrices
  25213. */
  25214. onBeforeComputeObservable: Observable<Skeleton>;
  25215. /**
  25216. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25217. */
  25218. get isUsingTextureForMatrices(): boolean;
  25219. /**
  25220. * Gets the unique ID of this skeleton
  25221. */
  25222. get uniqueId(): number;
  25223. /**
  25224. * Creates a new skeleton
  25225. * @param name defines the skeleton name
  25226. * @param id defines the skeleton Id
  25227. * @param scene defines the hosting scene
  25228. */
  25229. constructor(
  25230. /** defines the skeleton name */
  25231. name: string,
  25232. /** defines the skeleton Id */
  25233. id: string, scene: Scene);
  25234. /**
  25235. * Gets the current object class name.
  25236. * @return the class name
  25237. */
  25238. getClassName(): string;
  25239. /**
  25240. * Returns an array containing the root bones
  25241. * @returns an array containing the root bones
  25242. */
  25243. getChildren(): Array<Bone>;
  25244. /**
  25245. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25246. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25247. * @returns a Float32Array containing matrices data
  25248. */
  25249. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25250. /**
  25251. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25252. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25253. * @returns a raw texture containing the data
  25254. */
  25255. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25256. /**
  25257. * Gets the current hosting scene
  25258. * @returns a scene object
  25259. */
  25260. getScene(): Scene;
  25261. /**
  25262. * Gets a string representing the current skeleton data
  25263. * @param fullDetails defines a boolean indicating if we want a verbose version
  25264. * @returns a string representing the current skeleton data
  25265. */
  25266. toString(fullDetails?: boolean): string;
  25267. /**
  25268. * Get bone's index searching by name
  25269. * @param name defines bone's name to search for
  25270. * @return the indice of the bone. Returns -1 if not found
  25271. */
  25272. getBoneIndexByName(name: string): number;
  25273. /**
  25274. * Creater a new animation range
  25275. * @param name defines the name of the range
  25276. * @param from defines the start key
  25277. * @param to defines the end key
  25278. */
  25279. createAnimationRange(name: string, from: number, to: number): void;
  25280. /**
  25281. * Delete a specific animation range
  25282. * @param name defines the name of the range
  25283. * @param deleteFrames defines if frames must be removed as well
  25284. */
  25285. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25286. /**
  25287. * Gets a specific animation range
  25288. * @param name defines the name of the range to look for
  25289. * @returns the requested animation range or null if not found
  25290. */
  25291. getAnimationRange(name: string): Nullable<AnimationRange>;
  25292. /**
  25293. * Gets the list of all animation ranges defined on this skeleton
  25294. * @returns an array
  25295. */
  25296. getAnimationRanges(): Nullable<AnimationRange>[];
  25297. /**
  25298. * Copy animation range from a source skeleton.
  25299. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25300. * @param source defines the source skeleton
  25301. * @param name defines the name of the range to copy
  25302. * @param rescaleAsRequired defines if rescaling must be applied if required
  25303. * @returns true if operation was successful
  25304. */
  25305. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25306. /**
  25307. * Forces the skeleton to go to rest pose
  25308. */
  25309. returnToRest(): void;
  25310. private _getHighestAnimationFrame;
  25311. /**
  25312. * Begin a specific animation range
  25313. * @param name defines the name of the range to start
  25314. * @param loop defines if looping must be turned on (false by default)
  25315. * @param speedRatio defines the speed ratio to apply (1 by default)
  25316. * @param onAnimationEnd defines a callback which will be called when animation will end
  25317. * @returns a new animatable
  25318. */
  25319. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25320. /**
  25321. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25322. * @param skeleton defines the Skeleton containing the animation range to convert
  25323. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25324. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25325. * @returns the original skeleton
  25326. */
  25327. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25328. /** @hidden */
  25329. _markAsDirty(): void;
  25330. /** @hidden */
  25331. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25332. /** @hidden */
  25333. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25334. private _computeTransformMatrices;
  25335. /**
  25336. * Build all resources required to render a skeleton
  25337. */
  25338. prepare(): void;
  25339. /**
  25340. * Gets the list of animatables currently running for this skeleton
  25341. * @returns an array of animatables
  25342. */
  25343. getAnimatables(): IAnimatable[];
  25344. /**
  25345. * Clone the current skeleton
  25346. * @param name defines the name of the new skeleton
  25347. * @param id defines the id of the new skeleton
  25348. * @returns the new skeleton
  25349. */
  25350. clone(name: string, id?: string): Skeleton;
  25351. /**
  25352. * Enable animation blending for this skeleton
  25353. * @param blendingSpeed defines the blending speed to apply
  25354. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25355. */
  25356. enableBlending(blendingSpeed?: number): void;
  25357. /**
  25358. * Releases all resources associated with the current skeleton
  25359. */
  25360. dispose(): void;
  25361. /**
  25362. * Serialize the skeleton in a JSON object
  25363. * @returns a JSON object
  25364. */
  25365. serialize(): any;
  25366. /**
  25367. * Creates a new skeleton from serialized data
  25368. * @param parsedSkeleton defines the serialized data
  25369. * @param scene defines the hosting scene
  25370. * @returns a new skeleton
  25371. */
  25372. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25373. /**
  25374. * Compute all node absolute transforms
  25375. * @param forceUpdate defines if computation must be done even if cache is up to date
  25376. */
  25377. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25378. /**
  25379. * Gets the root pose matrix
  25380. * @returns a matrix
  25381. */
  25382. getPoseMatrix(): Nullable<Matrix>;
  25383. /**
  25384. * Sorts bones per internal index
  25385. */
  25386. sortBones(): void;
  25387. private _sortBones;
  25388. /**
  25389. * Set the current local matrix as the restPose for all bones in the skeleton.
  25390. */
  25391. setCurrentPoseAsRest(): void;
  25392. }
  25393. }
  25394. declare module BABYLON {
  25395. /**
  25396. * Class used to store bone information
  25397. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25398. */
  25399. export class Bone extends Node {
  25400. /**
  25401. * defines the bone name
  25402. */
  25403. name: string;
  25404. private static _tmpVecs;
  25405. private static _tmpQuat;
  25406. private static _tmpMats;
  25407. /**
  25408. * Gets the list of child bones
  25409. */
  25410. children: Bone[];
  25411. /** Gets the animations associated with this bone */
  25412. animations: Animation[];
  25413. /**
  25414. * Gets or sets bone length
  25415. */
  25416. length: number;
  25417. /**
  25418. * @hidden Internal only
  25419. * Set this value to map this bone to a different index in the transform matrices
  25420. * Set this value to -1 to exclude the bone from the transform matrices
  25421. */
  25422. _index: Nullable<number>;
  25423. private _skeleton;
  25424. private _localMatrix;
  25425. private _restPose;
  25426. private _bindPose;
  25427. private _baseMatrix;
  25428. private _absoluteTransform;
  25429. private _invertedAbsoluteTransform;
  25430. private _parent;
  25431. private _scalingDeterminant;
  25432. private _worldTransform;
  25433. private _localScaling;
  25434. private _localRotation;
  25435. private _localPosition;
  25436. private _needToDecompose;
  25437. private _needToCompose;
  25438. /** @hidden */
  25439. _linkedTransformNode: Nullable<TransformNode>;
  25440. /** @hidden */
  25441. _waitingTransformNodeId: Nullable<string>;
  25442. /** @hidden */
  25443. get _matrix(): Matrix;
  25444. /** @hidden */
  25445. set _matrix(value: Matrix);
  25446. /**
  25447. * Create a new bone
  25448. * @param name defines the bone name
  25449. * @param skeleton defines the parent skeleton
  25450. * @param parentBone defines the parent (can be null if the bone is the root)
  25451. * @param localMatrix defines the local matrix
  25452. * @param restPose defines the rest pose matrix
  25453. * @param baseMatrix defines the base matrix
  25454. * @param index defines index of the bone in the hiearchy
  25455. */
  25456. constructor(
  25457. /**
  25458. * defines the bone name
  25459. */
  25460. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25461. /**
  25462. * Gets the current object class name.
  25463. * @return the class name
  25464. */
  25465. getClassName(): string;
  25466. /**
  25467. * Gets the parent skeleton
  25468. * @returns a skeleton
  25469. */
  25470. getSkeleton(): Skeleton;
  25471. /**
  25472. * Gets parent bone
  25473. * @returns a bone or null if the bone is the root of the bone hierarchy
  25474. */
  25475. getParent(): Nullable<Bone>;
  25476. /**
  25477. * Returns an array containing the root bones
  25478. * @returns an array containing the root bones
  25479. */
  25480. getChildren(): Array<Bone>;
  25481. /**
  25482. * Gets the node index in matrix array generated for rendering
  25483. * @returns the node index
  25484. */
  25485. getIndex(): number;
  25486. /**
  25487. * Sets the parent bone
  25488. * @param parent defines the parent (can be null if the bone is the root)
  25489. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25490. */
  25491. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25492. /**
  25493. * Gets the local matrix
  25494. * @returns a matrix
  25495. */
  25496. getLocalMatrix(): Matrix;
  25497. /**
  25498. * Gets the base matrix (initial matrix which remains unchanged)
  25499. * @returns a matrix
  25500. */
  25501. getBaseMatrix(): Matrix;
  25502. /**
  25503. * Gets the rest pose matrix
  25504. * @returns a matrix
  25505. */
  25506. getRestPose(): Matrix;
  25507. /**
  25508. * Sets the rest pose matrix
  25509. * @param matrix the local-space rest pose to set for this bone
  25510. */
  25511. setRestPose(matrix: Matrix): void;
  25512. /**
  25513. * Gets the bind pose matrix
  25514. * @returns the bind pose matrix
  25515. */
  25516. getBindPose(): Matrix;
  25517. /**
  25518. * Sets the bind pose matrix
  25519. * @param matrix the local-space bind pose to set for this bone
  25520. */
  25521. setBindPose(matrix: Matrix): void;
  25522. /**
  25523. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25524. */
  25525. getWorldMatrix(): Matrix;
  25526. /**
  25527. * Sets the local matrix to rest pose matrix
  25528. */
  25529. returnToRest(): void;
  25530. /**
  25531. * Gets the inverse of the absolute transform matrix.
  25532. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25533. * @returns a matrix
  25534. */
  25535. getInvertedAbsoluteTransform(): Matrix;
  25536. /**
  25537. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25538. * @returns a matrix
  25539. */
  25540. getAbsoluteTransform(): Matrix;
  25541. /**
  25542. * Links with the given transform node.
  25543. * The local matrix of this bone is copied from the transform node every frame.
  25544. * @param transformNode defines the transform node to link to
  25545. */
  25546. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25547. /**
  25548. * Gets the node used to drive the bone's transformation
  25549. * @returns a transform node or null
  25550. */
  25551. getTransformNode(): Nullable<TransformNode>;
  25552. /** Gets or sets current position (in local space) */
  25553. get position(): Vector3;
  25554. set position(newPosition: Vector3);
  25555. /** Gets or sets current rotation (in local space) */
  25556. get rotation(): Vector3;
  25557. set rotation(newRotation: Vector3);
  25558. /** Gets or sets current rotation quaternion (in local space) */
  25559. get rotationQuaternion(): Quaternion;
  25560. set rotationQuaternion(newRotation: Quaternion);
  25561. /** Gets or sets current scaling (in local space) */
  25562. get scaling(): Vector3;
  25563. set scaling(newScaling: Vector3);
  25564. /**
  25565. * Gets the animation properties override
  25566. */
  25567. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25568. private _decompose;
  25569. private _compose;
  25570. /**
  25571. * Update the base and local matrices
  25572. * @param matrix defines the new base or local matrix
  25573. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25574. * @param updateLocalMatrix defines if the local matrix should be updated
  25575. */
  25576. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25577. /** @hidden */
  25578. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25579. /**
  25580. * Flag the bone as dirty (Forcing it to update everything)
  25581. */
  25582. markAsDirty(): void;
  25583. /** @hidden */
  25584. _markAsDirtyAndCompose(): void;
  25585. private _markAsDirtyAndDecompose;
  25586. /**
  25587. * Translate the bone in local or world space
  25588. * @param vec The amount to translate the bone
  25589. * @param space The space that the translation is in
  25590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25591. */
  25592. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25593. /**
  25594. * Set the postion of the bone in local or world space
  25595. * @param position The position to set the bone
  25596. * @param space The space that the position is in
  25597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25598. */
  25599. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25600. /**
  25601. * Set the absolute position of the bone (world space)
  25602. * @param position The position to set the bone
  25603. * @param mesh The mesh that this bone is attached to
  25604. */
  25605. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25606. /**
  25607. * Scale the bone on the x, y and z axes (in local space)
  25608. * @param x The amount to scale the bone on the x axis
  25609. * @param y The amount to scale the bone on the y axis
  25610. * @param z The amount to scale the bone on the z axis
  25611. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25612. */
  25613. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25614. /**
  25615. * Set the bone scaling in local space
  25616. * @param scale defines the scaling vector
  25617. */
  25618. setScale(scale: Vector3): void;
  25619. /**
  25620. * Gets the current scaling in local space
  25621. * @returns the current scaling vector
  25622. */
  25623. getScale(): Vector3;
  25624. /**
  25625. * Gets the current scaling in local space and stores it in a target vector
  25626. * @param result defines the target vector
  25627. */
  25628. getScaleToRef(result: Vector3): void;
  25629. /**
  25630. * Set the yaw, pitch, and roll of the bone in local or world space
  25631. * @param yaw The rotation of the bone on the y axis
  25632. * @param pitch The rotation of the bone on the x axis
  25633. * @param roll The rotation of the bone on the z axis
  25634. * @param space The space that the axes of rotation are in
  25635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25636. */
  25637. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25638. /**
  25639. * Add a rotation to the bone on an axis in local or world space
  25640. * @param axis The axis to rotate the bone on
  25641. * @param amount The amount to rotate the bone
  25642. * @param space The space that the axis is in
  25643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25644. */
  25645. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25646. /**
  25647. * Set the rotation of the bone to a particular axis angle in local or world space
  25648. * @param axis The axis to rotate the bone on
  25649. * @param angle The angle that the bone should be rotated to
  25650. * @param space The space that the axis is in
  25651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25652. */
  25653. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25654. /**
  25655. * Set the euler rotation of the bone in local or world space
  25656. * @param rotation The euler rotation that the bone should be set to
  25657. * @param space The space that the rotation is in
  25658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25659. */
  25660. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25661. /**
  25662. * Set the quaternion rotation of the bone in local or world space
  25663. * @param quat The quaternion rotation that the bone should be set to
  25664. * @param space The space that the rotation is in
  25665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25666. */
  25667. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25668. /**
  25669. * Set the rotation matrix of the bone in local or world space
  25670. * @param rotMat The rotation matrix that the bone should be set to
  25671. * @param space The space that the rotation is in
  25672. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25673. */
  25674. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25675. private _rotateWithMatrix;
  25676. private _getNegativeRotationToRef;
  25677. /**
  25678. * Get the position of the bone in local or world space
  25679. * @param space The space that the returned position is in
  25680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25681. * @returns The position of the bone
  25682. */
  25683. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25684. /**
  25685. * Copy the position of the bone to a vector3 in local or world space
  25686. * @param space The space that the returned position is in
  25687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25688. * @param result The vector3 to copy the position to
  25689. */
  25690. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25691. /**
  25692. * Get the absolute position of the bone (world space)
  25693. * @param mesh The mesh that this bone is attached to
  25694. * @returns The absolute position of the bone
  25695. */
  25696. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25697. /**
  25698. * Copy the absolute position of the bone (world space) to the result param
  25699. * @param mesh The mesh that this bone is attached to
  25700. * @param result The vector3 to copy the absolute position to
  25701. */
  25702. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25703. /**
  25704. * Compute the absolute transforms of this bone and its children
  25705. */
  25706. computeAbsoluteTransforms(): void;
  25707. /**
  25708. * Get the world direction from an axis that is in the local space of the bone
  25709. * @param localAxis The local direction that is used to compute the world direction
  25710. * @param mesh The mesh that this bone is attached to
  25711. * @returns The world direction
  25712. */
  25713. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25714. /**
  25715. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25716. * @param localAxis The local direction that is used to compute the world direction
  25717. * @param mesh The mesh that this bone is attached to
  25718. * @param result The vector3 that the world direction will be copied to
  25719. */
  25720. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25721. /**
  25722. * Get the euler rotation of the bone in local or world space
  25723. * @param space The space that the rotation should be in
  25724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25725. * @returns The euler rotation
  25726. */
  25727. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25728. /**
  25729. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25730. * @param space The space that the rotation should be in
  25731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25732. * @param result The vector3 that the rotation should be copied to
  25733. */
  25734. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25735. /**
  25736. * Get the quaternion rotation of the bone in either local or world space
  25737. * @param space The space that the rotation should be in
  25738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25739. * @returns The quaternion rotation
  25740. */
  25741. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25742. /**
  25743. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25744. * @param space The space that the rotation should be in
  25745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25746. * @param result The quaternion that the rotation should be copied to
  25747. */
  25748. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25749. /**
  25750. * Get the rotation matrix of the bone in local or world space
  25751. * @param space The space that the rotation should be in
  25752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25753. * @returns The rotation matrix
  25754. */
  25755. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25756. /**
  25757. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25758. * @param space The space that the rotation should be in
  25759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25760. * @param result The quaternion that the rotation should be copied to
  25761. */
  25762. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25763. /**
  25764. * Get the world position of a point that is in the local space of the bone
  25765. * @param position The local position
  25766. * @param mesh The mesh that this bone is attached to
  25767. * @returns The world position
  25768. */
  25769. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25770. /**
  25771. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25772. * @param position The local position
  25773. * @param mesh The mesh that this bone is attached to
  25774. * @param result The vector3 that the world position should be copied to
  25775. */
  25776. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25777. /**
  25778. * Get the local position of a point that is in world space
  25779. * @param position The world position
  25780. * @param mesh The mesh that this bone is attached to
  25781. * @returns The local position
  25782. */
  25783. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25784. /**
  25785. * Get the local position of a point that is in world space and copy it to the result param
  25786. * @param position The world position
  25787. * @param mesh The mesh that this bone is attached to
  25788. * @param result The vector3 that the local position should be copied to
  25789. */
  25790. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25791. /**
  25792. * Set the current local matrix as the restPose for this bone.
  25793. */
  25794. setCurrentPoseAsRest(): void;
  25795. }
  25796. }
  25797. declare module BABYLON {
  25798. /**
  25799. * 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.
  25800. * @see https://doc.babylonjs.com/how_to/transformnode
  25801. */
  25802. export class TransformNode extends Node {
  25803. /**
  25804. * Object will not rotate to face the camera
  25805. */
  25806. static BILLBOARDMODE_NONE: number;
  25807. /**
  25808. * Object will rotate to face the camera but only on the x axis
  25809. */
  25810. static BILLBOARDMODE_X: number;
  25811. /**
  25812. * Object will rotate to face the camera but only on the y axis
  25813. */
  25814. static BILLBOARDMODE_Y: number;
  25815. /**
  25816. * Object will rotate to face the camera but only on the z axis
  25817. */
  25818. static BILLBOARDMODE_Z: number;
  25819. /**
  25820. * Object will rotate to face the camera
  25821. */
  25822. static BILLBOARDMODE_ALL: number;
  25823. /**
  25824. * Object will rotate to face the camera's position instead of orientation
  25825. */
  25826. static BILLBOARDMODE_USE_POSITION: number;
  25827. private static _TmpRotation;
  25828. private static _TmpScaling;
  25829. private static _TmpTranslation;
  25830. private _forward;
  25831. private _forwardInverted;
  25832. private _up;
  25833. private _right;
  25834. private _rightInverted;
  25835. private _position;
  25836. private _rotation;
  25837. private _rotationQuaternion;
  25838. protected _scaling: Vector3;
  25839. protected _isDirty: boolean;
  25840. private _transformToBoneReferal;
  25841. private _isAbsoluteSynced;
  25842. private _billboardMode;
  25843. /**
  25844. * Gets or sets the billboard mode. Default is 0.
  25845. *
  25846. * | Value | Type | Description |
  25847. * | --- | --- | --- |
  25848. * | 0 | BILLBOARDMODE_NONE | |
  25849. * | 1 | BILLBOARDMODE_X | |
  25850. * | 2 | BILLBOARDMODE_Y | |
  25851. * | 4 | BILLBOARDMODE_Z | |
  25852. * | 7 | BILLBOARDMODE_ALL | |
  25853. *
  25854. */
  25855. get billboardMode(): number;
  25856. set billboardMode(value: number);
  25857. private _preserveParentRotationForBillboard;
  25858. /**
  25859. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25860. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25861. */
  25862. get preserveParentRotationForBillboard(): boolean;
  25863. set preserveParentRotationForBillboard(value: boolean);
  25864. /**
  25865. * 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
  25866. */
  25867. scalingDeterminant: number;
  25868. private _infiniteDistance;
  25869. /**
  25870. * Gets or sets the distance of the object to max, often used by skybox
  25871. */
  25872. get infiniteDistance(): boolean;
  25873. set infiniteDistance(value: boolean);
  25874. /**
  25875. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25876. * By default the system will update normals to compensate
  25877. */
  25878. ignoreNonUniformScaling: boolean;
  25879. /**
  25880. * 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
  25881. */
  25882. reIntegrateRotationIntoRotationQuaternion: boolean;
  25883. /** @hidden */
  25884. _poseMatrix: Nullable<Matrix>;
  25885. /** @hidden */
  25886. _localMatrix: Matrix;
  25887. private _usePivotMatrix;
  25888. private _absolutePosition;
  25889. private _absoluteScaling;
  25890. private _absoluteRotationQuaternion;
  25891. private _pivotMatrix;
  25892. private _pivotMatrixInverse;
  25893. /** @hidden */
  25894. _postMultiplyPivotMatrix: boolean;
  25895. protected _isWorldMatrixFrozen: boolean;
  25896. /** @hidden */
  25897. _indexInSceneTransformNodesArray: number;
  25898. /**
  25899. * An event triggered after the world matrix is updated
  25900. */
  25901. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25902. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25903. /**
  25904. * Gets a string identifying the name of the class
  25905. * @returns "TransformNode" string
  25906. */
  25907. getClassName(): string;
  25908. /**
  25909. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25910. */
  25911. get position(): Vector3;
  25912. set position(newPosition: Vector3);
  25913. /**
  25914. * 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)).
  25915. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25916. */
  25917. get rotation(): Vector3;
  25918. set rotation(newRotation: Vector3);
  25919. /**
  25920. * 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)).
  25921. */
  25922. get scaling(): Vector3;
  25923. set scaling(newScaling: Vector3);
  25924. /**
  25925. * 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).
  25926. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25927. */
  25928. get rotationQuaternion(): Nullable<Quaternion>;
  25929. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25930. /**
  25931. * The forward direction of that transform in world space.
  25932. */
  25933. get forward(): Vector3;
  25934. /**
  25935. * The up direction of that transform in world space.
  25936. */
  25937. get up(): Vector3;
  25938. /**
  25939. * The right direction of that transform in world space.
  25940. */
  25941. get right(): Vector3;
  25942. /**
  25943. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25944. * @param matrix the matrix to copy the pose from
  25945. * @returns this TransformNode.
  25946. */
  25947. updatePoseMatrix(matrix: Matrix): TransformNode;
  25948. /**
  25949. * Returns the mesh Pose matrix.
  25950. * @returns the pose matrix
  25951. */
  25952. getPoseMatrix(): Matrix;
  25953. /** @hidden */
  25954. _isSynchronized(): boolean;
  25955. /** @hidden */
  25956. _initCache(): void;
  25957. /**
  25958. * Flag the transform node as dirty (Forcing it to update everything)
  25959. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25960. * @returns this transform node
  25961. */
  25962. markAsDirty(property: string): TransformNode;
  25963. /**
  25964. * Returns the current mesh absolute position.
  25965. * Returns a Vector3.
  25966. */
  25967. get absolutePosition(): Vector3;
  25968. /**
  25969. * Returns the current mesh absolute scaling.
  25970. * Returns a Vector3.
  25971. */
  25972. get absoluteScaling(): Vector3;
  25973. /**
  25974. * Returns the current mesh absolute rotation.
  25975. * Returns a Quaternion.
  25976. */
  25977. get absoluteRotationQuaternion(): Quaternion;
  25978. /**
  25979. * Sets a new matrix to apply before all other transformation
  25980. * @param matrix defines the transform matrix
  25981. * @returns the current TransformNode
  25982. */
  25983. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25984. /**
  25985. * Sets a new pivot matrix to the current node
  25986. * @param matrix defines the new pivot matrix to use
  25987. * @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
  25988. * @returns the current TransformNode
  25989. */
  25990. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25991. /**
  25992. * Returns the mesh pivot matrix.
  25993. * Default : Identity.
  25994. * @returns the matrix
  25995. */
  25996. getPivotMatrix(): Matrix;
  25997. /**
  25998. * Instantiate (when possible) or clone that node with its hierarchy
  25999. * @param newParent defines the new parent to use for the instance (or clone)
  26000. * @param options defines options to configure how copy is done
  26001. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26002. * @returns an instance (or a clone) of the current node with its hiearchy
  26003. */
  26004. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26005. doNotInstantiate: boolean;
  26006. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26007. /**
  26008. * Prevents the World matrix to be computed any longer
  26009. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26010. * @returns the TransformNode.
  26011. */
  26012. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26013. /**
  26014. * Allows back the World matrix computation.
  26015. * @returns the TransformNode.
  26016. */
  26017. unfreezeWorldMatrix(): this;
  26018. /**
  26019. * True if the World matrix has been frozen.
  26020. */
  26021. get isWorldMatrixFrozen(): boolean;
  26022. /**
  26023. * Retuns the mesh absolute position in the World.
  26024. * @returns a Vector3.
  26025. */
  26026. getAbsolutePosition(): Vector3;
  26027. /**
  26028. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26029. * @param absolutePosition the absolute position to set
  26030. * @returns the TransformNode.
  26031. */
  26032. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26033. /**
  26034. * Sets the mesh position in its local space.
  26035. * @param vector3 the position to set in localspace
  26036. * @returns the TransformNode.
  26037. */
  26038. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26039. /**
  26040. * Returns the mesh position in the local space from the current World matrix values.
  26041. * @returns a new Vector3.
  26042. */
  26043. getPositionExpressedInLocalSpace(): Vector3;
  26044. /**
  26045. * Translates the mesh along the passed Vector3 in its local space.
  26046. * @param vector3 the distance to translate in localspace
  26047. * @returns the TransformNode.
  26048. */
  26049. locallyTranslate(vector3: Vector3): TransformNode;
  26050. private static _lookAtVectorCache;
  26051. /**
  26052. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26053. * @param targetPoint the position (must be in same space as current mesh) to look at
  26054. * @param yawCor optional yaw (y-axis) correction in radians
  26055. * @param pitchCor optional pitch (x-axis) correction in radians
  26056. * @param rollCor optional roll (z-axis) correction in radians
  26057. * @param space the choosen space of the target
  26058. * @returns the TransformNode.
  26059. */
  26060. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26061. /**
  26062. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26063. * This Vector3 is expressed in the World space.
  26064. * @param localAxis axis to rotate
  26065. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26066. */
  26067. getDirection(localAxis: Vector3): Vector3;
  26068. /**
  26069. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26070. * localAxis is expressed in the mesh local space.
  26071. * result is computed in the Wordl space from the mesh World matrix.
  26072. * @param localAxis axis to rotate
  26073. * @param result the resulting transformnode
  26074. * @returns this TransformNode.
  26075. */
  26076. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26077. /**
  26078. * Sets this transform node rotation to the given local axis.
  26079. * @param localAxis the axis in local space
  26080. * @param yawCor optional yaw (y-axis) correction in radians
  26081. * @param pitchCor optional pitch (x-axis) correction in radians
  26082. * @param rollCor optional roll (z-axis) correction in radians
  26083. * @returns this TransformNode
  26084. */
  26085. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26086. /**
  26087. * Sets a new pivot point to the current node
  26088. * @param point defines the new pivot point to use
  26089. * @param space defines if the point is in world or local space (local by default)
  26090. * @returns the current TransformNode
  26091. */
  26092. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26093. /**
  26094. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26095. * @returns the pivot point
  26096. */
  26097. getPivotPoint(): Vector3;
  26098. /**
  26099. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26100. * @param result the vector3 to store the result
  26101. * @returns this TransformNode.
  26102. */
  26103. getPivotPointToRef(result: Vector3): TransformNode;
  26104. /**
  26105. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26106. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26107. */
  26108. getAbsolutePivotPoint(): Vector3;
  26109. /**
  26110. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26111. * @param result vector3 to store the result
  26112. * @returns this TransformNode.
  26113. */
  26114. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26115. /**
  26116. * Defines the passed node as the parent of the current node.
  26117. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26118. * @see https://doc.babylonjs.com/how_to/parenting
  26119. * @param node the node ot set as the parent
  26120. * @returns this TransformNode.
  26121. */
  26122. setParent(node: Nullable<Node>): TransformNode;
  26123. private _nonUniformScaling;
  26124. /**
  26125. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26126. */
  26127. get nonUniformScaling(): boolean;
  26128. /** @hidden */
  26129. _updateNonUniformScalingState(value: boolean): boolean;
  26130. /**
  26131. * Attach the current TransformNode to another TransformNode associated with a bone
  26132. * @param bone Bone affecting the TransformNode
  26133. * @param affectedTransformNode TransformNode associated with the bone
  26134. * @returns this object
  26135. */
  26136. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26137. /**
  26138. * Detach the transform node if its associated with a bone
  26139. * @returns this object
  26140. */
  26141. detachFromBone(): TransformNode;
  26142. private static _rotationAxisCache;
  26143. /**
  26144. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26145. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26146. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26147. * The passed axis is also normalized.
  26148. * @param axis the axis to rotate around
  26149. * @param amount the amount to rotate in radians
  26150. * @param space Space to rotate in (Default: local)
  26151. * @returns the TransformNode.
  26152. */
  26153. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26154. /**
  26155. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26156. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26157. * The passed axis is also normalized. .
  26158. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26159. * @param point the point to rotate around
  26160. * @param axis the axis to rotate around
  26161. * @param amount the amount to rotate in radians
  26162. * @returns the TransformNode
  26163. */
  26164. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26165. /**
  26166. * Translates the mesh along the axis vector for the passed distance in the given space.
  26167. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26168. * @param axis the axis to translate in
  26169. * @param distance the distance to translate
  26170. * @param space Space to rotate in (Default: local)
  26171. * @returns the TransformNode.
  26172. */
  26173. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26174. /**
  26175. * Adds a rotation step to the mesh current rotation.
  26176. * x, y, z are Euler angles expressed in radians.
  26177. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26178. * This means this rotation is made in the mesh local space only.
  26179. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26180. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26181. * ```javascript
  26182. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26183. * ```
  26184. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26185. * 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.
  26186. * @param x Rotation to add
  26187. * @param y Rotation to add
  26188. * @param z Rotation to add
  26189. * @returns the TransformNode.
  26190. */
  26191. addRotation(x: number, y: number, z: number): TransformNode;
  26192. /**
  26193. * @hidden
  26194. */
  26195. protected _getEffectiveParent(): Nullable<Node>;
  26196. /**
  26197. * Computes the world matrix of the node
  26198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26199. * @returns the world matrix
  26200. */
  26201. computeWorldMatrix(force?: boolean): Matrix;
  26202. /**
  26203. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26204. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26205. */
  26206. resetLocalMatrix(independentOfChildren?: boolean): void;
  26207. protected _afterComputeWorldMatrix(): void;
  26208. /**
  26209. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26210. * @param func callback function to add
  26211. *
  26212. * @returns the TransformNode.
  26213. */
  26214. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26215. /**
  26216. * Removes a registered callback function.
  26217. * @param func callback function to remove
  26218. * @returns the TransformNode.
  26219. */
  26220. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26221. /**
  26222. * Gets the position of the current mesh in camera space
  26223. * @param camera defines the camera to use
  26224. * @returns a position
  26225. */
  26226. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26227. /**
  26228. * Returns the distance from the mesh to the active camera
  26229. * @param camera defines the camera to use
  26230. * @returns the distance
  26231. */
  26232. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26233. /**
  26234. * Clone the current transform node
  26235. * @param name Name of the new clone
  26236. * @param newParent New parent for the clone
  26237. * @param doNotCloneChildren Do not clone children hierarchy
  26238. * @returns the new transform node
  26239. */
  26240. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26241. /**
  26242. * Serializes the objects information.
  26243. * @param currentSerializationObject defines the object to serialize in
  26244. * @returns the serialized object
  26245. */
  26246. serialize(currentSerializationObject?: any): any;
  26247. /**
  26248. * Returns a new TransformNode object parsed from the source provided.
  26249. * @param parsedTransformNode is the source.
  26250. * @param scene the scne the object belongs to
  26251. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26252. * @returns a new TransformNode object parsed from the source provided.
  26253. */
  26254. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26255. /**
  26256. * Get all child-transformNodes of this node
  26257. * @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
  26258. * @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
  26259. * @returns an array of TransformNode
  26260. */
  26261. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26262. /**
  26263. * Releases resources associated with this transform node.
  26264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26266. */
  26267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26268. /**
  26269. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26270. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26271. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26272. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26273. * @returns the current mesh
  26274. */
  26275. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26276. private _syncAbsoluteScalingAndRotation;
  26277. }
  26278. }
  26279. declare module BABYLON {
  26280. /**
  26281. * Defines the types of pose enabled controllers that are supported
  26282. */
  26283. export enum PoseEnabledControllerType {
  26284. /**
  26285. * HTC Vive
  26286. */
  26287. VIVE = 0,
  26288. /**
  26289. * Oculus Rift
  26290. */
  26291. OCULUS = 1,
  26292. /**
  26293. * Windows mixed reality
  26294. */
  26295. WINDOWS = 2,
  26296. /**
  26297. * Samsung gear VR
  26298. */
  26299. GEAR_VR = 3,
  26300. /**
  26301. * Google Daydream
  26302. */
  26303. DAYDREAM = 4,
  26304. /**
  26305. * Generic
  26306. */
  26307. GENERIC = 5
  26308. }
  26309. /**
  26310. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26311. */
  26312. export interface MutableGamepadButton {
  26313. /**
  26314. * Value of the button/trigger
  26315. */
  26316. value: number;
  26317. /**
  26318. * If the button/trigger is currently touched
  26319. */
  26320. touched: boolean;
  26321. /**
  26322. * If the button/trigger is currently pressed
  26323. */
  26324. pressed: boolean;
  26325. }
  26326. /**
  26327. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26328. * @hidden
  26329. */
  26330. export interface ExtendedGamepadButton extends GamepadButton {
  26331. /**
  26332. * If the button/trigger is currently pressed
  26333. */
  26334. readonly pressed: boolean;
  26335. /**
  26336. * If the button/trigger is currently touched
  26337. */
  26338. readonly touched: boolean;
  26339. /**
  26340. * Value of the button/trigger
  26341. */
  26342. readonly value: number;
  26343. }
  26344. /** @hidden */
  26345. export interface _GamePadFactory {
  26346. /**
  26347. * Returns whether or not the current gamepad can be created for this type of controller.
  26348. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26349. * @returns true if it can be created, otherwise false
  26350. */
  26351. canCreate(gamepadInfo: any): boolean;
  26352. /**
  26353. * Creates a new instance of the Gamepad.
  26354. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26355. * @returns the new gamepad instance
  26356. */
  26357. create(gamepadInfo: any): Gamepad;
  26358. }
  26359. /**
  26360. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26361. */
  26362. export class PoseEnabledControllerHelper {
  26363. /** @hidden */
  26364. static _ControllerFactories: _GamePadFactory[];
  26365. /** @hidden */
  26366. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26367. /**
  26368. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26369. * @param vrGamepad the gamepad to initialized
  26370. * @returns a vr controller of the type the gamepad identified as
  26371. */
  26372. static InitiateController(vrGamepad: any): Gamepad;
  26373. }
  26374. /**
  26375. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26376. */
  26377. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26378. /**
  26379. * If the controller is used in a webXR session
  26380. */
  26381. isXR: boolean;
  26382. private _deviceRoomPosition;
  26383. private _deviceRoomRotationQuaternion;
  26384. /**
  26385. * The device position in babylon space
  26386. */
  26387. devicePosition: Vector3;
  26388. /**
  26389. * The device rotation in babylon space
  26390. */
  26391. deviceRotationQuaternion: Quaternion;
  26392. /**
  26393. * The scale factor of the device in babylon space
  26394. */
  26395. deviceScaleFactor: number;
  26396. /**
  26397. * (Likely devicePosition should be used instead) The device position in its room space
  26398. */
  26399. position: Vector3;
  26400. /**
  26401. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26402. */
  26403. rotationQuaternion: Quaternion;
  26404. /**
  26405. * The type of controller (Eg. Windows mixed reality)
  26406. */
  26407. controllerType: PoseEnabledControllerType;
  26408. protected _calculatedPosition: Vector3;
  26409. private _calculatedRotation;
  26410. /**
  26411. * The raw pose from the device
  26412. */
  26413. rawPose: DevicePose;
  26414. private _trackPosition;
  26415. private _maxRotationDistFromHeadset;
  26416. private _draggedRoomRotation;
  26417. /**
  26418. * @hidden
  26419. */
  26420. _disableTrackPosition(fixedPosition: Vector3): void;
  26421. /**
  26422. * Internal, the mesh attached to the controller
  26423. * @hidden
  26424. */
  26425. _mesh: Nullable<AbstractMesh>;
  26426. private _poseControlledCamera;
  26427. private _leftHandSystemQuaternion;
  26428. /**
  26429. * Internal, matrix used to convert room space to babylon space
  26430. * @hidden
  26431. */
  26432. _deviceToWorld: Matrix;
  26433. /**
  26434. * Node to be used when casting a ray from the controller
  26435. * @hidden
  26436. */
  26437. _pointingPoseNode: Nullable<TransformNode>;
  26438. /**
  26439. * Name of the child mesh that can be used to cast a ray from the controller
  26440. */
  26441. static readonly POINTING_POSE: string;
  26442. /**
  26443. * Creates a new PoseEnabledController from a gamepad
  26444. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26445. */
  26446. constructor(browserGamepad: any);
  26447. private _workingMatrix;
  26448. /**
  26449. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26450. */
  26451. update(): void;
  26452. /**
  26453. * Updates only the pose device and mesh without doing any button event checking
  26454. */
  26455. protected _updatePoseAndMesh(): void;
  26456. /**
  26457. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26458. * @param poseData raw pose fromthe device
  26459. */
  26460. updateFromDevice(poseData: DevicePose): void;
  26461. /**
  26462. * @hidden
  26463. */
  26464. _meshAttachedObservable: Observable<AbstractMesh>;
  26465. /**
  26466. * Attaches a mesh to the controller
  26467. * @param mesh the mesh to be attached
  26468. */
  26469. attachToMesh(mesh: AbstractMesh): void;
  26470. /**
  26471. * Attaches the controllers mesh to a camera
  26472. * @param camera the camera the mesh should be attached to
  26473. */
  26474. attachToPoseControlledCamera(camera: TargetCamera): void;
  26475. /**
  26476. * Disposes of the controller
  26477. */
  26478. dispose(): void;
  26479. /**
  26480. * The mesh that is attached to the controller
  26481. */
  26482. get mesh(): Nullable<AbstractMesh>;
  26483. /**
  26484. * Gets the ray of the controller in the direction the controller is pointing
  26485. * @param length the length the resulting ray should be
  26486. * @returns a ray in the direction the controller is pointing
  26487. */
  26488. getForwardRay(length?: number): Ray;
  26489. }
  26490. }
  26491. declare module BABYLON {
  26492. /**
  26493. * Defines the WebVRController object that represents controllers tracked in 3D space
  26494. */
  26495. export abstract class WebVRController extends PoseEnabledController {
  26496. /**
  26497. * Internal, the default controller model for the controller
  26498. */
  26499. protected _defaultModel: Nullable<AbstractMesh>;
  26500. /**
  26501. * Fired when the trigger state has changed
  26502. */
  26503. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26504. /**
  26505. * Fired when the main button state has changed
  26506. */
  26507. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26508. /**
  26509. * Fired when the secondary button state has changed
  26510. */
  26511. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26512. /**
  26513. * Fired when the pad state has changed
  26514. */
  26515. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26516. /**
  26517. * Fired when controllers stick values have changed
  26518. */
  26519. onPadValuesChangedObservable: Observable<StickValues>;
  26520. /**
  26521. * Array of button availible on the controller
  26522. */
  26523. protected _buttons: Array<MutableGamepadButton>;
  26524. private _onButtonStateChange;
  26525. /**
  26526. * Fired when a controller button's state has changed
  26527. * @param callback the callback containing the button that was modified
  26528. */
  26529. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26530. /**
  26531. * X and Y axis corresponding to the controllers joystick
  26532. */
  26533. pad: StickValues;
  26534. /**
  26535. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26536. */
  26537. hand: string;
  26538. /**
  26539. * The default controller model for the controller
  26540. */
  26541. get defaultModel(): Nullable<AbstractMesh>;
  26542. /**
  26543. * Creates a new WebVRController from a gamepad
  26544. * @param vrGamepad the gamepad that the WebVRController should be created from
  26545. */
  26546. constructor(vrGamepad: any);
  26547. /**
  26548. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26549. */
  26550. update(): void;
  26551. /**
  26552. * Function to be called when a button is modified
  26553. */
  26554. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26555. /**
  26556. * Loads a mesh and attaches it to the controller
  26557. * @param scene the scene the mesh should be added to
  26558. * @param meshLoaded callback for when the mesh has been loaded
  26559. */
  26560. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26561. private _setButtonValue;
  26562. private _changes;
  26563. private _checkChanges;
  26564. /**
  26565. * Disposes of th webVRCOntroller
  26566. */
  26567. dispose(): void;
  26568. }
  26569. }
  26570. declare module BABYLON {
  26571. /**
  26572. * The HemisphericLight simulates the ambient environment light,
  26573. * so the passed direction is the light reflection direction, not the incoming direction.
  26574. */
  26575. export class HemisphericLight extends Light {
  26576. /**
  26577. * The groundColor is the light in the opposite direction to the one specified during creation.
  26578. * 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.
  26579. */
  26580. groundColor: Color3;
  26581. /**
  26582. * The light reflection direction, not the incoming direction.
  26583. */
  26584. direction: Vector3;
  26585. /**
  26586. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26587. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26588. * The HemisphericLight can't cast shadows.
  26589. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26590. * @param name The friendly name of the light
  26591. * @param direction The direction of the light reflection
  26592. * @param scene The scene the light belongs to
  26593. */
  26594. constructor(name: string, direction: Vector3, scene: Scene);
  26595. protected _buildUniformLayout(): void;
  26596. /**
  26597. * Returns the string "HemisphericLight".
  26598. * @return The class name
  26599. */
  26600. getClassName(): string;
  26601. /**
  26602. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26603. * Returns the updated direction.
  26604. * @param target The target the direction should point to
  26605. * @return The computed direction
  26606. */
  26607. setDirectionToTarget(target: Vector3): Vector3;
  26608. /**
  26609. * Returns the shadow generator associated to the light.
  26610. * @returns Always null for hemispheric lights because it does not support shadows.
  26611. */
  26612. getShadowGenerator(): Nullable<IShadowGenerator>;
  26613. /**
  26614. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26615. * @param effect The effect to update
  26616. * @param lightIndex The index of the light in the effect to update
  26617. * @returns The hemispheric light
  26618. */
  26619. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26620. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26621. /**
  26622. * Computes the world matrix of the node
  26623. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26624. * @param useWasUpdatedFlag defines a reserved property
  26625. * @returns the world matrix
  26626. */
  26627. computeWorldMatrix(): Matrix;
  26628. /**
  26629. * Returns the integer 3.
  26630. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26631. */
  26632. getTypeID(): number;
  26633. /**
  26634. * Prepares the list of defines specific to the light type.
  26635. * @param defines the list of defines
  26636. * @param lightIndex defines the index of the light for the effect
  26637. */
  26638. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. /** @hidden */
  26643. export var vrMultiviewToSingleviewPixelShader: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module BABYLON {
  26649. /**
  26650. * Renders to multiple views with a single draw call
  26651. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26652. */
  26653. export class MultiviewRenderTarget extends RenderTargetTexture {
  26654. /**
  26655. * Creates a multiview render target
  26656. * @param scene scene used with the render target
  26657. * @param size the size of the render target (used for each view)
  26658. */
  26659. constructor(scene: Scene, size?: number | {
  26660. width: number;
  26661. height: number;
  26662. } | {
  26663. ratio: number;
  26664. });
  26665. /**
  26666. * @hidden
  26667. * @param faceIndex the face index, if its a cube texture
  26668. */
  26669. _bindFrameBuffer(faceIndex?: number): void;
  26670. /**
  26671. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26672. * @returns the view count
  26673. */
  26674. getViewCount(): number;
  26675. }
  26676. }
  26677. declare module BABYLON {
  26678. interface Engine {
  26679. /**
  26680. * Creates a new multiview render target
  26681. * @param width defines the width of the texture
  26682. * @param height defines the height of the texture
  26683. * @returns the created multiview texture
  26684. */
  26685. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26686. /**
  26687. * Binds a multiview framebuffer to be drawn to
  26688. * @param multiviewTexture texture to bind
  26689. */
  26690. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26691. }
  26692. interface Camera {
  26693. /**
  26694. * @hidden
  26695. * 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)
  26696. */
  26697. _useMultiviewToSingleView: boolean;
  26698. /**
  26699. * @hidden
  26700. * 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)
  26701. */
  26702. _multiviewTexture: Nullable<RenderTargetTexture>;
  26703. /**
  26704. * @hidden
  26705. * ensures the multiview texture of the camera exists and has the specified width/height
  26706. * @param width height to set on the multiview texture
  26707. * @param height width to set on the multiview texture
  26708. */
  26709. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26710. }
  26711. interface Scene {
  26712. /** @hidden */
  26713. _transformMatrixR: Matrix;
  26714. /** @hidden */
  26715. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26716. /** @hidden */
  26717. _createMultiviewUbo(): void;
  26718. /** @hidden */
  26719. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26720. /** @hidden */
  26721. _renderMultiviewToSingleView(camera: Camera): void;
  26722. }
  26723. }
  26724. declare module BABYLON {
  26725. /**
  26726. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26727. * This will not be used for webXR as it supports displaying texture arrays directly
  26728. */
  26729. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26730. /**
  26731. * Gets a string identifying the name of the class
  26732. * @returns "VRMultiviewToSingleviewPostProcess" string
  26733. */
  26734. getClassName(): string;
  26735. /**
  26736. * Initializes a VRMultiviewToSingleview
  26737. * @param name name of the post process
  26738. * @param camera camera to be applied to
  26739. * @param scaleFactor scaling factor to the size of the output texture
  26740. */
  26741. constructor(name: string, camera: Camera, scaleFactor: number);
  26742. }
  26743. }
  26744. declare module BABYLON {
  26745. /**
  26746. * Interface used to define additional presentation attributes
  26747. */
  26748. export interface IVRPresentationAttributes {
  26749. /**
  26750. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26751. */
  26752. highRefreshRate: boolean;
  26753. /**
  26754. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26755. */
  26756. foveationLevel: number;
  26757. }
  26758. interface Engine {
  26759. /** @hidden */
  26760. _vrDisplay: any;
  26761. /** @hidden */
  26762. _vrSupported: boolean;
  26763. /** @hidden */
  26764. _oldSize: Size;
  26765. /** @hidden */
  26766. _oldHardwareScaleFactor: number;
  26767. /** @hidden */
  26768. _vrExclusivePointerMode: boolean;
  26769. /** @hidden */
  26770. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26771. /** @hidden */
  26772. _onVRDisplayPointerRestricted: () => void;
  26773. /** @hidden */
  26774. _onVRDisplayPointerUnrestricted: () => void;
  26775. /** @hidden */
  26776. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26777. /** @hidden */
  26778. _onVrDisplayDisconnect: Nullable<() => void>;
  26779. /** @hidden */
  26780. _onVrDisplayPresentChange: Nullable<() => void>;
  26781. /**
  26782. * Observable signaled when VR display mode changes
  26783. */
  26784. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26785. /**
  26786. * Observable signaled when VR request present is complete
  26787. */
  26788. onVRRequestPresentComplete: Observable<boolean>;
  26789. /**
  26790. * Observable signaled when VR request present starts
  26791. */
  26792. onVRRequestPresentStart: Observable<Engine>;
  26793. /**
  26794. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26795. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26796. */
  26797. isInVRExclusivePointerMode: boolean;
  26798. /**
  26799. * Gets a boolean indicating if a webVR device was detected
  26800. * @returns true if a webVR device was detected
  26801. */
  26802. isVRDevicePresent(): boolean;
  26803. /**
  26804. * Gets the current webVR device
  26805. * @returns the current webVR device (or null)
  26806. */
  26807. getVRDevice(): any;
  26808. /**
  26809. * Initializes a webVR display and starts listening to display change events
  26810. * The onVRDisplayChangedObservable will be notified upon these changes
  26811. * @returns A promise containing a VRDisplay and if vr is supported
  26812. */
  26813. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26814. /** @hidden */
  26815. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26816. /**
  26817. * Gets or sets the presentation attributes used to configure VR rendering
  26818. */
  26819. vrPresentationAttributes?: IVRPresentationAttributes;
  26820. /**
  26821. * Call this function to switch to webVR mode
  26822. * Will do nothing if webVR is not supported or if there is no webVR device
  26823. * @param options the webvr options provided to the camera. mainly used for multiview
  26824. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26825. */
  26826. enableVR(options: WebVROptions): void;
  26827. /** @hidden */
  26828. _onVRFullScreenTriggered(): void;
  26829. }
  26830. }
  26831. declare module BABYLON {
  26832. /**
  26833. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26834. * IMPORTANT!! The data is right-hand data.
  26835. * @export
  26836. * @interface DevicePose
  26837. */
  26838. export interface DevicePose {
  26839. /**
  26840. * The position of the device, values in array are [x,y,z].
  26841. */
  26842. readonly position: Nullable<Float32Array>;
  26843. /**
  26844. * The linearVelocity of the device, values in array are [x,y,z].
  26845. */
  26846. readonly linearVelocity: Nullable<Float32Array>;
  26847. /**
  26848. * The linearAcceleration of the device, values in array are [x,y,z].
  26849. */
  26850. readonly linearAcceleration: Nullable<Float32Array>;
  26851. /**
  26852. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26853. */
  26854. readonly orientation: Nullable<Float32Array>;
  26855. /**
  26856. * The angularVelocity of the device, values in array are [x,y,z].
  26857. */
  26858. readonly angularVelocity: Nullable<Float32Array>;
  26859. /**
  26860. * The angularAcceleration of the device, values in array are [x,y,z].
  26861. */
  26862. readonly angularAcceleration: Nullable<Float32Array>;
  26863. }
  26864. /**
  26865. * Interface representing a pose controlled object in Babylon.
  26866. * A pose controlled object has both regular pose values as well as pose values
  26867. * from an external device such as a VR head mounted display
  26868. */
  26869. export interface PoseControlled {
  26870. /**
  26871. * The position of the object in babylon space.
  26872. */
  26873. position: Vector3;
  26874. /**
  26875. * The rotation quaternion of the object in babylon space.
  26876. */
  26877. rotationQuaternion: Quaternion;
  26878. /**
  26879. * The position of the device in babylon space.
  26880. */
  26881. devicePosition?: Vector3;
  26882. /**
  26883. * The rotation quaternion of the device in babylon space.
  26884. */
  26885. deviceRotationQuaternion: Quaternion;
  26886. /**
  26887. * The raw pose coming from the device.
  26888. */
  26889. rawPose: Nullable<DevicePose>;
  26890. /**
  26891. * The scale of the device to be used when translating from device space to babylon space.
  26892. */
  26893. deviceScaleFactor: number;
  26894. /**
  26895. * Updates the poseControlled values based on the input device pose.
  26896. * @param poseData the pose data to update the object with
  26897. */
  26898. updateFromDevice(poseData: DevicePose): void;
  26899. }
  26900. /**
  26901. * Set of options to customize the webVRCamera
  26902. */
  26903. export interface WebVROptions {
  26904. /**
  26905. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26906. */
  26907. trackPosition?: boolean;
  26908. /**
  26909. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26910. */
  26911. positionScale?: number;
  26912. /**
  26913. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26914. */
  26915. displayName?: string;
  26916. /**
  26917. * Should the native controller meshes be initialized. (default: true)
  26918. */
  26919. controllerMeshes?: boolean;
  26920. /**
  26921. * Creating a default HemiLight only on controllers. (default: true)
  26922. */
  26923. defaultLightingOnControllers?: boolean;
  26924. /**
  26925. * If you don't want to use the default VR button of the helper. (default: false)
  26926. */
  26927. useCustomVRButton?: boolean;
  26928. /**
  26929. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26930. */
  26931. customVRButton?: HTMLButtonElement;
  26932. /**
  26933. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26934. */
  26935. rayLength?: number;
  26936. /**
  26937. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26938. */
  26939. defaultHeight?: number;
  26940. /**
  26941. * If multiview should be used if availible (default: false)
  26942. */
  26943. useMultiview?: boolean;
  26944. }
  26945. /**
  26946. * This represents a WebVR camera.
  26947. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26948. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26949. */
  26950. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26951. private webVROptions;
  26952. /**
  26953. * @hidden
  26954. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26955. */
  26956. _vrDevice: any;
  26957. /**
  26958. * The rawPose of the vrDevice.
  26959. */
  26960. rawPose: Nullable<DevicePose>;
  26961. private _onVREnabled;
  26962. private _specsVersion;
  26963. private _attached;
  26964. private _frameData;
  26965. protected _descendants: Array<Node>;
  26966. private _deviceRoomPosition;
  26967. /** @hidden */
  26968. _deviceRoomRotationQuaternion: Quaternion;
  26969. private _standingMatrix;
  26970. /**
  26971. * Represents device position in babylon space.
  26972. */
  26973. devicePosition: Vector3;
  26974. /**
  26975. * Represents device rotation in babylon space.
  26976. */
  26977. deviceRotationQuaternion: Quaternion;
  26978. /**
  26979. * The scale of the device to be used when translating from device space to babylon space.
  26980. */
  26981. deviceScaleFactor: number;
  26982. private _deviceToWorld;
  26983. private _worldToDevice;
  26984. /**
  26985. * References to the webVR controllers for the vrDevice.
  26986. */
  26987. controllers: Array<WebVRController>;
  26988. /**
  26989. * Emits an event when a controller is attached.
  26990. */
  26991. onControllersAttachedObservable: Observable<WebVRController[]>;
  26992. /**
  26993. * Emits an event when a controller's mesh has been loaded;
  26994. */
  26995. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26996. /**
  26997. * Emits an event when the HMD's pose has been updated.
  26998. */
  26999. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27000. private _poseSet;
  27001. /**
  27002. * If the rig cameras be used as parent instead of this camera.
  27003. */
  27004. rigParenting: boolean;
  27005. private _lightOnControllers;
  27006. private _defaultHeight?;
  27007. /**
  27008. * Instantiates a WebVRFreeCamera.
  27009. * @param name The name of the WebVRFreeCamera
  27010. * @param position The starting anchor position for the camera
  27011. * @param scene The scene the camera belongs to
  27012. * @param webVROptions a set of customizable options for the webVRCamera
  27013. */
  27014. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27015. /**
  27016. * Gets the device distance from the ground in meters.
  27017. * @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.
  27018. */
  27019. deviceDistanceToRoomGround(): number;
  27020. /**
  27021. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27022. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27023. */
  27024. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27025. /**
  27026. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27027. * @returns A promise with a boolean set to if the standing matrix is supported.
  27028. */
  27029. useStandingMatrixAsync(): Promise<boolean>;
  27030. /**
  27031. * Disposes the camera
  27032. */
  27033. dispose(): void;
  27034. /**
  27035. * Gets a vrController by name.
  27036. * @param name The name of the controller to retreive
  27037. * @returns the controller matching the name specified or null if not found
  27038. */
  27039. getControllerByName(name: string): Nullable<WebVRController>;
  27040. private _leftController;
  27041. /**
  27042. * The controller corresponding to the users left hand.
  27043. */
  27044. get leftController(): Nullable<WebVRController>;
  27045. private _rightController;
  27046. /**
  27047. * The controller corresponding to the users right hand.
  27048. */
  27049. get rightController(): Nullable<WebVRController>;
  27050. /**
  27051. * Casts a ray forward from the vrCamera's gaze.
  27052. * @param length Length of the ray (default: 100)
  27053. * @returns the ray corresponding to the gaze
  27054. */
  27055. getForwardRay(length?: number): Ray;
  27056. /**
  27057. * @hidden
  27058. * Updates the camera based on device's frame data
  27059. */
  27060. _checkInputs(): void;
  27061. /**
  27062. * Updates the poseControlled values based on the input device pose.
  27063. * @param poseData Pose coming from the device
  27064. */
  27065. updateFromDevice(poseData: DevicePose): void;
  27066. private _detachIfAttached;
  27067. /**
  27068. * WebVR's attach control will start broadcasting frames to the device.
  27069. * Note that in certain browsers (chrome for example) this function must be called
  27070. * within a user-interaction callback. Example:
  27071. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27072. *
  27073. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27074. */
  27075. attachControl(noPreventDefault?: boolean): void;
  27076. /**
  27077. * Detach the current controls from the specified dom element.
  27078. */
  27079. detachControl(): void;
  27080. /**
  27081. * @returns the name of this class
  27082. */
  27083. getClassName(): string;
  27084. /**
  27085. * Calls resetPose on the vrDisplay
  27086. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27087. */
  27088. resetToCurrentRotation(): void;
  27089. /**
  27090. * @hidden
  27091. * Updates the rig cameras (left and right eye)
  27092. */
  27093. _updateRigCameras(): void;
  27094. private _workingVector;
  27095. private _oneVector;
  27096. private _workingMatrix;
  27097. private updateCacheCalled;
  27098. private _correctPositionIfNotTrackPosition;
  27099. /**
  27100. * @hidden
  27101. * Updates the cached values of the camera
  27102. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27103. */
  27104. _updateCache(ignoreParentClass?: boolean): void;
  27105. /**
  27106. * @hidden
  27107. * Get current device position in babylon world
  27108. */
  27109. _computeDevicePosition(): void;
  27110. /**
  27111. * Updates the current device position and rotation in the babylon world
  27112. */
  27113. update(): void;
  27114. /**
  27115. * @hidden
  27116. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27117. * @returns an identity matrix
  27118. */
  27119. _getViewMatrix(): Matrix;
  27120. private _tmpMatrix;
  27121. /**
  27122. * This function is called by the two RIG cameras.
  27123. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27124. * @hidden
  27125. */
  27126. _getWebVRViewMatrix(): Matrix;
  27127. /** @hidden */
  27128. _getWebVRProjectionMatrix(): Matrix;
  27129. private _onGamepadConnectedObserver;
  27130. private _onGamepadDisconnectedObserver;
  27131. private _updateCacheWhenTrackingDisabledObserver;
  27132. /**
  27133. * Initializes the controllers and their meshes
  27134. */
  27135. initControllers(): void;
  27136. }
  27137. }
  27138. declare module BABYLON {
  27139. /**
  27140. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27141. *
  27142. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27143. *
  27144. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27145. */
  27146. export class MaterialHelper {
  27147. /**
  27148. * Bind the current view position to an effect.
  27149. * @param effect The effect to be bound
  27150. * @param scene The scene the eyes position is used from
  27151. * @param variableName name of the shader variable that will hold the eye position
  27152. */
  27153. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27154. /**
  27155. * Helps preparing the defines values about the UVs in used in the effect.
  27156. * UVs are shared as much as we can accross channels in the shaders.
  27157. * @param texture The texture we are preparing the UVs for
  27158. * @param defines The defines to update
  27159. * @param key The channel key "diffuse", "specular"... used in the shader
  27160. */
  27161. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27162. /**
  27163. * Binds a texture matrix value to its corrsponding uniform
  27164. * @param texture The texture to bind the matrix for
  27165. * @param uniformBuffer The uniform buffer receivin the data
  27166. * @param key The channel key "diffuse", "specular"... used in the shader
  27167. */
  27168. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27169. /**
  27170. * Gets the current status of the fog (should it be enabled?)
  27171. * @param mesh defines the mesh to evaluate for fog support
  27172. * @param scene defines the hosting scene
  27173. * @returns true if fog must be enabled
  27174. */
  27175. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27176. /**
  27177. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27178. * @param mesh defines the current mesh
  27179. * @param scene defines the current scene
  27180. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27181. * @param pointsCloud defines if point cloud rendering has to be turned on
  27182. * @param fogEnabled defines if fog has to be turned on
  27183. * @param alphaTest defines if alpha testing has to be turned on
  27184. * @param defines defines the current list of defines
  27185. */
  27186. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27187. /**
  27188. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27189. * @param scene defines the current scene
  27190. * @param engine defines the current engine
  27191. * @param defines specifies the list of active defines
  27192. * @param useInstances defines if instances have to be turned on
  27193. * @param useClipPlane defines if clip plane have to be turned on
  27194. * @param useInstances defines if instances have to be turned on
  27195. * @param useThinInstances defines if thin instances have to be turned on
  27196. */
  27197. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27198. /**
  27199. * Prepares the defines for bones
  27200. * @param mesh The mesh containing the geometry data we will draw
  27201. * @param defines The defines to update
  27202. */
  27203. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27204. /**
  27205. * Prepares the defines for morph targets
  27206. * @param mesh The mesh containing the geometry data we will draw
  27207. * @param defines The defines to update
  27208. */
  27209. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27210. /**
  27211. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27212. * @param mesh The mesh containing the geometry data we will draw
  27213. * @param defines The defines to update
  27214. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27215. * @param useBones Precise whether bones should be used or not (override mesh info)
  27216. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27217. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27218. * @returns false if defines are considered not dirty and have not been checked
  27219. */
  27220. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27221. /**
  27222. * Prepares the defines related to multiview
  27223. * @param scene The scene we are intending to draw
  27224. * @param defines The defines to update
  27225. */
  27226. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27227. /**
  27228. * Prepares the defines related to the prepass
  27229. * @param scene The scene we are intending to draw
  27230. * @param defines The defines to update
  27231. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27232. */
  27233. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27234. /**
  27235. * Prepares the defines related to the light information passed in parameter
  27236. * @param scene The scene we are intending to draw
  27237. * @param mesh The mesh the effect is compiling for
  27238. * @param light The light the effect is compiling for
  27239. * @param lightIndex The index of the light
  27240. * @param defines The defines to update
  27241. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27242. * @param state Defines the current state regarding what is needed (normals, etc...)
  27243. */
  27244. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27245. needNormals: boolean;
  27246. needRebuild: boolean;
  27247. shadowEnabled: boolean;
  27248. specularEnabled: boolean;
  27249. lightmapMode: boolean;
  27250. }): void;
  27251. /**
  27252. * Prepares the defines related to the light information passed in parameter
  27253. * @param scene The scene we are intending to draw
  27254. * @param mesh The mesh the effect is compiling for
  27255. * @param defines The defines to update
  27256. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27257. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27258. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27259. * @returns true if normals will be required for the rest of the effect
  27260. */
  27261. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27262. /**
  27263. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27264. * @param lightIndex defines the light index
  27265. * @param uniformsList The uniform list
  27266. * @param samplersList The sampler list
  27267. * @param projectedLightTexture defines if projected texture must be used
  27268. * @param uniformBuffersList defines an optional list of uniform buffers
  27269. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27270. */
  27271. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27272. /**
  27273. * Prepares the uniforms and samplers list to be used in the effect
  27274. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27275. * @param samplersList The sampler list
  27276. * @param defines The defines helping in the list generation
  27277. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27278. */
  27279. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27280. /**
  27281. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27282. * @param defines The defines to update while falling back
  27283. * @param fallbacks The authorized effect fallbacks
  27284. * @param maxSimultaneousLights The maximum number of lights allowed
  27285. * @param rank the current rank of the Effect
  27286. * @returns The newly affected rank
  27287. */
  27288. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27289. private static _TmpMorphInfluencers;
  27290. /**
  27291. * Prepares the list of attributes required for morph targets according to the effect defines.
  27292. * @param attribs The current list of supported attribs
  27293. * @param mesh The mesh to prepare the morph targets attributes for
  27294. * @param influencers The number of influencers
  27295. */
  27296. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27297. /**
  27298. * Prepares the list of attributes required for morph targets according to the effect defines.
  27299. * @param attribs The current list of supported attribs
  27300. * @param mesh The mesh to prepare the morph targets attributes for
  27301. * @param defines The current Defines of the effect
  27302. */
  27303. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27304. /**
  27305. * Prepares the list of attributes required for bones according to the effect defines.
  27306. * @param attribs The current list of supported attribs
  27307. * @param mesh The mesh to prepare the bones attributes for
  27308. * @param defines The current Defines of the effect
  27309. * @param fallbacks The current efffect fallback strategy
  27310. */
  27311. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27312. /**
  27313. * Check and prepare the list of attributes required for instances according to the effect defines.
  27314. * @param attribs The current list of supported attribs
  27315. * @param defines The current MaterialDefines of the effect
  27316. */
  27317. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27318. /**
  27319. * Add the list of attributes required for instances to the attribs array.
  27320. * @param attribs The current list of supported attribs
  27321. */
  27322. static PushAttributesForInstances(attribs: string[]): void;
  27323. /**
  27324. * Binds the light information to the effect.
  27325. * @param light The light containing the generator
  27326. * @param effect The effect we are binding the data to
  27327. * @param lightIndex The light index in the effect used to render
  27328. */
  27329. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27330. /**
  27331. * Binds the lights information from the scene to the effect for the given mesh.
  27332. * @param light Light to bind
  27333. * @param lightIndex Light index
  27334. * @param scene The scene where the light belongs to
  27335. * @param effect The effect we are binding the data to
  27336. * @param useSpecular Defines if specular is supported
  27337. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27338. */
  27339. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27340. /**
  27341. * Binds the lights information from the scene to the effect for the given mesh.
  27342. * @param scene The scene the lights belongs to
  27343. * @param mesh The mesh we are binding the information to render
  27344. * @param effect The effect we are binding the data to
  27345. * @param defines The generated defines for the effect
  27346. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27347. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27348. */
  27349. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27350. private static _tempFogColor;
  27351. /**
  27352. * Binds the fog information from the scene to the effect for the given mesh.
  27353. * @param scene The scene the lights belongs to
  27354. * @param mesh The mesh we are binding the information to render
  27355. * @param effect The effect we are binding the data to
  27356. * @param linearSpace Defines if the fog effect is applied in linear space
  27357. */
  27358. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27359. /**
  27360. * Binds the bones information from the mesh to the effect.
  27361. * @param mesh The mesh we are binding the information to render
  27362. * @param effect The effect we are binding the data to
  27363. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27364. */
  27365. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27366. private static _CopyBonesTransformationMatrices;
  27367. /**
  27368. * Binds the morph targets information from the mesh to the effect.
  27369. * @param abstractMesh The mesh we are binding the information to render
  27370. * @param effect The effect we are binding the data to
  27371. */
  27372. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27373. /**
  27374. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27375. * @param defines The generated defines used in the effect
  27376. * @param effect The effect we are binding the data to
  27377. * @param scene The scene we are willing to render with logarithmic scale for
  27378. */
  27379. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27380. /**
  27381. * Binds the clip plane information from the scene to the effect.
  27382. * @param scene The scene the clip plane information are extracted from
  27383. * @param effect The effect we are binding the data to
  27384. */
  27385. static BindClipPlane(effect: Effect, scene: Scene): void;
  27386. }
  27387. }
  27388. declare module BABYLON {
  27389. /** @hidden */
  27390. export var bayerDitherFunctions: {
  27391. name: string;
  27392. shader: string;
  27393. };
  27394. }
  27395. declare module BABYLON {
  27396. /** @hidden */
  27397. export var shadowMapFragmentDeclaration: {
  27398. name: string;
  27399. shader: string;
  27400. };
  27401. }
  27402. declare module BABYLON {
  27403. /** @hidden */
  27404. export var shadowMapFragment: {
  27405. name: string;
  27406. shader: string;
  27407. };
  27408. }
  27409. declare module BABYLON {
  27410. /** @hidden */
  27411. export var shadowMapPixelShader: {
  27412. name: string;
  27413. shader: string;
  27414. };
  27415. }
  27416. declare module BABYLON {
  27417. /** @hidden */
  27418. export var shadowMapVertexDeclaration: {
  27419. name: string;
  27420. shader: string;
  27421. };
  27422. }
  27423. declare module BABYLON {
  27424. /** @hidden */
  27425. export var shadowMapVertexNormalBias: {
  27426. name: string;
  27427. shader: string;
  27428. };
  27429. }
  27430. declare module BABYLON {
  27431. /** @hidden */
  27432. export var shadowMapVertexMetric: {
  27433. name: string;
  27434. shader: string;
  27435. };
  27436. }
  27437. declare module BABYLON {
  27438. /** @hidden */
  27439. export var shadowMapVertexShader: {
  27440. name: string;
  27441. shader: string;
  27442. };
  27443. }
  27444. declare module BABYLON {
  27445. /** @hidden */
  27446. export var depthBoxBlurPixelShader: {
  27447. name: string;
  27448. shader: string;
  27449. };
  27450. }
  27451. declare module BABYLON {
  27452. /** @hidden */
  27453. export var shadowMapFragmentSoftTransparentShadow: {
  27454. name: string;
  27455. shader: string;
  27456. };
  27457. }
  27458. declare module BABYLON {
  27459. /**
  27460. * Creates an instance based on a source mesh.
  27461. */
  27462. export class InstancedMesh extends AbstractMesh {
  27463. private _sourceMesh;
  27464. private _currentLOD;
  27465. /** @hidden */
  27466. _indexInSourceMeshInstanceArray: number;
  27467. constructor(name: string, source: Mesh);
  27468. /**
  27469. * Returns the string "InstancedMesh".
  27470. */
  27471. getClassName(): string;
  27472. /** Gets the list of lights affecting that mesh */
  27473. get lightSources(): Light[];
  27474. _resyncLightSources(): void;
  27475. _resyncLightSource(light: Light): void;
  27476. _removeLightSource(light: Light, dispose: boolean): void;
  27477. /**
  27478. * If the source mesh receives shadows
  27479. */
  27480. get receiveShadows(): boolean;
  27481. /**
  27482. * The material of the source mesh
  27483. */
  27484. get material(): Nullable<Material>;
  27485. /**
  27486. * Visibility of the source mesh
  27487. */
  27488. get visibility(): number;
  27489. /**
  27490. * Skeleton of the source mesh
  27491. */
  27492. get skeleton(): Nullable<Skeleton>;
  27493. /**
  27494. * Rendering ground id of the source mesh
  27495. */
  27496. get renderingGroupId(): number;
  27497. set renderingGroupId(value: number);
  27498. /**
  27499. * Returns the total number of vertices (integer).
  27500. */
  27501. getTotalVertices(): number;
  27502. /**
  27503. * Returns a positive integer : the total number of indices in this mesh geometry.
  27504. * @returns the numner of indices or zero if the mesh has no geometry.
  27505. */
  27506. getTotalIndices(): number;
  27507. /**
  27508. * The source mesh of the instance
  27509. */
  27510. get sourceMesh(): Mesh;
  27511. /**
  27512. * Creates a new InstancedMesh object from the mesh model.
  27513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27514. * @param name defines the name of the new instance
  27515. * @returns a new InstancedMesh
  27516. */
  27517. createInstance(name: string): InstancedMesh;
  27518. /**
  27519. * Is this node ready to be used/rendered
  27520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27521. * @return {boolean} is it ready
  27522. */
  27523. isReady(completeCheck?: boolean): boolean;
  27524. /**
  27525. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27526. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27527. * @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.
  27528. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27529. */
  27530. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27531. /**
  27532. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27533. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27534. * The `data` are either a numeric array either a Float32Array.
  27535. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27536. * 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).
  27537. * Note that a new underlying VertexBuffer object is created each call.
  27538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27539. *
  27540. * Possible `kind` values :
  27541. * - VertexBuffer.PositionKind
  27542. * - VertexBuffer.UVKind
  27543. * - VertexBuffer.UV2Kind
  27544. * - VertexBuffer.UV3Kind
  27545. * - VertexBuffer.UV4Kind
  27546. * - VertexBuffer.UV5Kind
  27547. * - VertexBuffer.UV6Kind
  27548. * - VertexBuffer.ColorKind
  27549. * - VertexBuffer.MatricesIndicesKind
  27550. * - VertexBuffer.MatricesIndicesExtraKind
  27551. * - VertexBuffer.MatricesWeightsKind
  27552. * - VertexBuffer.MatricesWeightsExtraKind
  27553. *
  27554. * Returns the Mesh.
  27555. */
  27556. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27557. /**
  27558. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27559. * If the mesh has no geometry, it is simply returned as it is.
  27560. * The `data` are either a numeric array either a Float32Array.
  27561. * No new underlying VertexBuffer object is created.
  27562. * 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.
  27563. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27564. *
  27565. * Possible `kind` values :
  27566. * - VertexBuffer.PositionKind
  27567. * - VertexBuffer.UVKind
  27568. * - VertexBuffer.UV2Kind
  27569. * - VertexBuffer.UV3Kind
  27570. * - VertexBuffer.UV4Kind
  27571. * - VertexBuffer.UV5Kind
  27572. * - VertexBuffer.UV6Kind
  27573. * - VertexBuffer.ColorKind
  27574. * - VertexBuffer.MatricesIndicesKind
  27575. * - VertexBuffer.MatricesIndicesExtraKind
  27576. * - VertexBuffer.MatricesWeightsKind
  27577. * - VertexBuffer.MatricesWeightsExtraKind
  27578. *
  27579. * Returns the Mesh.
  27580. */
  27581. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27582. /**
  27583. * Sets the mesh indices.
  27584. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27585. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27586. * This method creates a new index buffer each call.
  27587. * Returns the Mesh.
  27588. */
  27589. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27590. /**
  27591. * Boolean : True if the mesh owns the requested kind of data.
  27592. */
  27593. isVerticesDataPresent(kind: string): boolean;
  27594. /**
  27595. * Returns an array of indices (IndicesArray).
  27596. */
  27597. getIndices(): Nullable<IndicesArray>;
  27598. get _positions(): Nullable<Vector3[]>;
  27599. /**
  27600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27601. * This means the mesh underlying bounding box and sphere are recomputed.
  27602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27603. * @returns the current mesh
  27604. */
  27605. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27606. /** @hidden */
  27607. _preActivate(): InstancedMesh;
  27608. /** @hidden */
  27609. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27610. /** @hidden */
  27611. _postActivate(): void;
  27612. getWorldMatrix(): Matrix;
  27613. get isAnInstance(): boolean;
  27614. /**
  27615. * Returns the current associated LOD AbstractMesh.
  27616. */
  27617. getLOD(camera: Camera): AbstractMesh;
  27618. /** @hidden */
  27619. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27620. /** @hidden */
  27621. _syncSubMeshes(): InstancedMesh;
  27622. /** @hidden */
  27623. _generatePointsArray(): boolean;
  27624. /** @hidden */
  27625. _updateBoundingInfo(): AbstractMesh;
  27626. /**
  27627. * Creates a new InstancedMesh from the current mesh.
  27628. * - name (string) : the cloned mesh name
  27629. * - newParent (optional Node) : the optional Node to parent the clone to.
  27630. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27631. *
  27632. * Returns the clone.
  27633. */
  27634. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27635. /**
  27636. * Disposes the InstancedMesh.
  27637. * Returns nothing.
  27638. */
  27639. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27640. }
  27641. interface Mesh {
  27642. /**
  27643. * Register a custom buffer that will be instanced
  27644. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27645. * @param kind defines the buffer kind
  27646. * @param stride defines the stride in floats
  27647. */
  27648. registerInstancedBuffer(kind: string, stride: number): void;
  27649. /**
  27650. * true to use the edge renderer for all instances of this mesh
  27651. */
  27652. edgesShareWithInstances: boolean;
  27653. /** @hidden */
  27654. _userInstancedBuffersStorage: {
  27655. data: {
  27656. [key: string]: Float32Array;
  27657. };
  27658. sizes: {
  27659. [key: string]: number;
  27660. };
  27661. vertexBuffers: {
  27662. [key: string]: Nullable<VertexBuffer>;
  27663. };
  27664. strides: {
  27665. [key: string]: number;
  27666. };
  27667. };
  27668. }
  27669. interface AbstractMesh {
  27670. /**
  27671. * Object used to store instanced buffers defined by user
  27672. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27673. */
  27674. instancedBuffers: {
  27675. [key: string]: any;
  27676. };
  27677. }
  27678. }
  27679. declare module BABYLON {
  27680. /**
  27681. * Defines the options associated with the creation of a shader material.
  27682. */
  27683. export interface IShaderMaterialOptions {
  27684. /**
  27685. * Does the material work in alpha blend mode
  27686. */
  27687. needAlphaBlending: boolean;
  27688. /**
  27689. * Does the material work in alpha test mode
  27690. */
  27691. needAlphaTesting: boolean;
  27692. /**
  27693. * The list of attribute names used in the shader
  27694. */
  27695. attributes: string[];
  27696. /**
  27697. * The list of unifrom names used in the shader
  27698. */
  27699. uniforms: string[];
  27700. /**
  27701. * The list of UBO names used in the shader
  27702. */
  27703. uniformBuffers: string[];
  27704. /**
  27705. * The list of sampler names used in the shader
  27706. */
  27707. samplers: string[];
  27708. /**
  27709. * The list of defines used in the shader
  27710. */
  27711. defines: string[];
  27712. }
  27713. /**
  27714. * 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.
  27715. *
  27716. * This returned material effects how the mesh will look based on the code in the shaders.
  27717. *
  27718. * @see https://doc.babylonjs.com/how_to/shader_material
  27719. */
  27720. export class ShaderMaterial extends Material {
  27721. private _shaderPath;
  27722. private _options;
  27723. private _textures;
  27724. private _textureArrays;
  27725. private _floats;
  27726. private _ints;
  27727. private _floatsArrays;
  27728. private _colors3;
  27729. private _colors3Arrays;
  27730. private _colors4;
  27731. private _colors4Arrays;
  27732. private _vectors2;
  27733. private _vectors3;
  27734. private _vectors4;
  27735. private _matrices;
  27736. private _matrixArrays;
  27737. private _matrices3x3;
  27738. private _matrices2x2;
  27739. private _vectors2Arrays;
  27740. private _vectors3Arrays;
  27741. private _vectors4Arrays;
  27742. private _cachedWorldViewMatrix;
  27743. private _cachedWorldViewProjectionMatrix;
  27744. private _renderId;
  27745. private _multiview;
  27746. private _cachedDefines;
  27747. /** Define the Url to load snippets */
  27748. static SnippetUrl: string;
  27749. /** Snippet ID if the material was created from the snippet server */
  27750. snippetId: string;
  27751. /**
  27752. * Instantiate a new shader material.
  27753. * 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.
  27754. * This returned material effects how the mesh will look based on the code in the shaders.
  27755. * @see https://doc.babylonjs.com/how_to/shader_material
  27756. * @param name Define the name of the material in the scene
  27757. * @param scene Define the scene the material belongs to
  27758. * @param shaderPath Defines the route to the shader code in one of three ways:
  27759. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27760. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27761. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27762. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27763. * @param options Define the options used to create the shader
  27764. */
  27765. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27766. /**
  27767. * Gets the shader path used to define the shader code
  27768. * It can be modified to trigger a new compilation
  27769. */
  27770. get shaderPath(): any;
  27771. /**
  27772. * Sets the shader path used to define the shader code
  27773. * It can be modified to trigger a new compilation
  27774. */
  27775. set shaderPath(shaderPath: any);
  27776. /**
  27777. * Gets the options used to compile the shader.
  27778. * They can be modified to trigger a new compilation
  27779. */
  27780. get options(): IShaderMaterialOptions;
  27781. /**
  27782. * Gets the current class name of the material e.g. "ShaderMaterial"
  27783. * Mainly use in serialization.
  27784. * @returns the class name
  27785. */
  27786. getClassName(): string;
  27787. /**
  27788. * Specifies if the material will require alpha blending
  27789. * @returns a boolean specifying if alpha blending is needed
  27790. */
  27791. needAlphaBlending(): boolean;
  27792. /**
  27793. * Specifies if this material should be rendered in alpha test mode
  27794. * @returns a boolean specifying if an alpha test is needed.
  27795. */
  27796. needAlphaTesting(): boolean;
  27797. private _checkUniform;
  27798. /**
  27799. * Set a texture in the shader.
  27800. * @param name Define the name of the uniform samplers as defined in the shader
  27801. * @param texture Define the texture to bind to this sampler
  27802. * @return the material itself allowing "fluent" like uniform updates
  27803. */
  27804. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27805. /**
  27806. * Set a texture array in the shader.
  27807. * @param name Define the name of the uniform sampler array as defined in the shader
  27808. * @param textures Define the list of textures to bind to this sampler
  27809. * @return the material itself allowing "fluent" like uniform updates
  27810. */
  27811. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27812. /**
  27813. * Set a float in the shader.
  27814. * @param name Define the name of the uniform as defined in the shader
  27815. * @param value Define the value to give to the uniform
  27816. * @return the material itself allowing "fluent" like uniform updates
  27817. */
  27818. setFloat(name: string, value: number): ShaderMaterial;
  27819. /**
  27820. * Set a int in the shader.
  27821. * @param name Define the name of the uniform as defined in the shader
  27822. * @param value Define the value to give to the uniform
  27823. * @return the material itself allowing "fluent" like uniform updates
  27824. */
  27825. setInt(name: string, value: number): ShaderMaterial;
  27826. /**
  27827. * Set an array of floats in the shader.
  27828. * @param name Define the name of the uniform as defined in the shader
  27829. * @param value Define the value to give to the uniform
  27830. * @return the material itself allowing "fluent" like uniform updates
  27831. */
  27832. setFloats(name: string, value: number[]): ShaderMaterial;
  27833. /**
  27834. * Set a vec3 in the shader from a Color3.
  27835. * @param name Define the name of the uniform as defined in the shader
  27836. * @param value Define the value to give to the uniform
  27837. * @return the material itself allowing "fluent" like uniform updates
  27838. */
  27839. setColor3(name: string, value: Color3): ShaderMaterial;
  27840. /**
  27841. * Set a vec3 array in the shader from a Color3 array.
  27842. * @param name Define the name of the uniform as defined in the shader
  27843. * @param value Define the value to give to the uniform
  27844. * @return the material itself allowing "fluent" like uniform updates
  27845. */
  27846. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27847. /**
  27848. * Set a vec4 in the shader from a Color4.
  27849. * @param name Define the name of the uniform as defined in the shader
  27850. * @param value Define the value to give to the uniform
  27851. * @return the material itself allowing "fluent" like uniform updates
  27852. */
  27853. setColor4(name: string, value: Color4): ShaderMaterial;
  27854. /**
  27855. * Set a vec4 array in the shader from a Color4 array.
  27856. * @param name Define the name of the uniform as defined in the shader
  27857. * @param value Define the value to give to the uniform
  27858. * @return the material itself allowing "fluent" like uniform updates
  27859. */
  27860. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27861. /**
  27862. * Set a vec2 in the shader from a Vector2.
  27863. * @param name Define the name of the uniform as defined in the shader
  27864. * @param value Define the value to give to the uniform
  27865. * @return the material itself allowing "fluent" like uniform updates
  27866. */
  27867. setVector2(name: string, value: Vector2): ShaderMaterial;
  27868. /**
  27869. * Set a vec3 in the shader from a Vector3.
  27870. * @param name Define the name of the uniform as defined in the shader
  27871. * @param value Define the value to give to the uniform
  27872. * @return the material itself allowing "fluent" like uniform updates
  27873. */
  27874. setVector3(name: string, value: Vector3): ShaderMaterial;
  27875. /**
  27876. * Set a vec4 in the shader from a Vector4.
  27877. * @param name Define the name of the uniform as defined in the shader
  27878. * @param value Define the value to give to the uniform
  27879. * @return the material itself allowing "fluent" like uniform updates
  27880. */
  27881. setVector4(name: string, value: Vector4): ShaderMaterial;
  27882. /**
  27883. * Set a mat4 in the shader from a Matrix.
  27884. * @param name Define the name of the uniform as defined in the shader
  27885. * @param value Define the value to give to the uniform
  27886. * @return the material itself allowing "fluent" like uniform updates
  27887. */
  27888. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27889. /**
  27890. * Set a float32Array in the shader from a matrix array.
  27891. * @param name Define the name of the uniform as defined in the shader
  27892. * @param value Define the value to give to the uniform
  27893. * @return the material itself allowing "fluent" like uniform updates
  27894. */
  27895. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27896. /**
  27897. * Set a mat3 in the shader from a Float32Array.
  27898. * @param name Define the name of the uniform as defined in the shader
  27899. * @param value Define the value to give to the uniform
  27900. * @return the material itself allowing "fluent" like uniform updates
  27901. */
  27902. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27903. /**
  27904. * Set a mat2 in the shader from a Float32Array.
  27905. * @param name Define the name of the uniform as defined in the shader
  27906. * @param value Define the value to give to the uniform
  27907. * @return the material itself allowing "fluent" like uniform updates
  27908. */
  27909. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27910. /**
  27911. * Set a vec2 array in the shader from a number array.
  27912. * @param name Define the name of the uniform as defined in the shader
  27913. * @param value Define the value to give to the uniform
  27914. * @return the material itself allowing "fluent" like uniform updates
  27915. */
  27916. setArray2(name: string, value: number[]): ShaderMaterial;
  27917. /**
  27918. * Set a vec3 array in the shader from a number array.
  27919. * @param name Define the name of the uniform as defined in the shader
  27920. * @param value Define the value to give to the uniform
  27921. * @return the material itself allowing "fluent" like uniform updates
  27922. */
  27923. setArray3(name: string, value: number[]): ShaderMaterial;
  27924. /**
  27925. * Set a vec4 array in the shader from a number array.
  27926. * @param name Define the name of the uniform as defined in the shader
  27927. * @param value Define the value to give to the uniform
  27928. * @return the material itself allowing "fluent" like uniform updates
  27929. */
  27930. setArray4(name: string, value: number[]): ShaderMaterial;
  27931. private _checkCache;
  27932. /**
  27933. * Specifies that the submesh is ready to be used
  27934. * @param mesh defines the mesh to check
  27935. * @param subMesh defines which submesh to check
  27936. * @param useInstances specifies that instances should be used
  27937. * @returns a boolean indicating that the submesh is ready or not
  27938. */
  27939. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27940. /**
  27941. * Checks if the material is ready to render the requested mesh
  27942. * @param mesh Define the mesh to render
  27943. * @param useInstances Define whether or not the material is used with instances
  27944. * @returns true if ready, otherwise false
  27945. */
  27946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27947. /**
  27948. * Binds the world matrix to the material
  27949. * @param world defines the world transformation matrix
  27950. * @param effectOverride - If provided, use this effect instead of internal effect
  27951. */
  27952. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27953. /**
  27954. * Binds the submesh to this material by preparing the effect and shader to draw
  27955. * @param world defines the world transformation matrix
  27956. * @param mesh defines the mesh containing the submesh
  27957. * @param subMesh defines the submesh to bind the material to
  27958. */
  27959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27960. /**
  27961. * Binds the material to the mesh
  27962. * @param world defines the world transformation matrix
  27963. * @param mesh defines the mesh to bind the material to
  27964. * @param effectOverride - If provided, use this effect instead of internal effect
  27965. */
  27966. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27967. protected _afterBind(mesh?: Mesh): void;
  27968. /**
  27969. * Gets the active textures from the material
  27970. * @returns an array of textures
  27971. */
  27972. getActiveTextures(): BaseTexture[];
  27973. /**
  27974. * Specifies if the material uses a texture
  27975. * @param texture defines the texture to check against the material
  27976. * @returns a boolean specifying if the material uses the texture
  27977. */
  27978. hasTexture(texture: BaseTexture): boolean;
  27979. /**
  27980. * Makes a duplicate of the material, and gives it a new name
  27981. * @param name defines the new name for the duplicated material
  27982. * @returns the cloned material
  27983. */
  27984. clone(name: string): ShaderMaterial;
  27985. /**
  27986. * Disposes the material
  27987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27989. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27990. */
  27991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27992. /**
  27993. * Serializes this material in a JSON representation
  27994. * @returns the serialized material object
  27995. */
  27996. serialize(): any;
  27997. /**
  27998. * Creates a shader material from parsed shader material data
  27999. * @param source defines the JSON represnetation of the material
  28000. * @param scene defines the hosting scene
  28001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28002. * @returns a new material
  28003. */
  28004. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28005. /**
  28006. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28007. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28008. * @param url defines the url to load from
  28009. * @param scene defines the hosting scene
  28010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28011. * @returns a promise that will resolve to the new ShaderMaterial
  28012. */
  28013. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28014. /**
  28015. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28016. * @param snippetId defines the snippet to load
  28017. * @param scene defines the hosting scene
  28018. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28019. * @returns a promise that will resolve to the new ShaderMaterial
  28020. */
  28021. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28022. }
  28023. }
  28024. declare module BABYLON {
  28025. /** @hidden */
  28026. export var colorPixelShader: {
  28027. name: string;
  28028. shader: string;
  28029. };
  28030. }
  28031. declare module BABYLON {
  28032. /** @hidden */
  28033. export var colorVertexShader: {
  28034. name: string;
  28035. shader: string;
  28036. };
  28037. }
  28038. declare module BABYLON {
  28039. /**
  28040. * Line mesh
  28041. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28042. */
  28043. export class LinesMesh extends Mesh {
  28044. /**
  28045. * If vertex color should be applied to the mesh
  28046. */
  28047. readonly useVertexColor?: boolean | undefined;
  28048. /**
  28049. * If vertex alpha should be applied to the mesh
  28050. */
  28051. readonly useVertexAlpha?: boolean | undefined;
  28052. /**
  28053. * Color of the line (Default: White)
  28054. */
  28055. color: Color3;
  28056. /**
  28057. * Alpha of the line (Default: 1)
  28058. */
  28059. alpha: number;
  28060. /**
  28061. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28062. * This margin is expressed in world space coordinates, so its value may vary.
  28063. * Default value is 0.1
  28064. */
  28065. intersectionThreshold: number;
  28066. private _colorShader;
  28067. private color4;
  28068. /**
  28069. * Creates a new LinesMesh
  28070. * @param name defines the name
  28071. * @param scene defines the hosting scene
  28072. * @param parent defines the parent mesh if any
  28073. * @param source defines the optional source LinesMesh used to clone data from
  28074. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28075. * When false, achieved by calling a clone(), also passing False.
  28076. * This will make creation of children, recursive.
  28077. * @param useVertexColor defines if this LinesMesh supports vertex color
  28078. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28079. */
  28080. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28081. /**
  28082. * If vertex color should be applied to the mesh
  28083. */
  28084. useVertexColor?: boolean | undefined,
  28085. /**
  28086. * If vertex alpha should be applied to the mesh
  28087. */
  28088. useVertexAlpha?: boolean | undefined);
  28089. private _addClipPlaneDefine;
  28090. private _removeClipPlaneDefine;
  28091. isReady(): boolean;
  28092. /**
  28093. * Returns the string "LineMesh"
  28094. */
  28095. getClassName(): string;
  28096. /**
  28097. * @hidden
  28098. */
  28099. get material(): Material;
  28100. /**
  28101. * @hidden
  28102. */
  28103. set material(value: Material);
  28104. /**
  28105. * @hidden
  28106. */
  28107. get checkCollisions(): boolean;
  28108. /** @hidden */
  28109. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28110. /** @hidden */
  28111. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28112. /**
  28113. * Disposes of the line mesh
  28114. * @param doNotRecurse If children should be disposed
  28115. */
  28116. dispose(doNotRecurse?: boolean): void;
  28117. /**
  28118. * Returns a new LineMesh object cloned from the current one.
  28119. */
  28120. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28121. /**
  28122. * Creates a new InstancedLinesMesh object from the mesh model.
  28123. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28124. * @param name defines the name of the new instance
  28125. * @returns a new InstancedLinesMesh
  28126. */
  28127. createInstance(name: string): InstancedLinesMesh;
  28128. }
  28129. /**
  28130. * Creates an instance based on a source LinesMesh
  28131. */
  28132. export class InstancedLinesMesh extends InstancedMesh {
  28133. /**
  28134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28135. * This margin is expressed in world space coordinates, so its value may vary.
  28136. * Initilized with the intersectionThreshold value of the source LinesMesh
  28137. */
  28138. intersectionThreshold: number;
  28139. constructor(name: string, source: LinesMesh);
  28140. /**
  28141. * Returns the string "InstancedLinesMesh".
  28142. */
  28143. getClassName(): string;
  28144. }
  28145. }
  28146. declare module BABYLON {
  28147. /** @hidden */
  28148. export var linePixelShader: {
  28149. name: string;
  28150. shader: string;
  28151. };
  28152. }
  28153. declare module BABYLON {
  28154. /** @hidden */
  28155. export var lineVertexShader: {
  28156. name: string;
  28157. shader: string;
  28158. };
  28159. }
  28160. declare module BABYLON {
  28161. interface Scene {
  28162. /** @hidden */
  28163. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28164. }
  28165. interface AbstractMesh {
  28166. /**
  28167. * Gets the edgesRenderer associated with the mesh
  28168. */
  28169. edgesRenderer: Nullable<EdgesRenderer>;
  28170. }
  28171. interface LinesMesh {
  28172. /**
  28173. * Enables the edge rendering mode on the mesh.
  28174. * This mode makes the mesh edges visible
  28175. * @param epsilon defines the maximal distance between two angles to detect a face
  28176. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28177. * @returns the currentAbstractMesh
  28178. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28179. */
  28180. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28181. }
  28182. interface InstancedLinesMesh {
  28183. /**
  28184. * Enables the edge rendering mode on the mesh.
  28185. * This mode makes the mesh edges visible
  28186. * @param epsilon defines the maximal distance between two angles to detect a face
  28187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28188. * @returns the current InstancedLinesMesh
  28189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28190. */
  28191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28192. }
  28193. /**
  28194. * Defines the minimum contract an Edges renderer should follow.
  28195. */
  28196. export interface IEdgesRenderer extends IDisposable {
  28197. /**
  28198. * Gets or sets a boolean indicating if the edgesRenderer is active
  28199. */
  28200. isEnabled: boolean;
  28201. /**
  28202. * Renders the edges of the attached mesh,
  28203. */
  28204. render(): void;
  28205. /**
  28206. * Checks wether or not the edges renderer is ready to render.
  28207. * @return true if ready, otherwise false.
  28208. */
  28209. isReady(): boolean;
  28210. /**
  28211. * List of instances to render in case the source mesh has instances
  28212. */
  28213. customInstances: SmartArray<Matrix>;
  28214. }
  28215. /**
  28216. * Defines the additional options of the edges renderer
  28217. */
  28218. export interface IEdgesRendererOptions {
  28219. /**
  28220. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28221. * If not defined, the default value is true
  28222. */
  28223. useAlternateEdgeFinder?: boolean;
  28224. /**
  28225. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28226. * If not defined, the default value is true.
  28227. * 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)
  28228. * This option is used only if useAlternateEdgeFinder = true
  28229. */
  28230. useFastVertexMerger?: boolean;
  28231. /**
  28232. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28233. * The default value is 1e-6
  28234. * This option is used only if useAlternateEdgeFinder = true
  28235. */
  28236. epsilonVertexMerge?: number;
  28237. /**
  28238. * 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
  28239. * 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.
  28240. * This option is used only if useAlternateEdgeFinder = true
  28241. */
  28242. applyTessellation?: boolean;
  28243. /**
  28244. * 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
  28245. * The default value is 1e-6
  28246. * This option is used only if useAlternateEdgeFinder = true
  28247. */
  28248. epsilonVertexAligned?: number;
  28249. }
  28250. /**
  28251. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28252. */
  28253. export class EdgesRenderer implements IEdgesRenderer {
  28254. /**
  28255. * Define the size of the edges with an orthographic camera
  28256. */
  28257. edgesWidthScalerForOrthographic: number;
  28258. /**
  28259. * Define the size of the edges with a perspective camera
  28260. */
  28261. edgesWidthScalerForPerspective: number;
  28262. protected _source: AbstractMesh;
  28263. protected _linesPositions: number[];
  28264. protected _linesNormals: number[];
  28265. protected _linesIndices: number[];
  28266. protected _epsilon: number;
  28267. protected _indicesCount: number;
  28268. protected _lineShader: ShaderMaterial;
  28269. protected _ib: DataBuffer;
  28270. protected _buffers: {
  28271. [key: string]: Nullable<VertexBuffer>;
  28272. };
  28273. protected _buffersForInstances: {
  28274. [key: string]: Nullable<VertexBuffer>;
  28275. };
  28276. protected _checkVerticesInsteadOfIndices: boolean;
  28277. protected _options: Nullable<IEdgesRendererOptions>;
  28278. private _meshRebuildObserver;
  28279. private _meshDisposeObserver;
  28280. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28281. isEnabled: boolean;
  28282. /** Gets the vertices generated by the edge renderer */
  28283. get linesPositions(): Immutable<Array<number>>;
  28284. /** Gets the normals generated by the edge renderer */
  28285. get linesNormals(): Immutable<Array<number>>;
  28286. /** Gets the indices generated by the edge renderer */
  28287. get linesIndices(): Immutable<Array<number>>;
  28288. /**
  28289. * List of instances to render in case the source mesh has instances
  28290. */
  28291. customInstances: SmartArray<Matrix>;
  28292. private static GetShader;
  28293. /**
  28294. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28295. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28296. * @param source Mesh used to create edges
  28297. * @param epsilon sum of angles in adjacency to check for edge
  28298. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28299. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28300. * @param options The options to apply when generating the edges
  28301. */
  28302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28303. protected _prepareRessources(): void;
  28304. /** @hidden */
  28305. _rebuild(): void;
  28306. /**
  28307. * Releases the required resources for the edges renderer
  28308. */
  28309. dispose(): void;
  28310. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28311. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28312. /**
  28313. * Checks if the pair of p0 and p1 is en edge
  28314. * @param faceIndex
  28315. * @param edge
  28316. * @param faceNormals
  28317. * @param p0
  28318. * @param p1
  28319. * @private
  28320. */
  28321. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28322. /**
  28323. * push line into the position, normal and index buffer
  28324. * @protected
  28325. */
  28326. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28327. /**
  28328. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28329. */
  28330. private _tessellateTriangle;
  28331. private _generateEdgesLinesAlternate;
  28332. /**
  28333. * Generates lines edges from adjacencjes
  28334. * @private
  28335. */
  28336. _generateEdgesLines(): void;
  28337. /**
  28338. * Checks wether or not the edges renderer is ready to render.
  28339. * @return true if ready, otherwise false.
  28340. */
  28341. isReady(): boolean;
  28342. /**
  28343. * Renders the edges of the attached mesh,
  28344. */
  28345. render(): void;
  28346. }
  28347. /**
  28348. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28349. */
  28350. export class LineEdgesRenderer extends EdgesRenderer {
  28351. /**
  28352. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28353. * @param source LineMesh used to generate edges
  28354. * @param epsilon not important (specified angle for edge detection)
  28355. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28356. */
  28357. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28358. /**
  28359. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28360. */
  28361. _generateEdgesLines(): void;
  28362. }
  28363. }
  28364. declare module BABYLON {
  28365. /**
  28366. * This represents the object necessary to create a rendering group.
  28367. * This is exclusively used and created by the rendering manager.
  28368. * To modify the behavior, you use the available helpers in your scene or meshes.
  28369. * @hidden
  28370. */
  28371. export class RenderingGroup {
  28372. index: number;
  28373. private static _zeroVector;
  28374. private _scene;
  28375. private _opaqueSubMeshes;
  28376. private _transparentSubMeshes;
  28377. private _alphaTestSubMeshes;
  28378. private _depthOnlySubMeshes;
  28379. private _particleSystems;
  28380. private _spriteManagers;
  28381. private _opaqueSortCompareFn;
  28382. private _alphaTestSortCompareFn;
  28383. private _transparentSortCompareFn;
  28384. private _renderOpaque;
  28385. private _renderAlphaTest;
  28386. private _renderTransparent;
  28387. /** @hidden */
  28388. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28389. onBeforeTransparentRendering: () => void;
  28390. /**
  28391. * Set the opaque sort comparison function.
  28392. * If null the sub meshes will be render in the order they were created
  28393. */
  28394. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28395. /**
  28396. * Set the alpha test sort comparison function.
  28397. * If null the sub meshes will be render in the order they were created
  28398. */
  28399. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28400. /**
  28401. * Set the transparent sort comparison function.
  28402. * If null the sub meshes will be render in the order they were created
  28403. */
  28404. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28405. /**
  28406. * Creates a new rendering group.
  28407. * @param index The rendering group index
  28408. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28409. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28410. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28411. */
  28412. 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>);
  28413. /**
  28414. * Render all the sub meshes contained in the group.
  28415. * @param customRenderFunction Used to override the default render behaviour of the group.
  28416. * @returns true if rendered some submeshes.
  28417. */
  28418. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28419. /**
  28420. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28421. * @param subMeshes The submeshes to render
  28422. */
  28423. private renderOpaqueSorted;
  28424. /**
  28425. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28426. * @param subMeshes The submeshes to render
  28427. */
  28428. private renderAlphaTestSorted;
  28429. /**
  28430. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28431. * @param subMeshes The submeshes to render
  28432. */
  28433. private renderTransparentSorted;
  28434. /**
  28435. * Renders the submeshes in a specified order.
  28436. * @param subMeshes The submeshes to sort before render
  28437. * @param sortCompareFn The comparison function use to sort
  28438. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28439. * @param transparent Specifies to activate blending if true
  28440. */
  28441. private static renderSorted;
  28442. /**
  28443. * Renders the submeshes in the order they were dispatched (no sort applied).
  28444. * @param subMeshes The submeshes to render
  28445. */
  28446. private static renderUnsorted;
  28447. /**
  28448. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28449. * are rendered back to front if in the same alpha index.
  28450. *
  28451. * @param a The first submesh
  28452. * @param b The second submesh
  28453. * @returns The result of the comparison
  28454. */
  28455. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28456. /**
  28457. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28458. * are rendered back to front.
  28459. *
  28460. * @param a The first submesh
  28461. * @param b The second submesh
  28462. * @returns The result of the comparison
  28463. */
  28464. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28465. /**
  28466. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28467. * are rendered front to back (prevent overdraw).
  28468. *
  28469. * @param a The first submesh
  28470. * @param b The second submesh
  28471. * @returns The result of the comparison
  28472. */
  28473. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28474. /**
  28475. * Resets the different lists of submeshes to prepare a new frame.
  28476. */
  28477. prepare(): void;
  28478. dispose(): void;
  28479. /**
  28480. * Inserts the submesh in its correct queue depending on its material.
  28481. * @param subMesh The submesh to dispatch
  28482. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28483. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28484. */
  28485. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28486. dispatchSprites(spriteManager: ISpriteManager): void;
  28487. dispatchParticles(particleSystem: IParticleSystem): void;
  28488. private _renderParticles;
  28489. private _renderSprites;
  28490. }
  28491. }
  28492. declare module BABYLON {
  28493. /**
  28494. * Interface describing the different options available in the rendering manager
  28495. * regarding Auto Clear between groups.
  28496. */
  28497. export interface IRenderingManagerAutoClearSetup {
  28498. /**
  28499. * Defines whether or not autoclear is enable.
  28500. */
  28501. autoClear: boolean;
  28502. /**
  28503. * Defines whether or not to autoclear the depth buffer.
  28504. */
  28505. depth: boolean;
  28506. /**
  28507. * Defines whether or not to autoclear the stencil buffer.
  28508. */
  28509. stencil: boolean;
  28510. }
  28511. /**
  28512. * This class is used by the onRenderingGroupObservable
  28513. */
  28514. export class RenderingGroupInfo {
  28515. /**
  28516. * The Scene that being rendered
  28517. */
  28518. scene: Scene;
  28519. /**
  28520. * The camera currently used for the rendering pass
  28521. */
  28522. camera: Nullable<Camera>;
  28523. /**
  28524. * The ID of the renderingGroup being processed
  28525. */
  28526. renderingGroupId: number;
  28527. }
  28528. /**
  28529. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28530. * It is enable to manage the different groups as well as the different necessary sort functions.
  28531. * This should not be used directly aside of the few static configurations
  28532. */
  28533. export class RenderingManager {
  28534. /**
  28535. * The max id used for rendering groups (not included)
  28536. */
  28537. static MAX_RENDERINGGROUPS: number;
  28538. /**
  28539. * The min id used for rendering groups (included)
  28540. */
  28541. static MIN_RENDERINGGROUPS: number;
  28542. /**
  28543. * Used to globally prevent autoclearing scenes.
  28544. */
  28545. static AUTOCLEAR: boolean;
  28546. /**
  28547. * @hidden
  28548. */
  28549. _useSceneAutoClearSetup: boolean;
  28550. private _scene;
  28551. private _renderingGroups;
  28552. private _depthStencilBufferAlreadyCleaned;
  28553. private _autoClearDepthStencil;
  28554. private _customOpaqueSortCompareFn;
  28555. private _customAlphaTestSortCompareFn;
  28556. private _customTransparentSortCompareFn;
  28557. private _renderingGroupInfo;
  28558. /**
  28559. * Instantiates a new rendering group for a particular scene
  28560. * @param scene Defines the scene the groups belongs to
  28561. */
  28562. constructor(scene: Scene);
  28563. private _clearDepthStencilBuffer;
  28564. /**
  28565. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28566. * @hidden
  28567. */
  28568. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28569. /**
  28570. * Resets the different information of the group to prepare a new frame
  28571. * @hidden
  28572. */
  28573. reset(): void;
  28574. /**
  28575. * Dispose and release the group and its associated resources.
  28576. * @hidden
  28577. */
  28578. dispose(): void;
  28579. /**
  28580. * Clear the info related to rendering groups preventing retention points during dispose.
  28581. */
  28582. freeRenderingGroups(): void;
  28583. private _prepareRenderingGroup;
  28584. /**
  28585. * Add a sprite manager to the rendering manager in order to render it this frame.
  28586. * @param spriteManager Define the sprite manager to render
  28587. */
  28588. dispatchSprites(spriteManager: ISpriteManager): void;
  28589. /**
  28590. * Add a particle system to the rendering manager in order to render it this frame.
  28591. * @param particleSystem Define the particle system to render
  28592. */
  28593. dispatchParticles(particleSystem: IParticleSystem): void;
  28594. /**
  28595. * Add a submesh to the manager in order to render it this frame
  28596. * @param subMesh The submesh to dispatch
  28597. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28598. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28599. */
  28600. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28601. /**
  28602. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28603. * This allowed control for front to back rendering or reversly depending of the special needs.
  28604. *
  28605. * @param renderingGroupId The rendering group id corresponding to its index
  28606. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28607. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28608. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28609. */
  28610. 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;
  28611. /**
  28612. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28613. *
  28614. * @param renderingGroupId The rendering group id corresponding to its index
  28615. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28616. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28617. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28618. */
  28619. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28620. /**
  28621. * Gets the current auto clear configuration for one rendering group of the rendering
  28622. * manager.
  28623. * @param index the rendering group index to get the information for
  28624. * @returns The auto clear setup for the requested rendering group
  28625. */
  28626. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28627. }
  28628. }
  28629. declare module BABYLON {
  28630. /**
  28631. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28632. */
  28633. export interface ICustomShaderOptions {
  28634. /**
  28635. * Gets or sets the custom shader name to use
  28636. */
  28637. shaderName: string;
  28638. /**
  28639. * The list of attribute names used in the shader
  28640. */
  28641. attributes?: string[];
  28642. /**
  28643. * The list of unifrom names used in the shader
  28644. */
  28645. uniforms?: string[];
  28646. /**
  28647. * The list of sampler names used in the shader
  28648. */
  28649. samplers?: string[];
  28650. /**
  28651. * The list of defines used in the shader
  28652. */
  28653. defines?: string[];
  28654. }
  28655. /**
  28656. * Interface to implement to create a shadow generator compatible with BJS.
  28657. */
  28658. export interface IShadowGenerator {
  28659. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28660. id: string;
  28661. /**
  28662. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28663. * @returns The render target texture if present otherwise, null
  28664. */
  28665. getShadowMap(): Nullable<RenderTargetTexture>;
  28666. /**
  28667. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28668. * @param subMesh The submesh we want to render in the shadow map
  28669. * @param useInstances Defines wether will draw in the map using instances
  28670. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28671. * @returns true if ready otherwise, false
  28672. */
  28673. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28674. /**
  28675. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28676. * @param defines Defines of the material we want to update
  28677. * @param lightIndex Index of the light in the enabled light list of the material
  28678. */
  28679. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28680. /**
  28681. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28682. * defined in the generator but impacting the effect).
  28683. * It implies the unifroms available on the materials are the standard BJS ones.
  28684. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28685. * @param effect The effect we are binfing the information for
  28686. */
  28687. bindShadowLight(lightIndex: string, effect: Effect): void;
  28688. /**
  28689. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28690. * (eq to shadow prjection matrix * light transform matrix)
  28691. * @returns The transform matrix used to create the shadow map
  28692. */
  28693. getTransformMatrix(): Matrix;
  28694. /**
  28695. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28696. * Cube and 2D textures for instance.
  28697. */
  28698. recreateShadowMap(): void;
  28699. /**
  28700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28701. * @param onCompiled Callback triggered at the and of the effects compilation
  28702. * @param options Sets of optional options forcing the compilation with different modes
  28703. */
  28704. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28705. useInstances: boolean;
  28706. }>): void;
  28707. /**
  28708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28709. * @param options Sets of optional options forcing the compilation with different modes
  28710. * @returns A promise that resolves when the compilation completes
  28711. */
  28712. forceCompilationAsync(options?: Partial<{
  28713. useInstances: boolean;
  28714. }>): Promise<void>;
  28715. /**
  28716. * Serializes the shadow generator setup to a json object.
  28717. * @returns The serialized JSON object
  28718. */
  28719. serialize(): any;
  28720. /**
  28721. * Disposes the Shadow map and related Textures and effects.
  28722. */
  28723. dispose(): void;
  28724. }
  28725. /**
  28726. * Default implementation IShadowGenerator.
  28727. * This is the main object responsible of generating shadows in the framework.
  28728. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28729. */
  28730. export class ShadowGenerator implements IShadowGenerator {
  28731. /**
  28732. * Name of the shadow generator class
  28733. */
  28734. static CLASSNAME: string;
  28735. /**
  28736. * Shadow generator mode None: no filtering applied.
  28737. */
  28738. static readonly FILTER_NONE: number;
  28739. /**
  28740. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28741. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28742. */
  28743. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28744. /**
  28745. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28746. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28747. */
  28748. static readonly FILTER_POISSONSAMPLING: number;
  28749. /**
  28750. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28751. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28752. */
  28753. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28754. /**
  28755. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28756. * edge artifacts on steep falloff.
  28757. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28758. */
  28759. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28760. /**
  28761. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28762. * edge artifacts on steep falloff.
  28763. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28764. */
  28765. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28766. /**
  28767. * Shadow generator mode PCF: Percentage Closer Filtering
  28768. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28769. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28770. */
  28771. static readonly FILTER_PCF: number;
  28772. /**
  28773. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28774. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28775. * Contact Hardening
  28776. */
  28777. static readonly FILTER_PCSS: number;
  28778. /**
  28779. * Reserved for PCF and PCSS
  28780. * Highest Quality.
  28781. *
  28782. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28783. *
  28784. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28785. */
  28786. static readonly QUALITY_HIGH: number;
  28787. /**
  28788. * Reserved for PCF and PCSS
  28789. * Good tradeoff for quality/perf cross devices
  28790. *
  28791. * Execute PCF on a 3*3 kernel.
  28792. *
  28793. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28794. */
  28795. static readonly QUALITY_MEDIUM: number;
  28796. /**
  28797. * Reserved for PCF and PCSS
  28798. * The lowest quality but the fastest.
  28799. *
  28800. * Execute PCF on a 1*1 kernel.
  28801. *
  28802. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28803. */
  28804. static readonly QUALITY_LOW: number;
  28805. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28806. id: string;
  28807. /** Gets or sets the custom shader name to use */
  28808. customShaderOptions: ICustomShaderOptions;
  28809. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28810. customAllowRendering: (subMesh: SubMesh) => boolean;
  28811. /**
  28812. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28813. */
  28814. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28815. /**
  28816. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28817. */
  28818. onAfterShadowMapRenderObservable: Observable<Effect>;
  28819. /**
  28820. * Observable triggered before a mesh is rendered in the shadow map.
  28821. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28822. */
  28823. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28824. /**
  28825. * Observable triggered after a mesh is rendered in the shadow map.
  28826. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28827. */
  28828. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28829. protected _bias: number;
  28830. /**
  28831. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28832. */
  28833. get bias(): number;
  28834. /**
  28835. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28836. */
  28837. set bias(bias: number);
  28838. protected _normalBias: number;
  28839. /**
  28840. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28841. */
  28842. get normalBias(): number;
  28843. /**
  28844. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28845. */
  28846. set normalBias(normalBias: number);
  28847. protected _blurBoxOffset: number;
  28848. /**
  28849. * Gets the blur box offset: offset applied during the blur pass.
  28850. * Only useful if useKernelBlur = false
  28851. */
  28852. get blurBoxOffset(): number;
  28853. /**
  28854. * Sets the blur box offset: offset applied during the blur pass.
  28855. * Only useful if useKernelBlur = false
  28856. */
  28857. set blurBoxOffset(value: number);
  28858. protected _blurScale: number;
  28859. /**
  28860. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28861. * 2 means half of the size.
  28862. */
  28863. get blurScale(): number;
  28864. /**
  28865. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28866. * 2 means half of the size.
  28867. */
  28868. set blurScale(value: number);
  28869. protected _blurKernel: number;
  28870. /**
  28871. * Gets the blur kernel: kernel size of the blur pass.
  28872. * Only useful if useKernelBlur = true
  28873. */
  28874. get blurKernel(): number;
  28875. /**
  28876. * Sets the blur kernel: kernel size of the blur pass.
  28877. * Only useful if useKernelBlur = true
  28878. */
  28879. set blurKernel(value: number);
  28880. protected _useKernelBlur: boolean;
  28881. /**
  28882. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28883. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28884. */
  28885. get useKernelBlur(): boolean;
  28886. /**
  28887. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28888. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28889. */
  28890. set useKernelBlur(value: boolean);
  28891. protected _depthScale: number;
  28892. /**
  28893. * Gets the depth scale used in ESM mode.
  28894. */
  28895. get depthScale(): number;
  28896. /**
  28897. * Sets the depth scale used in ESM mode.
  28898. * This can override the scale stored on the light.
  28899. */
  28900. set depthScale(value: number);
  28901. protected _validateFilter(filter: number): number;
  28902. protected _filter: number;
  28903. /**
  28904. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28905. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28906. */
  28907. get filter(): number;
  28908. /**
  28909. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28910. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28911. */
  28912. set filter(value: number);
  28913. /**
  28914. * Gets if the current filter is set to Poisson Sampling.
  28915. */
  28916. get usePoissonSampling(): boolean;
  28917. /**
  28918. * Sets the current filter to Poisson Sampling.
  28919. */
  28920. set usePoissonSampling(value: boolean);
  28921. /**
  28922. * Gets if the current filter is set to ESM.
  28923. */
  28924. get useExponentialShadowMap(): boolean;
  28925. /**
  28926. * Sets the current filter is to ESM.
  28927. */
  28928. set useExponentialShadowMap(value: boolean);
  28929. /**
  28930. * Gets if the current filter is set to filtered ESM.
  28931. */
  28932. get useBlurExponentialShadowMap(): boolean;
  28933. /**
  28934. * Gets if the current filter is set to filtered ESM.
  28935. */
  28936. set useBlurExponentialShadowMap(value: boolean);
  28937. /**
  28938. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28939. * exponential to prevent steep falloff artifacts).
  28940. */
  28941. get useCloseExponentialShadowMap(): boolean;
  28942. /**
  28943. * Sets the current filter to "close ESM" (using the inverse of the
  28944. * exponential to prevent steep falloff artifacts).
  28945. */
  28946. set useCloseExponentialShadowMap(value: boolean);
  28947. /**
  28948. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28949. * exponential to prevent steep falloff artifacts).
  28950. */
  28951. get useBlurCloseExponentialShadowMap(): boolean;
  28952. /**
  28953. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28954. * exponential to prevent steep falloff artifacts).
  28955. */
  28956. set useBlurCloseExponentialShadowMap(value: boolean);
  28957. /**
  28958. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28959. */
  28960. get usePercentageCloserFiltering(): boolean;
  28961. /**
  28962. * Sets the current filter to "PCF" (percentage closer filtering).
  28963. */
  28964. set usePercentageCloserFiltering(value: boolean);
  28965. protected _filteringQuality: number;
  28966. /**
  28967. * Gets the PCF or PCSS Quality.
  28968. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28969. */
  28970. get filteringQuality(): number;
  28971. /**
  28972. * Sets the PCF or PCSS Quality.
  28973. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28974. */
  28975. set filteringQuality(filteringQuality: number);
  28976. /**
  28977. * Gets if the current filter is set to "PCSS" (contact hardening).
  28978. */
  28979. get useContactHardeningShadow(): boolean;
  28980. /**
  28981. * Sets the current filter to "PCSS" (contact hardening).
  28982. */
  28983. set useContactHardeningShadow(value: boolean);
  28984. protected _contactHardeningLightSizeUVRatio: number;
  28985. /**
  28986. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28987. * Using a ratio helps keeping shape stability independently of the map size.
  28988. *
  28989. * It does not account for the light projection as it was having too much
  28990. * instability during the light setup or during light position changes.
  28991. *
  28992. * Only valid if useContactHardeningShadow is true.
  28993. */
  28994. get contactHardeningLightSizeUVRatio(): number;
  28995. /**
  28996. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28997. * Using a ratio helps keeping shape stability independently of the map size.
  28998. *
  28999. * It does not account for the light projection as it was having too much
  29000. * instability during the light setup or during light position changes.
  29001. *
  29002. * Only valid if useContactHardeningShadow is true.
  29003. */
  29004. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29005. protected _darkness: number;
  29006. /** Gets or sets the actual darkness of a shadow */
  29007. get darkness(): number;
  29008. set darkness(value: number);
  29009. /**
  29010. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29011. * 0 means strongest and 1 would means no shadow.
  29012. * @returns the darkness.
  29013. */
  29014. getDarkness(): number;
  29015. /**
  29016. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29017. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29018. * @returns the shadow generator allowing fluent coding.
  29019. */
  29020. setDarkness(darkness: number): ShadowGenerator;
  29021. protected _transparencyShadow: boolean;
  29022. /** Gets or sets the ability to have transparent shadow */
  29023. get transparencyShadow(): boolean;
  29024. set transparencyShadow(value: boolean);
  29025. /**
  29026. * Sets the ability to have transparent shadow (boolean).
  29027. * @param transparent True if transparent else False
  29028. * @returns the shadow generator allowing fluent coding
  29029. */
  29030. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29031. /**
  29032. * Enables or disables shadows with varying strength based on the transparency
  29033. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29034. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29035. * mesh.visibility * alphaTexture.a
  29036. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29037. */
  29038. enableSoftTransparentShadow: boolean;
  29039. protected _shadowMap: Nullable<RenderTargetTexture>;
  29040. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29041. /**
  29042. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29043. * @returns The render target texture if present otherwise, null
  29044. */
  29045. getShadowMap(): Nullable<RenderTargetTexture>;
  29046. /**
  29047. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29048. * @returns The render target texture if the shadow map is present otherwise, null
  29049. */
  29050. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29051. /**
  29052. * Gets the class name of that object
  29053. * @returns "ShadowGenerator"
  29054. */
  29055. getClassName(): string;
  29056. /**
  29057. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29058. * @param mesh Mesh to add
  29059. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29060. * @returns the Shadow Generator itself
  29061. */
  29062. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29063. /**
  29064. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29065. * @param mesh Mesh to remove
  29066. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29067. * @returns the Shadow Generator itself
  29068. */
  29069. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29070. /**
  29071. * Controls the extent to which the shadows fade out at the edge of the frustum
  29072. */
  29073. frustumEdgeFalloff: number;
  29074. protected _light: IShadowLight;
  29075. /**
  29076. * Returns the associated light object.
  29077. * @returns the light generating the shadow
  29078. */
  29079. getLight(): IShadowLight;
  29080. /**
  29081. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29082. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29083. * It might on the other hand introduce peter panning.
  29084. */
  29085. forceBackFacesOnly: boolean;
  29086. protected _scene: Scene;
  29087. protected _lightDirection: Vector3;
  29088. protected _effect: Effect;
  29089. protected _viewMatrix: Matrix;
  29090. protected _projectionMatrix: Matrix;
  29091. protected _transformMatrix: Matrix;
  29092. protected _cachedPosition: Vector3;
  29093. protected _cachedDirection: Vector3;
  29094. protected _cachedDefines: string;
  29095. protected _currentRenderID: number;
  29096. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29097. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29098. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29099. protected _blurPostProcesses: PostProcess[];
  29100. protected _mapSize: number;
  29101. protected _currentFaceIndex: number;
  29102. protected _currentFaceIndexCache: number;
  29103. protected _textureType: number;
  29104. protected _defaultTextureMatrix: Matrix;
  29105. protected _storedUniqueId: Nullable<number>;
  29106. /** @hidden */
  29107. static _SceneComponentInitialization: (scene: Scene) => void;
  29108. /**
  29109. * Gets or sets the size of the texture what stores the shadows
  29110. */
  29111. get mapSize(): number;
  29112. set mapSize(size: number);
  29113. /**
  29114. * Creates a ShadowGenerator object.
  29115. * A ShadowGenerator is the required tool to use the shadows.
  29116. * Each light casting shadows needs to use its own ShadowGenerator.
  29117. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29118. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29119. * @param light The light object generating the shadows.
  29120. * @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.
  29121. */
  29122. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29123. protected _initializeGenerator(): void;
  29124. protected _createTargetRenderTexture(): void;
  29125. protected _initializeShadowMap(): void;
  29126. protected _initializeBlurRTTAndPostProcesses(): void;
  29127. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29128. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29129. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29130. protected _applyFilterValues(): void;
  29131. /**
  29132. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29133. * @param onCompiled Callback triggered at the and of the effects compilation
  29134. * @param options Sets of optional options forcing the compilation with different modes
  29135. */
  29136. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29137. useInstances: boolean;
  29138. }>): void;
  29139. /**
  29140. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29141. * @param options Sets of optional options forcing the compilation with different modes
  29142. * @returns A promise that resolves when the compilation completes
  29143. */
  29144. forceCompilationAsync(options?: Partial<{
  29145. useInstances: boolean;
  29146. }>): Promise<void>;
  29147. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29148. private _prepareShadowDefines;
  29149. /**
  29150. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29151. * @param subMesh The submesh we want to render in the shadow map
  29152. * @param useInstances Defines wether will draw in the map using instances
  29153. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29154. * @returns true if ready otherwise, false
  29155. */
  29156. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29157. /**
  29158. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29159. * @param defines Defines of the material we want to update
  29160. * @param lightIndex Index of the light in the enabled light list of the material
  29161. */
  29162. prepareDefines(defines: any, lightIndex: number): void;
  29163. /**
  29164. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29165. * defined in the generator but impacting the effect).
  29166. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29167. * @param effect The effect we are binfing the information for
  29168. */
  29169. bindShadowLight(lightIndex: string, effect: Effect): void;
  29170. /**
  29171. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29172. * (eq to shadow prjection matrix * light transform matrix)
  29173. * @returns The transform matrix used to create the shadow map
  29174. */
  29175. getTransformMatrix(): Matrix;
  29176. /**
  29177. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29178. * Cube and 2D textures for instance.
  29179. */
  29180. recreateShadowMap(): void;
  29181. protected _disposeBlurPostProcesses(): void;
  29182. protected _disposeRTTandPostProcesses(): void;
  29183. /**
  29184. * Disposes the ShadowGenerator.
  29185. * Returns nothing.
  29186. */
  29187. dispose(): void;
  29188. /**
  29189. * Serializes the shadow generator setup to a json object.
  29190. * @returns The serialized JSON object
  29191. */
  29192. serialize(): any;
  29193. /**
  29194. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29195. * @param parsedShadowGenerator The JSON object to parse
  29196. * @param scene The scene to create the shadow map for
  29197. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29198. * @returns The parsed shadow generator
  29199. */
  29200. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29201. }
  29202. }
  29203. declare module BABYLON {
  29204. /**
  29205. * Options to be used when creating a shadow depth material
  29206. */
  29207. export interface IIOptionShadowDepthMaterial {
  29208. /** Variables in the vertex shader code that need to have their names remapped.
  29209. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29210. * "var_name" should be either: worldPos or vNormalW
  29211. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29212. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29213. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29214. */
  29215. remappedVariables?: string[];
  29216. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29217. standalone?: boolean;
  29218. }
  29219. /**
  29220. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29221. */
  29222. export class ShadowDepthWrapper {
  29223. private _scene;
  29224. private _options?;
  29225. private _baseMaterial;
  29226. private _onEffectCreatedObserver;
  29227. private _subMeshToEffect;
  29228. private _subMeshToDepthEffect;
  29229. private _meshes;
  29230. /** @hidden */
  29231. _matriceNames: any;
  29232. /** Gets the standalone status of the wrapper */
  29233. get standalone(): boolean;
  29234. /** Gets the base material the wrapper is built upon */
  29235. get baseMaterial(): Material;
  29236. /**
  29237. * Instantiate a new shadow depth wrapper.
  29238. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29239. * generate the shadow depth map. For more information, please refer to the documentation:
  29240. * https://doc.babylonjs.com/babylon101/shadows
  29241. * @param baseMaterial Material to wrap
  29242. * @param scene Define the scene the material belongs to
  29243. * @param options Options used to create the wrapper
  29244. */
  29245. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29246. /**
  29247. * Gets the effect to use to generate the depth map
  29248. * @param subMesh subMesh to get the effect for
  29249. * @param shadowGenerator shadow generator to get the effect for
  29250. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29251. */
  29252. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29253. /**
  29254. * Specifies that the submesh is ready to be used for depth rendering
  29255. * @param subMesh submesh to check
  29256. * @param defines the list of defines to take into account when checking the effect
  29257. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29258. * @param useInstances specifies that instances should be used
  29259. * @returns a boolean indicating that the submesh is ready or not
  29260. */
  29261. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29262. /**
  29263. * Disposes the resources
  29264. */
  29265. dispose(): void;
  29266. private _makeEffect;
  29267. }
  29268. }
  29269. declare module BABYLON {
  29270. /**
  29271. * Options for compiling materials.
  29272. */
  29273. export interface IMaterialCompilationOptions {
  29274. /**
  29275. * Defines whether clip planes are enabled.
  29276. */
  29277. clipPlane: boolean;
  29278. /**
  29279. * Defines whether instances are enabled.
  29280. */
  29281. useInstances: boolean;
  29282. }
  29283. /**
  29284. * Options passed when calling customShaderNameResolve
  29285. */
  29286. export interface ICustomShaderNameResolveOptions {
  29287. /**
  29288. * 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
  29289. */
  29290. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29291. }
  29292. /**
  29293. * Base class for the main features of a material in Babylon.js
  29294. */
  29295. export class Material implements IAnimatable {
  29296. /**
  29297. * Returns the triangle fill mode
  29298. */
  29299. static readonly TriangleFillMode: number;
  29300. /**
  29301. * Returns the wireframe mode
  29302. */
  29303. static readonly WireFrameFillMode: number;
  29304. /**
  29305. * Returns the point fill mode
  29306. */
  29307. static readonly PointFillMode: number;
  29308. /**
  29309. * Returns the point list draw mode
  29310. */
  29311. static readonly PointListDrawMode: number;
  29312. /**
  29313. * Returns the line list draw mode
  29314. */
  29315. static readonly LineListDrawMode: number;
  29316. /**
  29317. * Returns the line loop draw mode
  29318. */
  29319. static readonly LineLoopDrawMode: number;
  29320. /**
  29321. * Returns the line strip draw mode
  29322. */
  29323. static readonly LineStripDrawMode: number;
  29324. /**
  29325. * Returns the triangle strip draw mode
  29326. */
  29327. static readonly TriangleStripDrawMode: number;
  29328. /**
  29329. * Returns the triangle fan draw mode
  29330. */
  29331. static readonly TriangleFanDrawMode: number;
  29332. /**
  29333. * Stores the clock-wise side orientation
  29334. */
  29335. static readonly ClockWiseSideOrientation: number;
  29336. /**
  29337. * Stores the counter clock-wise side orientation
  29338. */
  29339. static readonly CounterClockWiseSideOrientation: number;
  29340. /**
  29341. * The dirty texture flag value
  29342. */
  29343. static readonly TextureDirtyFlag: number;
  29344. /**
  29345. * The dirty light flag value
  29346. */
  29347. static readonly LightDirtyFlag: number;
  29348. /**
  29349. * The dirty fresnel flag value
  29350. */
  29351. static readonly FresnelDirtyFlag: number;
  29352. /**
  29353. * The dirty attribute flag value
  29354. */
  29355. static readonly AttributesDirtyFlag: number;
  29356. /**
  29357. * The dirty misc flag value
  29358. */
  29359. static readonly MiscDirtyFlag: number;
  29360. /**
  29361. * The dirty prepass flag value
  29362. */
  29363. static readonly PrePassDirtyFlag: number;
  29364. /**
  29365. * The all dirty flag value
  29366. */
  29367. static readonly AllDirtyFlag: number;
  29368. /**
  29369. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29370. */
  29371. static readonly MATERIAL_OPAQUE: number;
  29372. /**
  29373. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29374. */
  29375. static readonly MATERIAL_ALPHATEST: number;
  29376. /**
  29377. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29378. */
  29379. static readonly MATERIAL_ALPHABLEND: number;
  29380. /**
  29381. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29382. * They are also discarded below the alpha cutoff threshold to improve performances.
  29383. */
  29384. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29385. /**
  29386. * The Whiteout method is used to blend normals.
  29387. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29388. */
  29389. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29390. /**
  29391. * The Reoriented Normal Mapping method is used to blend normals.
  29392. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29393. */
  29394. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29395. /**
  29396. * Custom callback helping to override the default shader used in the material.
  29397. */
  29398. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29399. /**
  29400. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29401. */
  29402. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29403. /**
  29404. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29405. * This means that the material can keep using a previous shader while a new one is being compiled.
  29406. * This is mostly used when shader parallel compilation is supported (true by default)
  29407. */
  29408. allowShaderHotSwapping: boolean;
  29409. /**
  29410. * The ID of the material
  29411. */
  29412. id: string;
  29413. /**
  29414. * Gets or sets the unique id of the material
  29415. */
  29416. uniqueId: number;
  29417. /**
  29418. * The name of the material
  29419. */
  29420. name: string;
  29421. /**
  29422. * Gets or sets user defined metadata
  29423. */
  29424. metadata: any;
  29425. /**
  29426. * For internal use only. Please do not use.
  29427. */
  29428. reservedDataStore: any;
  29429. /**
  29430. * Specifies if the ready state should be checked on each call
  29431. */
  29432. checkReadyOnEveryCall: boolean;
  29433. /**
  29434. * Specifies if the ready state should be checked once
  29435. */
  29436. checkReadyOnlyOnce: boolean;
  29437. /**
  29438. * The state of the material
  29439. */
  29440. state: string;
  29441. /**
  29442. * If the material can be rendered to several textures with MRT extension
  29443. */
  29444. get canRenderToMRT(): boolean;
  29445. /**
  29446. * The alpha value of the material
  29447. */
  29448. protected _alpha: number;
  29449. /**
  29450. * List of inspectable custom properties (used by the Inspector)
  29451. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29452. */
  29453. inspectableCustomProperties: IInspectable[];
  29454. /**
  29455. * Sets the alpha value of the material
  29456. */
  29457. set alpha(value: number);
  29458. /**
  29459. * Gets the alpha value of the material
  29460. */
  29461. get alpha(): number;
  29462. /**
  29463. * Specifies if back face culling is enabled
  29464. */
  29465. protected _backFaceCulling: boolean;
  29466. /**
  29467. * Sets the back-face culling state
  29468. */
  29469. set backFaceCulling(value: boolean);
  29470. /**
  29471. * Gets the back-face culling state
  29472. */
  29473. get backFaceCulling(): boolean;
  29474. /**
  29475. * Stores the value for side orientation
  29476. */
  29477. sideOrientation: number;
  29478. /**
  29479. * Callback triggered when the material is compiled
  29480. */
  29481. onCompiled: Nullable<(effect: Effect) => void>;
  29482. /**
  29483. * Callback triggered when an error occurs
  29484. */
  29485. onError: Nullable<(effect: Effect, errors: string) => void>;
  29486. /**
  29487. * Callback triggered to get the render target textures
  29488. */
  29489. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29490. /**
  29491. * Gets a boolean indicating that current material needs to register RTT
  29492. */
  29493. get hasRenderTargetTextures(): boolean;
  29494. /**
  29495. * Specifies if the material should be serialized
  29496. */
  29497. doNotSerialize: boolean;
  29498. /**
  29499. * @hidden
  29500. */
  29501. _storeEffectOnSubMeshes: boolean;
  29502. /**
  29503. * Stores the animations for the material
  29504. */
  29505. animations: Nullable<Array<Animation>>;
  29506. /**
  29507. * An event triggered when the material is disposed
  29508. */
  29509. onDisposeObservable: Observable<Material>;
  29510. /**
  29511. * An observer which watches for dispose events
  29512. */
  29513. private _onDisposeObserver;
  29514. private _onUnBindObservable;
  29515. /**
  29516. * Called during a dispose event
  29517. */
  29518. set onDispose(callback: () => void);
  29519. private _onBindObservable;
  29520. /**
  29521. * An event triggered when the material is bound
  29522. */
  29523. get onBindObservable(): Observable<AbstractMesh>;
  29524. /**
  29525. * An observer which watches for bind events
  29526. */
  29527. private _onBindObserver;
  29528. /**
  29529. * Called during a bind event
  29530. */
  29531. set onBind(callback: (Mesh: AbstractMesh) => void);
  29532. /**
  29533. * An event triggered when the material is unbound
  29534. */
  29535. get onUnBindObservable(): Observable<Material>;
  29536. protected _onEffectCreatedObservable: Nullable<Observable<{
  29537. effect: Effect;
  29538. subMesh: Nullable<SubMesh>;
  29539. }>>;
  29540. /**
  29541. * An event triggered when the effect is (re)created
  29542. */
  29543. get onEffectCreatedObservable(): Observable<{
  29544. effect: Effect;
  29545. subMesh: Nullable<SubMesh>;
  29546. }>;
  29547. /**
  29548. * Stores the value of the alpha mode
  29549. */
  29550. private _alphaMode;
  29551. /**
  29552. * Sets the value of the alpha mode.
  29553. *
  29554. * | Value | Type | Description |
  29555. * | --- | --- | --- |
  29556. * | 0 | ALPHA_DISABLE | |
  29557. * | 1 | ALPHA_ADD | |
  29558. * | 2 | ALPHA_COMBINE | |
  29559. * | 3 | ALPHA_SUBTRACT | |
  29560. * | 4 | ALPHA_MULTIPLY | |
  29561. * | 5 | ALPHA_MAXIMIZED | |
  29562. * | 6 | ALPHA_ONEONE | |
  29563. * | 7 | ALPHA_PREMULTIPLIED | |
  29564. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29565. * | 9 | ALPHA_INTERPOLATE | |
  29566. * | 10 | ALPHA_SCREENMODE | |
  29567. *
  29568. */
  29569. set alphaMode(value: number);
  29570. /**
  29571. * Gets the value of the alpha mode
  29572. */
  29573. get alphaMode(): number;
  29574. /**
  29575. * Stores the state of the need depth pre-pass value
  29576. */
  29577. private _needDepthPrePass;
  29578. /**
  29579. * Sets the need depth pre-pass value
  29580. */
  29581. set needDepthPrePass(value: boolean);
  29582. /**
  29583. * Gets the depth pre-pass value
  29584. */
  29585. get needDepthPrePass(): boolean;
  29586. /**
  29587. * Specifies if depth writing should be disabled
  29588. */
  29589. disableDepthWrite: boolean;
  29590. /**
  29591. * Specifies if color writing should be disabled
  29592. */
  29593. disableColorWrite: boolean;
  29594. /**
  29595. * Specifies if depth writing should be forced
  29596. */
  29597. forceDepthWrite: boolean;
  29598. /**
  29599. * Specifies the depth function that should be used. 0 means the default engine function
  29600. */
  29601. depthFunction: number;
  29602. /**
  29603. * Specifies if there should be a separate pass for culling
  29604. */
  29605. separateCullingPass: boolean;
  29606. /**
  29607. * Stores the state specifing if fog should be enabled
  29608. */
  29609. private _fogEnabled;
  29610. /**
  29611. * Sets the state for enabling fog
  29612. */
  29613. set fogEnabled(value: boolean);
  29614. /**
  29615. * Gets the value of the fog enabled state
  29616. */
  29617. get fogEnabled(): boolean;
  29618. /**
  29619. * Stores the size of points
  29620. */
  29621. pointSize: number;
  29622. /**
  29623. * Stores the z offset value
  29624. */
  29625. zOffset: number;
  29626. get wireframe(): boolean;
  29627. /**
  29628. * Sets the state of wireframe mode
  29629. */
  29630. set wireframe(value: boolean);
  29631. /**
  29632. * Gets the value specifying if point clouds are enabled
  29633. */
  29634. get pointsCloud(): boolean;
  29635. /**
  29636. * Sets the state of point cloud mode
  29637. */
  29638. set pointsCloud(value: boolean);
  29639. /**
  29640. * Gets the material fill mode
  29641. */
  29642. get fillMode(): number;
  29643. /**
  29644. * Sets the material fill mode
  29645. */
  29646. set fillMode(value: number);
  29647. /**
  29648. * @hidden
  29649. * Stores the effects for the material
  29650. */
  29651. _effect: Nullable<Effect>;
  29652. /**
  29653. * Specifies if uniform buffers should be used
  29654. */
  29655. private _useUBO;
  29656. /**
  29657. * Stores a reference to the scene
  29658. */
  29659. private _scene;
  29660. /**
  29661. * Stores the fill mode state
  29662. */
  29663. private _fillMode;
  29664. /**
  29665. * Specifies if the depth write state should be cached
  29666. */
  29667. private _cachedDepthWriteState;
  29668. /**
  29669. * Specifies if the color write state should be cached
  29670. */
  29671. private _cachedColorWriteState;
  29672. /**
  29673. * Specifies if the depth function state should be cached
  29674. */
  29675. private _cachedDepthFunctionState;
  29676. /**
  29677. * Stores the uniform buffer
  29678. */
  29679. protected _uniformBuffer: UniformBuffer;
  29680. /** @hidden */
  29681. _indexInSceneMaterialArray: number;
  29682. /** @hidden */
  29683. meshMap: Nullable<{
  29684. [id: string]: AbstractMesh | undefined;
  29685. }>;
  29686. /**
  29687. * Creates a material instance
  29688. * @param name defines the name of the material
  29689. * @param scene defines the scene to reference
  29690. * @param doNotAdd specifies if the material should be added to the scene
  29691. */
  29692. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29693. /**
  29694. * Returns a string representation of the current material
  29695. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29696. * @returns a string with material information
  29697. */
  29698. toString(fullDetails?: boolean): string;
  29699. /**
  29700. * Gets the class name of the material
  29701. * @returns a string with the class name of the material
  29702. */
  29703. getClassName(): string;
  29704. /**
  29705. * Specifies if updates for the material been locked
  29706. */
  29707. get isFrozen(): boolean;
  29708. /**
  29709. * Locks updates for the material
  29710. */
  29711. freeze(): void;
  29712. /**
  29713. * Unlocks updates for the material
  29714. */
  29715. unfreeze(): void;
  29716. /**
  29717. * Specifies if the material is ready to be used
  29718. * @param mesh defines the mesh to check
  29719. * @param useInstances specifies if instances should be used
  29720. * @returns a boolean indicating if the material is ready to be used
  29721. */
  29722. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29723. /**
  29724. * Specifies that the submesh is ready to be used
  29725. * @param mesh defines the mesh to check
  29726. * @param subMesh defines which submesh to check
  29727. * @param useInstances specifies that instances should be used
  29728. * @returns a boolean indicating that the submesh is ready or not
  29729. */
  29730. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29731. /**
  29732. * Returns the material effect
  29733. * @returns the effect associated with the material
  29734. */
  29735. getEffect(): Nullable<Effect>;
  29736. /**
  29737. * Returns the current scene
  29738. * @returns a Scene
  29739. */
  29740. getScene(): Scene;
  29741. /**
  29742. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29743. */
  29744. protected _forceAlphaTest: boolean;
  29745. /**
  29746. * The transparency mode of the material.
  29747. */
  29748. protected _transparencyMode: Nullable<number>;
  29749. /**
  29750. * Gets the current transparency mode.
  29751. */
  29752. get transparencyMode(): Nullable<number>;
  29753. /**
  29754. * Sets the transparency mode of the material.
  29755. *
  29756. * | Value | Type | Description |
  29757. * | ----- | ----------------------------------- | ----------- |
  29758. * | 0 | OPAQUE | |
  29759. * | 1 | ALPHATEST | |
  29760. * | 2 | ALPHABLEND | |
  29761. * | 3 | ALPHATESTANDBLEND | |
  29762. *
  29763. */
  29764. set transparencyMode(value: Nullable<number>);
  29765. /**
  29766. * Returns true if alpha blending should be disabled.
  29767. */
  29768. protected get _disableAlphaBlending(): boolean;
  29769. /**
  29770. * Specifies whether or not this material should be rendered in alpha blend mode.
  29771. * @returns a boolean specifying if alpha blending is needed
  29772. */
  29773. needAlphaBlending(): boolean;
  29774. /**
  29775. * Specifies if the mesh will require alpha blending
  29776. * @param mesh defines the mesh to check
  29777. * @returns a boolean specifying if alpha blending is needed for the mesh
  29778. */
  29779. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29780. /**
  29781. * Specifies whether or not this material should be rendered in alpha test mode.
  29782. * @returns a boolean specifying if an alpha test is needed.
  29783. */
  29784. needAlphaTesting(): boolean;
  29785. /**
  29786. * Specifies if material alpha testing should be turned on for the mesh
  29787. * @param mesh defines the mesh to check
  29788. */
  29789. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29790. /**
  29791. * Gets the texture used for the alpha test
  29792. * @returns the texture to use for alpha testing
  29793. */
  29794. getAlphaTestTexture(): Nullable<BaseTexture>;
  29795. /**
  29796. * Marks the material to indicate that it needs to be re-calculated
  29797. */
  29798. markDirty(): void;
  29799. /** @hidden */
  29800. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29801. /**
  29802. * Binds the material to the mesh
  29803. * @param world defines the world transformation matrix
  29804. * @param mesh defines the mesh to bind the material to
  29805. */
  29806. bind(world: Matrix, mesh?: Mesh): void;
  29807. /**
  29808. * Binds the submesh to the material
  29809. * @param world defines the world transformation matrix
  29810. * @param mesh defines the mesh containing the submesh
  29811. * @param subMesh defines the submesh to bind the material to
  29812. */
  29813. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29814. /**
  29815. * Binds the world matrix to the material
  29816. * @param world defines the world transformation matrix
  29817. */
  29818. bindOnlyWorldMatrix(world: Matrix): void;
  29819. /**
  29820. * Binds the scene's uniform buffer to the effect.
  29821. * @param effect defines the effect to bind to the scene uniform buffer
  29822. * @param sceneUbo defines the uniform buffer storing scene data
  29823. */
  29824. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29825. /**
  29826. * Binds the view matrix to the effect
  29827. * @param effect defines the effect to bind the view matrix to
  29828. */
  29829. bindView(effect: Effect): void;
  29830. /**
  29831. * Binds the view projection matrix to the effect
  29832. * @param effect defines the effect to bind the view projection matrix to
  29833. */
  29834. bindViewProjection(effect: Effect): void;
  29835. /**
  29836. * Processes to execute after binding the material to a mesh
  29837. * @param mesh defines the rendered mesh
  29838. */
  29839. protected _afterBind(mesh?: Mesh): void;
  29840. /**
  29841. * Unbinds the material from the mesh
  29842. */
  29843. unbind(): void;
  29844. /**
  29845. * Gets the active textures from the material
  29846. * @returns an array of textures
  29847. */
  29848. getActiveTextures(): BaseTexture[];
  29849. /**
  29850. * Specifies if the material uses a texture
  29851. * @param texture defines the texture to check against the material
  29852. * @returns a boolean specifying if the material uses the texture
  29853. */
  29854. hasTexture(texture: BaseTexture): boolean;
  29855. /**
  29856. * Makes a duplicate of the material, and gives it a new name
  29857. * @param name defines the new name for the duplicated material
  29858. * @returns the cloned material
  29859. */
  29860. clone(name: string): Nullable<Material>;
  29861. /**
  29862. * Gets the meshes bound to the material
  29863. * @returns an array of meshes bound to the material
  29864. */
  29865. getBindedMeshes(): AbstractMesh[];
  29866. /**
  29867. * Force shader compilation
  29868. * @param mesh defines the mesh associated with this material
  29869. * @param onCompiled defines a function to execute once the material is compiled
  29870. * @param options defines the options to configure the compilation
  29871. * @param onError defines a function to execute if the material fails compiling
  29872. */
  29873. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29874. /**
  29875. * Force shader compilation
  29876. * @param mesh defines the mesh that will use this material
  29877. * @param options defines additional options for compiling the shaders
  29878. * @returns a promise that resolves when the compilation completes
  29879. */
  29880. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29881. private static readonly _AllDirtyCallBack;
  29882. private static readonly _ImageProcessingDirtyCallBack;
  29883. private static readonly _TextureDirtyCallBack;
  29884. private static readonly _FresnelDirtyCallBack;
  29885. private static readonly _MiscDirtyCallBack;
  29886. private static readonly _PrePassDirtyCallBack;
  29887. private static readonly _LightsDirtyCallBack;
  29888. private static readonly _AttributeDirtyCallBack;
  29889. private static _FresnelAndMiscDirtyCallBack;
  29890. private static _TextureAndMiscDirtyCallBack;
  29891. private static readonly _DirtyCallbackArray;
  29892. private static readonly _RunDirtyCallBacks;
  29893. /**
  29894. * Marks a define in the material to indicate that it needs to be re-computed
  29895. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29896. */
  29897. markAsDirty(flag: number): void;
  29898. /**
  29899. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29900. * @param func defines a function which checks material defines against the submeshes
  29901. */
  29902. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29903. /**
  29904. * Indicates that the scene should check if the rendering now needs a prepass
  29905. */
  29906. protected _markScenePrePassDirty(): void;
  29907. /**
  29908. * Indicates that we need to re-calculated for all submeshes
  29909. */
  29910. protected _markAllSubMeshesAsAllDirty(): void;
  29911. /**
  29912. * Indicates that image processing needs to be re-calculated for all submeshes
  29913. */
  29914. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29915. /**
  29916. * Indicates that textures need to be re-calculated for all submeshes
  29917. */
  29918. protected _markAllSubMeshesAsTexturesDirty(): void;
  29919. /**
  29920. * Indicates that fresnel needs to be re-calculated for all submeshes
  29921. */
  29922. protected _markAllSubMeshesAsFresnelDirty(): void;
  29923. /**
  29924. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29925. */
  29926. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29927. /**
  29928. * Indicates that lights need to be re-calculated for all submeshes
  29929. */
  29930. protected _markAllSubMeshesAsLightsDirty(): void;
  29931. /**
  29932. * Indicates that attributes need to be re-calculated for all submeshes
  29933. */
  29934. protected _markAllSubMeshesAsAttributesDirty(): void;
  29935. /**
  29936. * Indicates that misc needs to be re-calculated for all submeshes
  29937. */
  29938. protected _markAllSubMeshesAsMiscDirty(): void;
  29939. /**
  29940. * Indicates that prepass needs to be re-calculated for all submeshes
  29941. */
  29942. protected _markAllSubMeshesAsPrePassDirty(): void;
  29943. /**
  29944. * Indicates that textures and misc need to be re-calculated for all submeshes
  29945. */
  29946. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29947. /**
  29948. * Sets the required values to the prepass renderer.
  29949. * @param prePassRenderer defines the prepass renderer to setup.
  29950. * @returns true if the pre pass is needed.
  29951. */
  29952. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29953. /**
  29954. * Disposes the material
  29955. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29956. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29957. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29958. */
  29959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29960. /** @hidden */
  29961. private releaseVertexArrayObject;
  29962. /**
  29963. * Serializes this material
  29964. * @returns the serialized material object
  29965. */
  29966. serialize(): any;
  29967. /**
  29968. * Creates a material from parsed material data
  29969. * @param parsedMaterial defines parsed material data
  29970. * @param scene defines the hosting scene
  29971. * @param rootUrl defines the root URL to use to load textures
  29972. * @returns a new material
  29973. */
  29974. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29975. }
  29976. }
  29977. declare module BABYLON {
  29978. /**
  29979. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29980. * separate meshes. This can be use to improve performances.
  29981. * @see https://doc.babylonjs.com/how_to/multi_materials
  29982. */
  29983. export class MultiMaterial extends Material {
  29984. private _subMaterials;
  29985. /**
  29986. * Gets or Sets the list of Materials used within the multi material.
  29987. * They need to be ordered according to the submeshes order in the associated mesh
  29988. */
  29989. get subMaterials(): Nullable<Material>[];
  29990. set subMaterials(value: Nullable<Material>[]);
  29991. /**
  29992. * Function used to align with Node.getChildren()
  29993. * @returns the list of Materials used within the multi material
  29994. */
  29995. getChildren(): Nullable<Material>[];
  29996. /**
  29997. * Instantiates a new Multi Material
  29998. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29999. * separate meshes. This can be use to improve performances.
  30000. * @see https://doc.babylonjs.com/how_to/multi_materials
  30001. * @param name Define the name in the scene
  30002. * @param scene Define the scene the material belongs to
  30003. */
  30004. constructor(name: string, scene: Scene);
  30005. private _hookArray;
  30006. /**
  30007. * Get one of the submaterial by its index in the submaterials array
  30008. * @param index The index to look the sub material at
  30009. * @returns The Material if the index has been defined
  30010. */
  30011. getSubMaterial(index: number): Nullable<Material>;
  30012. /**
  30013. * Get the list of active textures for the whole sub materials list.
  30014. * @returns All the textures that will be used during the rendering
  30015. */
  30016. getActiveTextures(): BaseTexture[];
  30017. /**
  30018. * Specifies if any sub-materials of this multi-material use a given texture.
  30019. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30020. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30021. */
  30022. hasTexture(texture: BaseTexture): boolean;
  30023. /**
  30024. * Gets the current class name of the material e.g. "MultiMaterial"
  30025. * Mainly use in serialization.
  30026. * @returns the class name
  30027. */
  30028. getClassName(): string;
  30029. /**
  30030. * Checks if the material is ready to render the requested sub mesh
  30031. * @param mesh Define the mesh the submesh belongs to
  30032. * @param subMesh Define the sub mesh to look readyness for
  30033. * @param useInstances Define whether or not the material is used with instances
  30034. * @returns true if ready, otherwise false
  30035. */
  30036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30037. /**
  30038. * Clones the current material and its related sub materials
  30039. * @param name Define the name of the newly cloned material
  30040. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30041. * @returns the cloned material
  30042. */
  30043. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30044. /**
  30045. * Serializes the materials into a JSON representation.
  30046. * @returns the JSON representation
  30047. */
  30048. serialize(): any;
  30049. /**
  30050. * Dispose the material and release its associated resources
  30051. * @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)
  30052. * @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)
  30053. * @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)
  30054. */
  30055. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30056. /**
  30057. * Creates a MultiMaterial from parsed MultiMaterial data.
  30058. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30059. * @param scene defines the hosting scene
  30060. * @returns a new MultiMaterial
  30061. */
  30062. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30063. }
  30064. }
  30065. declare module BABYLON {
  30066. /**
  30067. * Defines a subdivision inside a mesh
  30068. */
  30069. export class SubMesh implements ICullable {
  30070. /** the material index to use */
  30071. materialIndex: number;
  30072. /** vertex index start */
  30073. verticesStart: number;
  30074. /** vertices count */
  30075. verticesCount: number;
  30076. /** index start */
  30077. indexStart: number;
  30078. /** indices count */
  30079. indexCount: number;
  30080. /** @hidden */
  30081. _materialDefines: Nullable<MaterialDefines>;
  30082. /** @hidden */
  30083. _materialEffect: Nullable<Effect>;
  30084. /** @hidden */
  30085. _effectOverride: Nullable<Effect>;
  30086. /**
  30087. * Gets material defines used by the effect associated to the sub mesh
  30088. */
  30089. get materialDefines(): Nullable<MaterialDefines>;
  30090. /**
  30091. * Sets material defines used by the effect associated to the sub mesh
  30092. */
  30093. set materialDefines(defines: Nullable<MaterialDefines>);
  30094. /**
  30095. * Gets associated effect
  30096. */
  30097. get effect(): Nullable<Effect>;
  30098. /**
  30099. * Sets associated effect (effect used to render this submesh)
  30100. * @param effect defines the effect to associate with
  30101. * @param defines defines the set of defines used to compile this effect
  30102. */
  30103. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30104. /** @hidden */
  30105. _linesIndexCount: number;
  30106. private _mesh;
  30107. private _renderingMesh;
  30108. private _boundingInfo;
  30109. private _linesIndexBuffer;
  30110. /** @hidden */
  30111. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30112. /** @hidden */
  30113. _trianglePlanes: Plane[];
  30114. /** @hidden */
  30115. _lastColliderTransformMatrix: Nullable<Matrix>;
  30116. /** @hidden */
  30117. _renderId: number;
  30118. /** @hidden */
  30119. _alphaIndex: number;
  30120. /** @hidden */
  30121. _distanceToCamera: number;
  30122. /** @hidden */
  30123. _id: number;
  30124. private _currentMaterial;
  30125. /**
  30126. * Add a new submesh to a mesh
  30127. * @param materialIndex defines the material index to use
  30128. * @param verticesStart defines vertex index start
  30129. * @param verticesCount defines vertices count
  30130. * @param indexStart defines index start
  30131. * @param indexCount defines indices count
  30132. * @param mesh defines the parent mesh
  30133. * @param renderingMesh defines an optional rendering mesh
  30134. * @param createBoundingBox defines if bounding box should be created for this submesh
  30135. * @returns the new submesh
  30136. */
  30137. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30138. /**
  30139. * Creates a new submesh
  30140. * @param materialIndex defines the material index to use
  30141. * @param verticesStart defines vertex index start
  30142. * @param verticesCount defines vertices count
  30143. * @param indexStart defines index start
  30144. * @param indexCount defines indices count
  30145. * @param mesh defines the parent mesh
  30146. * @param renderingMesh defines an optional rendering mesh
  30147. * @param createBoundingBox defines if bounding box should be created for this submesh
  30148. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30149. */
  30150. constructor(
  30151. /** the material index to use */
  30152. materialIndex: number,
  30153. /** vertex index start */
  30154. verticesStart: number,
  30155. /** vertices count */
  30156. verticesCount: number,
  30157. /** index start */
  30158. indexStart: number,
  30159. /** indices count */
  30160. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30161. /**
  30162. * Returns true if this submesh covers the entire parent mesh
  30163. * @ignorenaming
  30164. */
  30165. get IsGlobal(): boolean;
  30166. /**
  30167. * Returns the submesh BoudingInfo object
  30168. * @returns current bounding info (or mesh's one if the submesh is global)
  30169. */
  30170. getBoundingInfo(): BoundingInfo;
  30171. /**
  30172. * Sets the submesh BoundingInfo
  30173. * @param boundingInfo defines the new bounding info to use
  30174. * @returns the SubMesh
  30175. */
  30176. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30177. /**
  30178. * Returns the mesh of the current submesh
  30179. * @return the parent mesh
  30180. */
  30181. getMesh(): AbstractMesh;
  30182. /**
  30183. * Returns the rendering mesh of the submesh
  30184. * @returns the rendering mesh (could be different from parent mesh)
  30185. */
  30186. getRenderingMesh(): Mesh;
  30187. /**
  30188. * Returns the replacement mesh of the submesh
  30189. * @returns the replacement mesh (could be different from parent mesh)
  30190. */
  30191. getReplacementMesh(): Nullable<AbstractMesh>;
  30192. /**
  30193. * Returns the effective mesh of the submesh
  30194. * @returns the effective mesh (could be different from parent mesh)
  30195. */
  30196. getEffectiveMesh(): AbstractMesh;
  30197. /**
  30198. * Returns the submesh material
  30199. * @returns null or the current material
  30200. */
  30201. getMaterial(): Nullable<Material>;
  30202. private _IsMultiMaterial;
  30203. /**
  30204. * Sets a new updated BoundingInfo object to the submesh
  30205. * @param data defines an optional position array to use to determine the bounding info
  30206. * @returns the SubMesh
  30207. */
  30208. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30209. /** @hidden */
  30210. _checkCollision(collider: Collider): boolean;
  30211. /**
  30212. * Updates the submesh BoundingInfo
  30213. * @param world defines the world matrix to use to update the bounding info
  30214. * @returns the submesh
  30215. */
  30216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30217. /**
  30218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30219. * @param frustumPlanes defines the frustum planes
  30220. * @returns true if the submesh is intersecting with the frustum
  30221. */
  30222. isInFrustum(frustumPlanes: Plane[]): boolean;
  30223. /**
  30224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30225. * @param frustumPlanes defines the frustum planes
  30226. * @returns true if the submesh is inside the frustum
  30227. */
  30228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30229. /**
  30230. * Renders the submesh
  30231. * @param enableAlphaMode defines if alpha needs to be used
  30232. * @returns the submesh
  30233. */
  30234. render(enableAlphaMode: boolean): SubMesh;
  30235. /**
  30236. * @hidden
  30237. */
  30238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30239. /**
  30240. * Checks if the submesh intersects with a ray
  30241. * @param ray defines the ray to test
  30242. * @returns true is the passed ray intersects the submesh bounding box
  30243. */
  30244. canIntersects(ray: Ray): boolean;
  30245. /**
  30246. * Intersects current submesh with a ray
  30247. * @param ray defines the ray to test
  30248. * @param positions defines mesh's positions array
  30249. * @param indices defines mesh's indices array
  30250. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30252. * @returns intersection info or null if no intersection
  30253. */
  30254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30255. /** @hidden */
  30256. private _intersectLines;
  30257. /** @hidden */
  30258. private _intersectUnIndexedLines;
  30259. /** @hidden */
  30260. private _intersectTriangles;
  30261. /** @hidden */
  30262. private _intersectUnIndexedTriangles;
  30263. /** @hidden */
  30264. _rebuild(): void;
  30265. /**
  30266. * Creates a new submesh from the passed mesh
  30267. * @param newMesh defines the new hosting mesh
  30268. * @param newRenderingMesh defines an optional rendering mesh
  30269. * @returns the new submesh
  30270. */
  30271. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30272. /**
  30273. * Release associated resources
  30274. */
  30275. dispose(): void;
  30276. /**
  30277. * Gets the class name
  30278. * @returns the string "SubMesh".
  30279. */
  30280. getClassName(): string;
  30281. /**
  30282. * Creates a new submesh from indices data
  30283. * @param materialIndex the index of the main mesh material
  30284. * @param startIndex the index where to start the copy in the mesh indices array
  30285. * @param indexCount the number of indices to copy then from the startIndex
  30286. * @param mesh the main mesh to create the submesh from
  30287. * @param renderingMesh the optional rendering mesh
  30288. * @returns a new submesh
  30289. */
  30290. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30291. }
  30292. }
  30293. declare module BABYLON {
  30294. /**
  30295. * Class used to represent data loading progression
  30296. */
  30297. export class SceneLoaderFlags {
  30298. private static _ForceFullSceneLoadingForIncremental;
  30299. private static _ShowLoadingScreen;
  30300. private static _CleanBoneMatrixWeights;
  30301. private static _loggingLevel;
  30302. /**
  30303. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30304. */
  30305. static get ForceFullSceneLoadingForIncremental(): boolean;
  30306. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30307. /**
  30308. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30309. */
  30310. static get ShowLoadingScreen(): boolean;
  30311. static set ShowLoadingScreen(value: boolean);
  30312. /**
  30313. * Defines the current logging level (while loading the scene)
  30314. * @ignorenaming
  30315. */
  30316. static get loggingLevel(): number;
  30317. static set loggingLevel(value: number);
  30318. /**
  30319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30320. */
  30321. static get CleanBoneMatrixWeights(): boolean;
  30322. static set CleanBoneMatrixWeights(value: boolean);
  30323. }
  30324. }
  30325. declare module BABYLON {
  30326. /**
  30327. * Class used to store geometry data (vertex buffers + index buffer)
  30328. */
  30329. export class Geometry implements IGetSetVerticesData {
  30330. /**
  30331. * Gets or sets the ID of the geometry
  30332. */
  30333. id: string;
  30334. /**
  30335. * Gets or sets the unique ID of the geometry
  30336. */
  30337. uniqueId: number;
  30338. /**
  30339. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30340. */
  30341. delayLoadState: number;
  30342. /**
  30343. * Gets the file containing the data to load when running in delay load state
  30344. */
  30345. delayLoadingFile: Nullable<string>;
  30346. /**
  30347. * Callback called when the geometry is updated
  30348. */
  30349. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30350. private _scene;
  30351. private _engine;
  30352. private _meshes;
  30353. private _totalVertices;
  30354. /** @hidden */
  30355. _indices: IndicesArray;
  30356. /** @hidden */
  30357. _vertexBuffers: {
  30358. [key: string]: VertexBuffer;
  30359. };
  30360. private _isDisposed;
  30361. private _extend;
  30362. private _boundingBias;
  30363. /** @hidden */
  30364. _delayInfo: Array<string>;
  30365. private _indexBuffer;
  30366. private _indexBufferIsUpdatable;
  30367. /** @hidden */
  30368. _boundingInfo: Nullable<BoundingInfo>;
  30369. /** @hidden */
  30370. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30371. /** @hidden */
  30372. _softwareSkinningFrameId: number;
  30373. private _vertexArrayObjects;
  30374. private _updatable;
  30375. /** @hidden */
  30376. _positions: Nullable<Vector3[]>;
  30377. private _positionsCache;
  30378. /**
  30379. * 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
  30380. */
  30381. get boundingBias(): Vector2;
  30382. /**
  30383. * 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
  30384. */
  30385. set boundingBias(value: Vector2);
  30386. /**
  30387. * Static function used to attach a new empty geometry to a mesh
  30388. * @param mesh defines the mesh to attach the geometry to
  30389. * @returns the new Geometry
  30390. */
  30391. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30392. /** Get the list of meshes using this geometry */
  30393. get meshes(): Mesh[];
  30394. /**
  30395. * 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
  30396. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30397. */
  30398. useBoundingInfoFromGeometry: boolean;
  30399. /**
  30400. * Creates a new geometry
  30401. * @param id defines the unique ID
  30402. * @param scene defines the hosting scene
  30403. * @param vertexData defines the VertexData used to get geometry data
  30404. * @param updatable defines if geometry must be updatable (false by default)
  30405. * @param mesh defines the mesh that will be associated with the geometry
  30406. */
  30407. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30408. /**
  30409. * Gets the current extend of the geometry
  30410. */
  30411. get extend(): {
  30412. minimum: Vector3;
  30413. maximum: Vector3;
  30414. };
  30415. /**
  30416. * Gets the hosting scene
  30417. * @returns the hosting Scene
  30418. */
  30419. getScene(): Scene;
  30420. /**
  30421. * Gets the hosting engine
  30422. * @returns the hosting Engine
  30423. */
  30424. getEngine(): Engine;
  30425. /**
  30426. * Defines if the geometry is ready to use
  30427. * @returns true if the geometry is ready to be used
  30428. */
  30429. isReady(): boolean;
  30430. /**
  30431. * Gets a value indicating that the geometry should not be serialized
  30432. */
  30433. get doNotSerialize(): boolean;
  30434. /** @hidden */
  30435. _rebuild(): void;
  30436. /**
  30437. * Affects all geometry data in one call
  30438. * @param vertexData defines the geometry data
  30439. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30440. */
  30441. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30442. /**
  30443. * Set specific vertex data
  30444. * @param kind defines the data kind (Position, normal, etc...)
  30445. * @param data defines the vertex data to use
  30446. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30447. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30448. */
  30449. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30450. /**
  30451. * Removes a specific vertex data
  30452. * @param kind defines the data kind (Position, normal, etc...)
  30453. */
  30454. removeVerticesData(kind: string): void;
  30455. /**
  30456. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30457. * @param buffer defines the vertex buffer to use
  30458. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30459. */
  30460. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30461. /**
  30462. * Update a specific vertex buffer
  30463. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30464. * It will do nothing if the buffer is not updatable
  30465. * @param kind defines the data kind (Position, normal, etc...)
  30466. * @param data defines the data to use
  30467. * @param offset defines the offset in the target buffer where to store the data
  30468. * @param useBytes set to true if the offset is in bytes
  30469. */
  30470. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30471. /**
  30472. * Update a specific vertex buffer
  30473. * This function will create a new buffer if the current one is not updatable
  30474. * @param kind defines the data kind (Position, normal, etc...)
  30475. * @param data defines the data to use
  30476. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30477. */
  30478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30479. private _updateBoundingInfo;
  30480. /** @hidden */
  30481. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30482. /**
  30483. * Gets total number of vertices
  30484. * @returns the total number of vertices
  30485. */
  30486. getTotalVertices(): number;
  30487. /**
  30488. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30489. * @param kind defines the data kind (Position, normal, etc...)
  30490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30492. * @returns a float array containing vertex data
  30493. */
  30494. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30495. /**
  30496. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30497. * @param kind defines the data kind (Position, normal, etc...)
  30498. * @returns true if the vertex buffer with the specified kind is updatable
  30499. */
  30500. isVertexBufferUpdatable(kind: string): boolean;
  30501. /**
  30502. * Gets a specific vertex buffer
  30503. * @param kind defines the data kind (Position, normal, etc...)
  30504. * @returns a VertexBuffer
  30505. */
  30506. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30507. /**
  30508. * Returns all vertex buffers
  30509. * @return an object holding all vertex buffers indexed by kind
  30510. */
  30511. getVertexBuffers(): Nullable<{
  30512. [key: string]: VertexBuffer;
  30513. }>;
  30514. /**
  30515. * Gets a boolean indicating if specific vertex buffer is present
  30516. * @param kind defines the data kind (Position, normal, etc...)
  30517. * @returns true if data is present
  30518. */
  30519. isVerticesDataPresent(kind: string): boolean;
  30520. /**
  30521. * Gets a list of all attached data kinds (Position, normal, etc...)
  30522. * @returns a list of string containing all kinds
  30523. */
  30524. getVerticesDataKinds(): string[];
  30525. /**
  30526. * Update index buffer
  30527. * @param indices defines the indices to store in the index buffer
  30528. * @param offset defines the offset in the target buffer where to store the data
  30529. * @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)
  30530. */
  30531. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30532. /**
  30533. * Creates a new index buffer
  30534. * @param indices defines the indices to store in the index buffer
  30535. * @param totalVertices defines the total number of vertices (could be null)
  30536. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30537. */
  30538. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30539. /**
  30540. * Return the total number of indices
  30541. * @returns the total number of indices
  30542. */
  30543. getTotalIndices(): number;
  30544. /**
  30545. * Gets the index buffer array
  30546. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30547. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30548. * @returns the index buffer array
  30549. */
  30550. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30551. /**
  30552. * Gets the index buffer
  30553. * @return the index buffer
  30554. */
  30555. getIndexBuffer(): Nullable<DataBuffer>;
  30556. /** @hidden */
  30557. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30558. /**
  30559. * Release the associated resources for a specific mesh
  30560. * @param mesh defines the source mesh
  30561. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30562. */
  30563. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30564. /**
  30565. * Apply current geometry to a given mesh
  30566. * @param mesh defines the mesh to apply geometry to
  30567. */
  30568. applyToMesh(mesh: Mesh): void;
  30569. private _updateExtend;
  30570. private _applyToMesh;
  30571. private notifyUpdate;
  30572. /**
  30573. * Load the geometry if it was flagged as delay loaded
  30574. * @param scene defines the hosting scene
  30575. * @param onLoaded defines a callback called when the geometry is loaded
  30576. */
  30577. load(scene: Scene, onLoaded?: () => void): void;
  30578. private _queueLoad;
  30579. /**
  30580. * Invert the geometry to move from a right handed system to a left handed one.
  30581. */
  30582. toLeftHanded(): void;
  30583. /** @hidden */
  30584. _resetPointsArrayCache(): void;
  30585. /** @hidden */
  30586. _generatePointsArray(): boolean;
  30587. /**
  30588. * Gets a value indicating if the geometry is disposed
  30589. * @returns true if the geometry was disposed
  30590. */
  30591. isDisposed(): boolean;
  30592. private _disposeVertexArrayObjects;
  30593. /**
  30594. * Free all associated resources
  30595. */
  30596. dispose(): void;
  30597. /**
  30598. * Clone the current geometry into a new geometry
  30599. * @param id defines the unique ID of the new geometry
  30600. * @returns a new geometry object
  30601. */
  30602. copy(id: string): Geometry;
  30603. /**
  30604. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30605. * @return a JSON representation of the current geometry data (without the vertices data)
  30606. */
  30607. serialize(): any;
  30608. private toNumberArray;
  30609. /**
  30610. * Serialize all vertices data into a JSON oject
  30611. * @returns a JSON representation of the current geometry data
  30612. */
  30613. serializeVerticeData(): any;
  30614. /**
  30615. * Extracts a clone of a mesh geometry
  30616. * @param mesh defines the source mesh
  30617. * @param id defines the unique ID of the new geometry object
  30618. * @returns the new geometry object
  30619. */
  30620. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30621. /**
  30622. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30623. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30624. * Be aware Math.random() could cause collisions, but:
  30625. * "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"
  30626. * @returns a string containing a new GUID
  30627. */
  30628. static RandomId(): string;
  30629. /** @hidden */
  30630. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30631. private static _CleanMatricesWeights;
  30632. /**
  30633. * Create a new geometry from persisted data (Using .babylon file format)
  30634. * @param parsedVertexData defines the persisted data
  30635. * @param scene defines the hosting scene
  30636. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30637. * @returns the new geometry object
  30638. */
  30639. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30640. }
  30641. }
  30642. declare module BABYLON {
  30643. /**
  30644. * Defines a target to use with MorphTargetManager
  30645. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30646. */
  30647. export class MorphTarget implements IAnimatable {
  30648. /** defines the name of the target */
  30649. name: string;
  30650. /**
  30651. * Gets or sets the list of animations
  30652. */
  30653. animations: Animation[];
  30654. private _scene;
  30655. private _positions;
  30656. private _normals;
  30657. private _tangents;
  30658. private _uvs;
  30659. private _influence;
  30660. private _uniqueId;
  30661. /**
  30662. * Observable raised when the influence changes
  30663. */
  30664. onInfluenceChanged: Observable<boolean>;
  30665. /** @hidden */
  30666. _onDataLayoutChanged: Observable<void>;
  30667. /**
  30668. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30669. */
  30670. get influence(): number;
  30671. set influence(influence: number);
  30672. /**
  30673. * Gets or sets the id of the morph Target
  30674. */
  30675. id: string;
  30676. private _animationPropertiesOverride;
  30677. /**
  30678. * Gets or sets the animation properties override
  30679. */
  30680. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30681. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30682. /**
  30683. * Creates a new MorphTarget
  30684. * @param name defines the name of the target
  30685. * @param influence defines the influence to use
  30686. * @param scene defines the scene the morphtarget belongs to
  30687. */
  30688. constructor(
  30689. /** defines the name of the target */
  30690. name: string, influence?: number, scene?: Nullable<Scene>);
  30691. /**
  30692. * Gets the unique ID of this manager
  30693. */
  30694. get uniqueId(): number;
  30695. /**
  30696. * Gets a boolean defining if the target contains position data
  30697. */
  30698. get hasPositions(): boolean;
  30699. /**
  30700. * Gets a boolean defining if the target contains normal data
  30701. */
  30702. get hasNormals(): boolean;
  30703. /**
  30704. * Gets a boolean defining if the target contains tangent data
  30705. */
  30706. get hasTangents(): boolean;
  30707. /**
  30708. * Gets a boolean defining if the target contains texture coordinates data
  30709. */
  30710. get hasUVs(): boolean;
  30711. /**
  30712. * Affects position data to this target
  30713. * @param data defines the position data to use
  30714. */
  30715. setPositions(data: Nullable<FloatArray>): void;
  30716. /**
  30717. * Gets the position data stored in this target
  30718. * @returns a FloatArray containing the position data (or null if not present)
  30719. */
  30720. getPositions(): Nullable<FloatArray>;
  30721. /**
  30722. * Affects normal data to this target
  30723. * @param data defines the normal data to use
  30724. */
  30725. setNormals(data: Nullable<FloatArray>): void;
  30726. /**
  30727. * Gets the normal data stored in this target
  30728. * @returns a FloatArray containing the normal data (or null if not present)
  30729. */
  30730. getNormals(): Nullable<FloatArray>;
  30731. /**
  30732. * Affects tangent data to this target
  30733. * @param data defines the tangent data to use
  30734. */
  30735. setTangents(data: Nullable<FloatArray>): void;
  30736. /**
  30737. * Gets the tangent data stored in this target
  30738. * @returns a FloatArray containing the tangent data (or null if not present)
  30739. */
  30740. getTangents(): Nullable<FloatArray>;
  30741. /**
  30742. * Affects texture coordinates data to this target
  30743. * @param data defines the texture coordinates data to use
  30744. */
  30745. setUVs(data: Nullable<FloatArray>): void;
  30746. /**
  30747. * Gets the texture coordinates data stored in this target
  30748. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30749. */
  30750. getUVs(): Nullable<FloatArray>;
  30751. /**
  30752. * Clone the current target
  30753. * @returns a new MorphTarget
  30754. */
  30755. clone(): MorphTarget;
  30756. /**
  30757. * Serializes the current target into a Serialization object
  30758. * @returns the serialized object
  30759. */
  30760. serialize(): any;
  30761. /**
  30762. * Returns the string "MorphTarget"
  30763. * @returns "MorphTarget"
  30764. */
  30765. getClassName(): string;
  30766. /**
  30767. * Creates a new target from serialized data
  30768. * @param serializationObject defines the serialized data to use
  30769. * @returns a new MorphTarget
  30770. */
  30771. static Parse(serializationObject: any): MorphTarget;
  30772. /**
  30773. * Creates a MorphTarget from mesh data
  30774. * @param mesh defines the source mesh
  30775. * @param name defines the name to use for the new target
  30776. * @param influence defines the influence to attach to the target
  30777. * @returns a new MorphTarget
  30778. */
  30779. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30780. }
  30781. }
  30782. declare module BABYLON {
  30783. /**
  30784. * This class is used to deform meshes using morphing between different targets
  30785. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30786. */
  30787. export class MorphTargetManager {
  30788. private _targets;
  30789. private _targetInfluenceChangedObservers;
  30790. private _targetDataLayoutChangedObservers;
  30791. private _activeTargets;
  30792. private _scene;
  30793. private _influences;
  30794. private _supportsNormals;
  30795. private _supportsTangents;
  30796. private _supportsUVs;
  30797. private _vertexCount;
  30798. private _uniqueId;
  30799. private _tempInfluences;
  30800. /**
  30801. * Gets or sets a boolean indicating if normals must be morphed
  30802. */
  30803. enableNormalMorphing: boolean;
  30804. /**
  30805. * Gets or sets a boolean indicating if tangents must be morphed
  30806. */
  30807. enableTangentMorphing: boolean;
  30808. /**
  30809. * Gets or sets a boolean indicating if UV must be morphed
  30810. */
  30811. enableUVMorphing: boolean;
  30812. /**
  30813. * Creates a new MorphTargetManager
  30814. * @param scene defines the current scene
  30815. */
  30816. constructor(scene?: Nullable<Scene>);
  30817. /**
  30818. * Gets the unique ID of this manager
  30819. */
  30820. get uniqueId(): number;
  30821. /**
  30822. * Gets the number of vertices handled by this manager
  30823. */
  30824. get vertexCount(): number;
  30825. /**
  30826. * Gets a boolean indicating if this manager supports morphing of normals
  30827. */
  30828. get supportsNormals(): boolean;
  30829. /**
  30830. * Gets a boolean indicating if this manager supports morphing of tangents
  30831. */
  30832. get supportsTangents(): boolean;
  30833. /**
  30834. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30835. */
  30836. get supportsUVs(): boolean;
  30837. /**
  30838. * Gets the number of targets stored in this manager
  30839. */
  30840. get numTargets(): number;
  30841. /**
  30842. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30843. */
  30844. get numInfluencers(): number;
  30845. /**
  30846. * Gets the list of influences (one per target)
  30847. */
  30848. get influences(): Float32Array;
  30849. /**
  30850. * Gets the active target at specified index. An active target is a target with an influence > 0
  30851. * @param index defines the index to check
  30852. * @returns the requested target
  30853. */
  30854. getActiveTarget(index: number): MorphTarget;
  30855. /**
  30856. * Gets the target at specified index
  30857. * @param index defines the index to check
  30858. * @returns the requested target
  30859. */
  30860. getTarget(index: number): MorphTarget;
  30861. /**
  30862. * Add a new target to this manager
  30863. * @param target defines the target to add
  30864. */
  30865. addTarget(target: MorphTarget): void;
  30866. /**
  30867. * Removes a target from the manager
  30868. * @param target defines the target to remove
  30869. */
  30870. removeTarget(target: MorphTarget): void;
  30871. /**
  30872. * Clone the current manager
  30873. * @returns a new MorphTargetManager
  30874. */
  30875. clone(): MorphTargetManager;
  30876. /**
  30877. * Serializes the current manager into a Serialization object
  30878. * @returns the serialized object
  30879. */
  30880. serialize(): any;
  30881. private _syncActiveTargets;
  30882. /**
  30883. * Syncrhonize the targets with all the meshes using this morph target manager
  30884. */
  30885. synchronize(): void;
  30886. /**
  30887. * Creates a new MorphTargetManager from serialized data
  30888. * @param serializationObject defines the serialized data
  30889. * @param scene defines the hosting scene
  30890. * @returns the new MorphTargetManager
  30891. */
  30892. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30893. }
  30894. }
  30895. declare module BABYLON {
  30896. /**
  30897. * Class used to represent a specific level of detail of a mesh
  30898. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30899. */
  30900. export class MeshLODLevel {
  30901. /** Defines the distance where this level should start being displayed */
  30902. distance: number;
  30903. /** Defines the mesh to use to render this level */
  30904. mesh: Nullable<Mesh>;
  30905. /**
  30906. * Creates a new LOD level
  30907. * @param distance defines the distance where this level should star being displayed
  30908. * @param mesh defines the mesh to use to render this level
  30909. */
  30910. constructor(
  30911. /** Defines the distance where this level should start being displayed */
  30912. distance: number,
  30913. /** Defines the mesh to use to render this level */
  30914. mesh: Nullable<Mesh>);
  30915. }
  30916. }
  30917. declare module BABYLON {
  30918. /**
  30919. * Helper class used to generate a canvas to manipulate images
  30920. */
  30921. export class CanvasGenerator {
  30922. /**
  30923. * Create a new canvas (or offscreen canvas depending on the context)
  30924. * @param width defines the expected width
  30925. * @param height defines the expected height
  30926. * @return a new canvas or offscreen canvas
  30927. */
  30928. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30929. }
  30930. }
  30931. declare module BABYLON {
  30932. /**
  30933. * Mesh representing the gorund
  30934. */
  30935. export class GroundMesh extends Mesh {
  30936. /** If octree should be generated */
  30937. generateOctree: boolean;
  30938. private _heightQuads;
  30939. /** @hidden */
  30940. _subdivisionsX: number;
  30941. /** @hidden */
  30942. _subdivisionsY: number;
  30943. /** @hidden */
  30944. _width: number;
  30945. /** @hidden */
  30946. _height: number;
  30947. /** @hidden */
  30948. _minX: number;
  30949. /** @hidden */
  30950. _maxX: number;
  30951. /** @hidden */
  30952. _minZ: number;
  30953. /** @hidden */
  30954. _maxZ: number;
  30955. constructor(name: string, scene: Scene);
  30956. /**
  30957. * "GroundMesh"
  30958. * @returns "GroundMesh"
  30959. */
  30960. getClassName(): string;
  30961. /**
  30962. * The minimum of x and y subdivisions
  30963. */
  30964. get subdivisions(): number;
  30965. /**
  30966. * X subdivisions
  30967. */
  30968. get subdivisionsX(): number;
  30969. /**
  30970. * Y subdivisions
  30971. */
  30972. get subdivisionsY(): number;
  30973. /**
  30974. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30976. * @param chunksCount the number of subdivisions for x and y
  30977. * @param octreeBlocksSize (Default: 32)
  30978. */
  30979. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30980. /**
  30981. * Returns a height (y) value in the Worl system :
  30982. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30983. * @param x x coordinate
  30984. * @param z z coordinate
  30985. * @returns the ground y position if (x, z) are outside the ground surface.
  30986. */
  30987. getHeightAtCoordinates(x: number, z: number): number;
  30988. /**
  30989. * Returns a normalized vector (Vector3) orthogonal to the ground
  30990. * at the ground coordinates (x, z) expressed in the World system.
  30991. * @param x x coordinate
  30992. * @param z z coordinate
  30993. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30994. */
  30995. getNormalAtCoordinates(x: number, z: number): Vector3;
  30996. /**
  30997. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30998. * at the ground coordinates (x, z) expressed in the World system.
  30999. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31000. * @param x x coordinate
  31001. * @param z z coordinate
  31002. * @param ref vector to store the result
  31003. * @returns the GroundMesh.
  31004. */
  31005. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31006. /**
  31007. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31008. * if the ground has been updated.
  31009. * This can be used in the render loop.
  31010. * @returns the GroundMesh.
  31011. */
  31012. updateCoordinateHeights(): GroundMesh;
  31013. private _getFacetAt;
  31014. private _initHeightQuads;
  31015. private _computeHeightQuads;
  31016. /**
  31017. * Serializes this ground mesh
  31018. * @param serializationObject object to write serialization to
  31019. */
  31020. serialize(serializationObject: any): void;
  31021. /**
  31022. * Parses a serialized ground mesh
  31023. * @param parsedMesh the serialized mesh
  31024. * @param scene the scene to create the ground mesh in
  31025. * @returns the created ground mesh
  31026. */
  31027. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31028. }
  31029. }
  31030. declare module BABYLON {
  31031. /**
  31032. * Interface for Physics-Joint data
  31033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31034. */
  31035. export interface PhysicsJointData {
  31036. /**
  31037. * The main pivot of the joint
  31038. */
  31039. mainPivot?: Vector3;
  31040. /**
  31041. * The connected pivot of the joint
  31042. */
  31043. connectedPivot?: Vector3;
  31044. /**
  31045. * The main axis of the joint
  31046. */
  31047. mainAxis?: Vector3;
  31048. /**
  31049. * The connected axis of the joint
  31050. */
  31051. connectedAxis?: Vector3;
  31052. /**
  31053. * The collision of the joint
  31054. */
  31055. collision?: boolean;
  31056. /**
  31057. * Native Oimo/Cannon/Energy data
  31058. */
  31059. nativeParams?: any;
  31060. }
  31061. /**
  31062. * This is a holder class for the physics joint created by the physics plugin
  31063. * It holds a set of functions to control the underlying joint
  31064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31065. */
  31066. export class PhysicsJoint {
  31067. /**
  31068. * The type of the physics joint
  31069. */
  31070. type: number;
  31071. /**
  31072. * The data for the physics joint
  31073. */
  31074. jointData: PhysicsJointData;
  31075. private _physicsJoint;
  31076. protected _physicsPlugin: IPhysicsEnginePlugin;
  31077. /**
  31078. * Initializes the physics joint
  31079. * @param type The type of the physics joint
  31080. * @param jointData The data for the physics joint
  31081. */
  31082. constructor(
  31083. /**
  31084. * The type of the physics joint
  31085. */
  31086. type: number,
  31087. /**
  31088. * The data for the physics joint
  31089. */
  31090. jointData: PhysicsJointData);
  31091. /**
  31092. * Gets the physics joint
  31093. */
  31094. get physicsJoint(): any;
  31095. /**
  31096. * Sets the physics joint
  31097. */
  31098. set physicsJoint(newJoint: any);
  31099. /**
  31100. * Sets the physics plugin
  31101. */
  31102. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31103. /**
  31104. * Execute a function that is physics-plugin specific.
  31105. * @param {Function} func the function that will be executed.
  31106. * It accepts two parameters: the physics world and the physics joint
  31107. */
  31108. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31109. /**
  31110. * Distance-Joint type
  31111. */
  31112. static DistanceJoint: number;
  31113. /**
  31114. * Hinge-Joint type
  31115. */
  31116. static HingeJoint: number;
  31117. /**
  31118. * Ball-and-Socket joint type
  31119. */
  31120. static BallAndSocketJoint: number;
  31121. /**
  31122. * Wheel-Joint type
  31123. */
  31124. static WheelJoint: number;
  31125. /**
  31126. * Slider-Joint type
  31127. */
  31128. static SliderJoint: number;
  31129. /**
  31130. * Prismatic-Joint type
  31131. */
  31132. static PrismaticJoint: number;
  31133. /**
  31134. * Universal-Joint type
  31135. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31136. */
  31137. static UniversalJoint: number;
  31138. /**
  31139. * Hinge-Joint 2 type
  31140. */
  31141. static Hinge2Joint: number;
  31142. /**
  31143. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31144. */
  31145. static PointToPointJoint: number;
  31146. /**
  31147. * Spring-Joint type
  31148. */
  31149. static SpringJoint: number;
  31150. /**
  31151. * Lock-Joint type
  31152. */
  31153. static LockJoint: number;
  31154. }
  31155. /**
  31156. * A class representing a physics distance joint
  31157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31158. */
  31159. export class DistanceJoint extends PhysicsJoint {
  31160. /**
  31161. *
  31162. * @param jointData The data for the Distance-Joint
  31163. */
  31164. constructor(jointData: DistanceJointData);
  31165. /**
  31166. * Update the predefined distance.
  31167. * @param maxDistance The maximum preferred distance
  31168. * @param minDistance The minimum preferred distance
  31169. */
  31170. updateDistance(maxDistance: number, minDistance?: number): void;
  31171. }
  31172. /**
  31173. * Represents a Motor-Enabled Joint
  31174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31175. */
  31176. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31177. /**
  31178. * Initializes the Motor-Enabled Joint
  31179. * @param type The type of the joint
  31180. * @param jointData The physica joint data for the joint
  31181. */
  31182. constructor(type: number, jointData: PhysicsJointData);
  31183. /**
  31184. * Set the motor values.
  31185. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31186. * @param force the force to apply
  31187. * @param maxForce max force for this motor.
  31188. */
  31189. setMotor(force?: number, maxForce?: number): void;
  31190. /**
  31191. * Set the motor's limits.
  31192. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31193. * @param upperLimit The upper limit of the motor
  31194. * @param lowerLimit The lower limit of the motor
  31195. */
  31196. setLimit(upperLimit: number, lowerLimit?: number): void;
  31197. }
  31198. /**
  31199. * This class represents a single physics Hinge-Joint
  31200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31201. */
  31202. export class HingeJoint extends MotorEnabledJoint {
  31203. /**
  31204. * Initializes the Hinge-Joint
  31205. * @param jointData The joint data for the Hinge-Joint
  31206. */
  31207. constructor(jointData: PhysicsJointData);
  31208. /**
  31209. * Set the motor values.
  31210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31211. * @param {number} force the force to apply
  31212. * @param {number} maxForce max force for this motor.
  31213. */
  31214. setMotor(force?: number, maxForce?: number): void;
  31215. /**
  31216. * Set the motor's limits.
  31217. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31218. * @param upperLimit The upper limit of the motor
  31219. * @param lowerLimit The lower limit of the motor
  31220. */
  31221. setLimit(upperLimit: number, lowerLimit?: number): void;
  31222. }
  31223. /**
  31224. * This class represents a dual hinge physics joint (same as wheel joint)
  31225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31226. */
  31227. export class Hinge2Joint extends MotorEnabledJoint {
  31228. /**
  31229. * Initializes the Hinge2-Joint
  31230. * @param jointData The joint data for the Hinge2-Joint
  31231. */
  31232. constructor(jointData: PhysicsJointData);
  31233. /**
  31234. * Set the motor values.
  31235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31236. * @param {number} targetSpeed the speed the motor is to reach
  31237. * @param {number} maxForce max force for this motor.
  31238. * @param {motorIndex} the motor's index, 0 or 1.
  31239. */
  31240. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31241. /**
  31242. * Set the motor limits.
  31243. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31244. * @param {number} upperLimit the upper limit
  31245. * @param {number} lowerLimit lower limit
  31246. * @param {motorIndex} the motor's index, 0 or 1.
  31247. */
  31248. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31249. }
  31250. /**
  31251. * Interface for a motor enabled joint
  31252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31253. */
  31254. export interface IMotorEnabledJoint {
  31255. /**
  31256. * Physics joint
  31257. */
  31258. physicsJoint: any;
  31259. /**
  31260. * Sets the motor of the motor-enabled joint
  31261. * @param force The force of the motor
  31262. * @param maxForce The maximum force of the motor
  31263. * @param motorIndex The index of the motor
  31264. */
  31265. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31266. /**
  31267. * Sets the limit of the motor
  31268. * @param upperLimit The upper limit of the motor
  31269. * @param lowerLimit The lower limit of the motor
  31270. * @param motorIndex The index of the motor
  31271. */
  31272. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31273. }
  31274. /**
  31275. * Joint data for a Distance-Joint
  31276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31277. */
  31278. export interface DistanceJointData extends PhysicsJointData {
  31279. /**
  31280. * Max distance the 2 joint objects can be apart
  31281. */
  31282. maxDistance: number;
  31283. }
  31284. /**
  31285. * Joint data from a spring joint
  31286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31287. */
  31288. export interface SpringJointData extends PhysicsJointData {
  31289. /**
  31290. * Length of the spring
  31291. */
  31292. length: number;
  31293. /**
  31294. * Stiffness of the spring
  31295. */
  31296. stiffness: number;
  31297. /**
  31298. * Damping of the spring
  31299. */
  31300. damping: number;
  31301. /** this callback will be called when applying the force to the impostors. */
  31302. forceApplicationCallback: () => void;
  31303. }
  31304. }
  31305. declare module BABYLON {
  31306. /**
  31307. * Holds the data for the raycast result
  31308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31309. */
  31310. export class PhysicsRaycastResult {
  31311. private _hasHit;
  31312. private _hitDistance;
  31313. private _hitNormalWorld;
  31314. private _hitPointWorld;
  31315. private _rayFromWorld;
  31316. private _rayToWorld;
  31317. /**
  31318. * Gets if there was a hit
  31319. */
  31320. get hasHit(): boolean;
  31321. /**
  31322. * Gets the distance from the hit
  31323. */
  31324. get hitDistance(): number;
  31325. /**
  31326. * Gets the hit normal/direction in the world
  31327. */
  31328. get hitNormalWorld(): Vector3;
  31329. /**
  31330. * Gets the hit point in the world
  31331. */
  31332. get hitPointWorld(): Vector3;
  31333. /**
  31334. * Gets the ray "start point" of the ray in the world
  31335. */
  31336. get rayFromWorld(): Vector3;
  31337. /**
  31338. * Gets the ray "end point" of the ray in the world
  31339. */
  31340. get rayToWorld(): Vector3;
  31341. /**
  31342. * Sets the hit data (normal & point in world space)
  31343. * @param hitNormalWorld defines the normal in world space
  31344. * @param hitPointWorld defines the point in world space
  31345. */
  31346. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31347. /**
  31348. * Sets the distance from the start point to the hit point
  31349. * @param distance
  31350. */
  31351. setHitDistance(distance: number): void;
  31352. /**
  31353. * Calculates the distance manually
  31354. */
  31355. calculateHitDistance(): void;
  31356. /**
  31357. * Resets all the values to default
  31358. * @param from The from point on world space
  31359. * @param to The to point on world space
  31360. */
  31361. reset(from?: Vector3, to?: Vector3): void;
  31362. }
  31363. /**
  31364. * Interface for the size containing width and height
  31365. */
  31366. interface IXYZ {
  31367. /**
  31368. * X
  31369. */
  31370. x: number;
  31371. /**
  31372. * Y
  31373. */
  31374. y: number;
  31375. /**
  31376. * Z
  31377. */
  31378. z: number;
  31379. }
  31380. }
  31381. declare module BABYLON {
  31382. /**
  31383. * Interface used to describe a physics joint
  31384. */
  31385. export interface PhysicsImpostorJoint {
  31386. /** Defines the main impostor to which the joint is linked */
  31387. mainImpostor: PhysicsImpostor;
  31388. /** Defines the impostor that is connected to the main impostor using this joint */
  31389. connectedImpostor: PhysicsImpostor;
  31390. /** Defines the joint itself */
  31391. joint: PhysicsJoint;
  31392. }
  31393. /** @hidden */
  31394. export interface IPhysicsEnginePlugin {
  31395. world: any;
  31396. name: string;
  31397. setGravity(gravity: Vector3): void;
  31398. setTimeStep(timeStep: number): void;
  31399. getTimeStep(): number;
  31400. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31401. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31402. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31403. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31404. removePhysicsBody(impostor: PhysicsImpostor): void;
  31405. generateJoint(joint: PhysicsImpostorJoint): void;
  31406. removeJoint(joint: PhysicsImpostorJoint): void;
  31407. isSupported(): boolean;
  31408. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31409. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31410. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31411. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31412. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31413. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31414. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31415. getBodyMass(impostor: PhysicsImpostor): number;
  31416. getBodyFriction(impostor: PhysicsImpostor): number;
  31417. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31418. getBodyRestitution(impostor: PhysicsImpostor): number;
  31419. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31420. getBodyPressure?(impostor: PhysicsImpostor): number;
  31421. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31422. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31423. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31424. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31425. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31426. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31427. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31428. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31429. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31430. sleepBody(impostor: PhysicsImpostor): void;
  31431. wakeUpBody(impostor: PhysicsImpostor): void;
  31432. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31434. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31435. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31436. getRadius(impostor: PhysicsImpostor): number;
  31437. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31438. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31439. dispose(): void;
  31440. }
  31441. /**
  31442. * Interface used to define a physics engine
  31443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31444. */
  31445. export interface IPhysicsEngine {
  31446. /**
  31447. * Gets the gravity vector used by the simulation
  31448. */
  31449. gravity: Vector3;
  31450. /**
  31451. * Sets the gravity vector used by the simulation
  31452. * @param gravity defines the gravity vector to use
  31453. */
  31454. setGravity(gravity: Vector3): void;
  31455. /**
  31456. * Set the time step of the physics engine.
  31457. * Default is 1/60.
  31458. * To slow it down, enter 1/600 for example.
  31459. * To speed it up, 1/30
  31460. * @param newTimeStep the new timestep to apply to this world.
  31461. */
  31462. setTimeStep(newTimeStep: number): void;
  31463. /**
  31464. * Get the time step of the physics engine.
  31465. * @returns the current time step
  31466. */
  31467. getTimeStep(): number;
  31468. /**
  31469. * Set the sub time step of the physics engine.
  31470. * Default is 0 meaning there is no sub steps
  31471. * To increase physics resolution precision, set a small value (like 1 ms)
  31472. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31473. */
  31474. setSubTimeStep(subTimeStep: number): void;
  31475. /**
  31476. * Get the sub time step of the physics engine.
  31477. * @returns the current sub time step
  31478. */
  31479. getSubTimeStep(): number;
  31480. /**
  31481. * Release all resources
  31482. */
  31483. dispose(): void;
  31484. /**
  31485. * Gets the name of the current physics plugin
  31486. * @returns the name of the plugin
  31487. */
  31488. getPhysicsPluginName(): string;
  31489. /**
  31490. * Adding a new impostor for the impostor tracking.
  31491. * This will be done by the impostor itself.
  31492. * @param impostor the impostor to add
  31493. */
  31494. addImpostor(impostor: PhysicsImpostor): void;
  31495. /**
  31496. * Remove an impostor from the engine.
  31497. * This impostor and its mesh will not longer be updated by the physics engine.
  31498. * @param impostor the impostor to remove
  31499. */
  31500. removeImpostor(impostor: PhysicsImpostor): void;
  31501. /**
  31502. * Add a joint to the physics engine
  31503. * @param mainImpostor defines the main impostor to which the joint is added.
  31504. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31505. * @param joint defines the joint that will connect both impostors.
  31506. */
  31507. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31508. /**
  31509. * Removes a joint from the simulation
  31510. * @param mainImpostor defines the impostor used with the joint
  31511. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31512. * @param joint defines the joint to remove
  31513. */
  31514. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31515. /**
  31516. * Gets the current plugin used to run the simulation
  31517. * @returns current plugin
  31518. */
  31519. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31520. /**
  31521. * Gets the list of physic impostors
  31522. * @returns an array of PhysicsImpostor
  31523. */
  31524. getImpostors(): Array<PhysicsImpostor>;
  31525. /**
  31526. * Gets the impostor for a physics enabled object
  31527. * @param object defines the object impersonated by the impostor
  31528. * @returns the PhysicsImpostor or null if not found
  31529. */
  31530. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31531. /**
  31532. * Gets the impostor for a physics body object
  31533. * @param body defines physics body used by the impostor
  31534. * @returns the PhysicsImpostor or null if not found
  31535. */
  31536. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31537. /**
  31538. * Does a raycast in the physics world
  31539. * @param from when should the ray start?
  31540. * @param to when should the ray end?
  31541. * @returns PhysicsRaycastResult
  31542. */
  31543. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31544. /**
  31545. * Called by the scene. No need to call it.
  31546. * @param delta defines the timespam between frames
  31547. */
  31548. _step(delta: number): void;
  31549. }
  31550. }
  31551. declare module BABYLON {
  31552. /**
  31553. * The interface for the physics imposter parameters
  31554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31555. */
  31556. export interface PhysicsImpostorParameters {
  31557. /**
  31558. * The mass of the physics imposter
  31559. */
  31560. mass: number;
  31561. /**
  31562. * The friction of the physics imposter
  31563. */
  31564. friction?: number;
  31565. /**
  31566. * The coefficient of restitution of the physics imposter
  31567. */
  31568. restitution?: number;
  31569. /**
  31570. * The native options of the physics imposter
  31571. */
  31572. nativeOptions?: any;
  31573. /**
  31574. * Specifies if the parent should be ignored
  31575. */
  31576. ignoreParent?: boolean;
  31577. /**
  31578. * Specifies if bi-directional transformations should be disabled
  31579. */
  31580. disableBidirectionalTransformation?: boolean;
  31581. /**
  31582. * The pressure inside the physics imposter, soft object only
  31583. */
  31584. pressure?: number;
  31585. /**
  31586. * The stiffness the physics imposter, soft object only
  31587. */
  31588. stiffness?: number;
  31589. /**
  31590. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31591. */
  31592. velocityIterations?: number;
  31593. /**
  31594. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31595. */
  31596. positionIterations?: number;
  31597. /**
  31598. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31599. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31600. * Add to fix multiple points
  31601. */
  31602. fixedPoints?: number;
  31603. /**
  31604. * The collision margin around a soft object
  31605. */
  31606. margin?: number;
  31607. /**
  31608. * The collision margin around a soft object
  31609. */
  31610. damping?: number;
  31611. /**
  31612. * The path for a rope based on an extrusion
  31613. */
  31614. path?: any;
  31615. /**
  31616. * The shape of an extrusion used for a rope based on an extrusion
  31617. */
  31618. shape?: any;
  31619. }
  31620. /**
  31621. * Interface for a physics-enabled object
  31622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31623. */
  31624. export interface IPhysicsEnabledObject {
  31625. /**
  31626. * The position of the physics-enabled object
  31627. */
  31628. position: Vector3;
  31629. /**
  31630. * The rotation of the physics-enabled object
  31631. */
  31632. rotationQuaternion: Nullable<Quaternion>;
  31633. /**
  31634. * The scale of the physics-enabled object
  31635. */
  31636. scaling: Vector3;
  31637. /**
  31638. * The rotation of the physics-enabled object
  31639. */
  31640. rotation?: Vector3;
  31641. /**
  31642. * The parent of the physics-enabled object
  31643. */
  31644. parent?: any;
  31645. /**
  31646. * The bounding info of the physics-enabled object
  31647. * @returns The bounding info of the physics-enabled object
  31648. */
  31649. getBoundingInfo(): BoundingInfo;
  31650. /**
  31651. * Computes the world matrix
  31652. * @param force Specifies if the world matrix should be computed by force
  31653. * @returns A world matrix
  31654. */
  31655. computeWorldMatrix(force: boolean): Matrix;
  31656. /**
  31657. * Gets the world matrix
  31658. * @returns A world matrix
  31659. */
  31660. getWorldMatrix?(): Matrix;
  31661. /**
  31662. * Gets the child meshes
  31663. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31664. * @returns An array of abstract meshes
  31665. */
  31666. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31667. /**
  31668. * Gets the vertex data
  31669. * @param kind The type of vertex data
  31670. * @returns A nullable array of numbers, or a float32 array
  31671. */
  31672. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31673. /**
  31674. * Gets the indices from the mesh
  31675. * @returns A nullable array of index arrays
  31676. */
  31677. getIndices?(): Nullable<IndicesArray>;
  31678. /**
  31679. * Gets the scene from the mesh
  31680. * @returns the indices array or null
  31681. */
  31682. getScene?(): Scene;
  31683. /**
  31684. * Gets the absolute position from the mesh
  31685. * @returns the absolute position
  31686. */
  31687. getAbsolutePosition(): Vector3;
  31688. /**
  31689. * Gets the absolute pivot point from the mesh
  31690. * @returns the absolute pivot point
  31691. */
  31692. getAbsolutePivotPoint(): Vector3;
  31693. /**
  31694. * Rotates the mesh
  31695. * @param axis The axis of rotation
  31696. * @param amount The amount of rotation
  31697. * @param space The space of the rotation
  31698. * @returns The rotation transform node
  31699. */
  31700. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31701. /**
  31702. * Translates the mesh
  31703. * @param axis The axis of translation
  31704. * @param distance The distance of translation
  31705. * @param space The space of the translation
  31706. * @returns The transform node
  31707. */
  31708. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31709. /**
  31710. * Sets the absolute position of the mesh
  31711. * @param absolutePosition The absolute position of the mesh
  31712. * @returns The transform node
  31713. */
  31714. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31715. /**
  31716. * Gets the class name of the mesh
  31717. * @returns The class name
  31718. */
  31719. getClassName(): string;
  31720. }
  31721. /**
  31722. * Represents a physics imposter
  31723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31724. */
  31725. export class PhysicsImpostor {
  31726. /**
  31727. * The physics-enabled object used as the physics imposter
  31728. */
  31729. object: IPhysicsEnabledObject;
  31730. /**
  31731. * The type of the physics imposter
  31732. */
  31733. type: number;
  31734. private _options;
  31735. private _scene?;
  31736. /**
  31737. * The default object size of the imposter
  31738. */
  31739. static DEFAULT_OBJECT_SIZE: Vector3;
  31740. /**
  31741. * The identity quaternion of the imposter
  31742. */
  31743. static IDENTITY_QUATERNION: Quaternion;
  31744. /** @hidden */
  31745. _pluginData: any;
  31746. private _physicsEngine;
  31747. private _physicsBody;
  31748. private _bodyUpdateRequired;
  31749. private _onBeforePhysicsStepCallbacks;
  31750. private _onAfterPhysicsStepCallbacks;
  31751. /** @hidden */
  31752. _onPhysicsCollideCallbacks: Array<{
  31753. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31754. otherImpostors: Array<PhysicsImpostor>;
  31755. }>;
  31756. private _deltaPosition;
  31757. private _deltaRotation;
  31758. private _deltaRotationConjugated;
  31759. /** @hidden */
  31760. _isFromLine: boolean;
  31761. private _parent;
  31762. private _isDisposed;
  31763. private static _tmpVecs;
  31764. private static _tmpQuat;
  31765. /**
  31766. * Specifies if the physics imposter is disposed
  31767. */
  31768. get isDisposed(): boolean;
  31769. /**
  31770. * Gets the mass of the physics imposter
  31771. */
  31772. get mass(): number;
  31773. set mass(value: number);
  31774. /**
  31775. * Gets the coefficient of friction
  31776. */
  31777. get friction(): number;
  31778. /**
  31779. * Sets the coefficient of friction
  31780. */
  31781. set friction(value: number);
  31782. /**
  31783. * Gets the coefficient of restitution
  31784. */
  31785. get restitution(): number;
  31786. /**
  31787. * Sets the coefficient of restitution
  31788. */
  31789. set restitution(value: number);
  31790. /**
  31791. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31792. */
  31793. get pressure(): number;
  31794. /**
  31795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31796. */
  31797. set pressure(value: number);
  31798. /**
  31799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31800. */
  31801. get stiffness(): number;
  31802. /**
  31803. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31804. */
  31805. set stiffness(value: number);
  31806. /**
  31807. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31808. */
  31809. get velocityIterations(): number;
  31810. /**
  31811. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31812. */
  31813. set velocityIterations(value: number);
  31814. /**
  31815. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31816. */
  31817. get positionIterations(): number;
  31818. /**
  31819. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31820. */
  31821. set positionIterations(value: number);
  31822. /**
  31823. * The unique id of the physics imposter
  31824. * set by the physics engine when adding this impostor to the array
  31825. */
  31826. uniqueId: number;
  31827. /**
  31828. * @hidden
  31829. */
  31830. soft: boolean;
  31831. /**
  31832. * @hidden
  31833. */
  31834. segments: number;
  31835. private _joints;
  31836. /**
  31837. * Initializes the physics imposter
  31838. * @param object The physics-enabled object used as the physics imposter
  31839. * @param type The type of the physics imposter
  31840. * @param _options The options for the physics imposter
  31841. * @param _scene The Babylon scene
  31842. */
  31843. constructor(
  31844. /**
  31845. * The physics-enabled object used as the physics imposter
  31846. */
  31847. object: IPhysicsEnabledObject,
  31848. /**
  31849. * The type of the physics imposter
  31850. */
  31851. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31852. /**
  31853. * This function will completly initialize this impostor.
  31854. * It will create a new body - but only if this mesh has no parent.
  31855. * If it has, this impostor will not be used other than to define the impostor
  31856. * of the child mesh.
  31857. * @hidden
  31858. */
  31859. _init(): void;
  31860. private _getPhysicsParent;
  31861. /**
  31862. * Should a new body be generated.
  31863. * @returns boolean specifying if body initialization is required
  31864. */
  31865. isBodyInitRequired(): boolean;
  31866. /**
  31867. * Sets the updated scaling
  31868. * @param updated Specifies if the scaling is updated
  31869. */
  31870. setScalingUpdated(): void;
  31871. /**
  31872. * Force a regeneration of this or the parent's impostor's body.
  31873. * Use under cautious - This will remove all joints already implemented.
  31874. */
  31875. forceUpdate(): void;
  31876. /**
  31877. * Gets the body that holds this impostor. Either its own, or its parent.
  31878. */
  31879. get physicsBody(): any;
  31880. /**
  31881. * Get the parent of the physics imposter
  31882. * @returns Physics imposter or null
  31883. */
  31884. get parent(): Nullable<PhysicsImpostor>;
  31885. /**
  31886. * Sets the parent of the physics imposter
  31887. */
  31888. set parent(value: Nullable<PhysicsImpostor>);
  31889. /**
  31890. * Set the physics body. Used mainly by the physics engine/plugin
  31891. */
  31892. set physicsBody(physicsBody: any);
  31893. /**
  31894. * Resets the update flags
  31895. */
  31896. resetUpdateFlags(): void;
  31897. /**
  31898. * Gets the object extend size
  31899. * @returns the object extend size
  31900. */
  31901. getObjectExtendSize(): Vector3;
  31902. /**
  31903. * Gets the object center
  31904. * @returns The object center
  31905. */
  31906. getObjectCenter(): Vector3;
  31907. /**
  31908. * Get a specific parameter from the options parameters
  31909. * @param paramName The object parameter name
  31910. * @returns The object parameter
  31911. */
  31912. getParam(paramName: string): any;
  31913. /**
  31914. * Sets a specific parameter in the options given to the physics plugin
  31915. * @param paramName The parameter name
  31916. * @param value The value of the parameter
  31917. */
  31918. setParam(paramName: string, value: number): void;
  31919. /**
  31920. * Specifically change the body's mass option. Won't recreate the physics body object
  31921. * @param mass The mass of the physics imposter
  31922. */
  31923. setMass(mass: number): void;
  31924. /**
  31925. * Gets the linear velocity
  31926. * @returns linear velocity or null
  31927. */
  31928. getLinearVelocity(): Nullable<Vector3>;
  31929. /**
  31930. * Sets the linear velocity
  31931. * @param velocity linear velocity or null
  31932. */
  31933. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31934. /**
  31935. * Gets the angular velocity
  31936. * @returns angular velocity or null
  31937. */
  31938. getAngularVelocity(): Nullable<Vector3>;
  31939. /**
  31940. * Sets the angular velocity
  31941. * @param velocity The velocity or null
  31942. */
  31943. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31944. /**
  31945. * Execute a function with the physics plugin native code
  31946. * Provide a function the will have two variables - the world object and the physics body object
  31947. * @param func The function to execute with the physics plugin native code
  31948. */
  31949. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31950. /**
  31951. * Register a function that will be executed before the physics world is stepping forward
  31952. * @param func The function to execute before the physics world is stepped forward
  31953. */
  31954. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31955. /**
  31956. * Unregister a function that will be executed before the physics world is stepping forward
  31957. * @param func The function to execute before the physics world is stepped forward
  31958. */
  31959. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31960. /**
  31961. * Register a function that will be executed after the physics step
  31962. * @param func The function to execute after physics step
  31963. */
  31964. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31965. /**
  31966. * Unregisters a function that will be executed after the physics step
  31967. * @param func The function to execute after physics step
  31968. */
  31969. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31970. /**
  31971. * register a function that will be executed when this impostor collides against a different body
  31972. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31973. * @param func Callback that is executed on collision
  31974. */
  31975. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31976. /**
  31977. * Unregisters the physics imposter on contact
  31978. * @param collideAgainst The physics object to collide against
  31979. * @param func Callback to execute on collision
  31980. */
  31981. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31982. private _tmpQuat;
  31983. private _tmpQuat2;
  31984. /**
  31985. * Get the parent rotation
  31986. * @returns The parent rotation
  31987. */
  31988. getParentsRotation(): Quaternion;
  31989. /**
  31990. * this function is executed by the physics engine.
  31991. */
  31992. beforeStep: () => void;
  31993. /**
  31994. * this function is executed by the physics engine
  31995. */
  31996. afterStep: () => void;
  31997. /**
  31998. * Legacy collision detection event support
  31999. */
  32000. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32001. /**
  32002. * event and body object due to cannon's event-based architecture.
  32003. */
  32004. onCollide: (e: {
  32005. body: any;
  32006. point: Nullable<Vector3>;
  32007. }) => void;
  32008. /**
  32009. * Apply a force
  32010. * @param force The force to apply
  32011. * @param contactPoint The contact point for the force
  32012. * @returns The physics imposter
  32013. */
  32014. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32015. /**
  32016. * Apply an impulse
  32017. * @param force The impulse force
  32018. * @param contactPoint The contact point for the impulse force
  32019. * @returns The physics imposter
  32020. */
  32021. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32022. /**
  32023. * A help function to create a joint
  32024. * @param otherImpostor A physics imposter used to create a joint
  32025. * @param jointType The type of joint
  32026. * @param jointData The data for the joint
  32027. * @returns The physics imposter
  32028. */
  32029. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32030. /**
  32031. * Add a joint to this impostor with a different impostor
  32032. * @param otherImpostor A physics imposter used to add a joint
  32033. * @param joint The joint to add
  32034. * @returns The physics imposter
  32035. */
  32036. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32037. /**
  32038. * Add an anchor to a cloth impostor
  32039. * @param otherImpostor rigid impostor to anchor to
  32040. * @param width ratio across width from 0 to 1
  32041. * @param height ratio up height from 0 to 1
  32042. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32043. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32044. * @returns impostor the soft imposter
  32045. */
  32046. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32047. /**
  32048. * Add a hook to a rope impostor
  32049. * @param otherImpostor rigid impostor to anchor to
  32050. * @param length ratio across rope from 0 to 1
  32051. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32052. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32053. * @returns impostor the rope imposter
  32054. */
  32055. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32056. /**
  32057. * Will keep this body still, in a sleep mode.
  32058. * @returns the physics imposter
  32059. */
  32060. sleep(): PhysicsImpostor;
  32061. /**
  32062. * Wake the body up.
  32063. * @returns The physics imposter
  32064. */
  32065. wakeUp(): PhysicsImpostor;
  32066. /**
  32067. * Clones the physics imposter
  32068. * @param newObject The physics imposter clones to this physics-enabled object
  32069. * @returns A nullable physics imposter
  32070. */
  32071. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32072. /**
  32073. * Disposes the physics imposter
  32074. */
  32075. dispose(): void;
  32076. /**
  32077. * Sets the delta position
  32078. * @param position The delta position amount
  32079. */
  32080. setDeltaPosition(position: Vector3): void;
  32081. /**
  32082. * Sets the delta rotation
  32083. * @param rotation The delta rotation amount
  32084. */
  32085. setDeltaRotation(rotation: Quaternion): void;
  32086. /**
  32087. * Gets the box size of the physics imposter and stores the result in the input parameter
  32088. * @param result Stores the box size
  32089. * @returns The physics imposter
  32090. */
  32091. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32092. /**
  32093. * Gets the radius of the physics imposter
  32094. * @returns Radius of the physics imposter
  32095. */
  32096. getRadius(): number;
  32097. /**
  32098. * Sync a bone with this impostor
  32099. * @param bone The bone to sync to the impostor.
  32100. * @param boneMesh The mesh that the bone is influencing.
  32101. * @param jointPivot The pivot of the joint / bone in local space.
  32102. * @param distToJoint Optional distance from the impostor to the joint.
  32103. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32104. */
  32105. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32106. /**
  32107. * Sync impostor to a bone
  32108. * @param bone The bone that the impostor will be synced to.
  32109. * @param boneMesh The mesh that the bone is influencing.
  32110. * @param jointPivot The pivot of the joint / bone in local space.
  32111. * @param distToJoint Optional distance from the impostor to the joint.
  32112. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32113. * @param boneAxis Optional vector3 axis the bone is aligned with
  32114. */
  32115. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32116. /**
  32117. * No-Imposter type
  32118. */
  32119. static NoImpostor: number;
  32120. /**
  32121. * Sphere-Imposter type
  32122. */
  32123. static SphereImpostor: number;
  32124. /**
  32125. * Box-Imposter type
  32126. */
  32127. static BoxImpostor: number;
  32128. /**
  32129. * Plane-Imposter type
  32130. */
  32131. static PlaneImpostor: number;
  32132. /**
  32133. * Mesh-imposter type
  32134. */
  32135. static MeshImpostor: number;
  32136. /**
  32137. * Capsule-Impostor type (Ammo.js plugin only)
  32138. */
  32139. static CapsuleImpostor: number;
  32140. /**
  32141. * Cylinder-Imposter type
  32142. */
  32143. static CylinderImpostor: number;
  32144. /**
  32145. * Particle-Imposter type
  32146. */
  32147. static ParticleImpostor: number;
  32148. /**
  32149. * Heightmap-Imposter type
  32150. */
  32151. static HeightmapImpostor: number;
  32152. /**
  32153. * ConvexHull-Impostor type (Ammo.js plugin only)
  32154. */
  32155. static ConvexHullImpostor: number;
  32156. /**
  32157. * Custom-Imposter type (Ammo.js plugin only)
  32158. */
  32159. static CustomImpostor: number;
  32160. /**
  32161. * Rope-Imposter type
  32162. */
  32163. static RopeImpostor: number;
  32164. /**
  32165. * Cloth-Imposter type
  32166. */
  32167. static ClothImpostor: number;
  32168. /**
  32169. * Softbody-Imposter type
  32170. */
  32171. static SoftbodyImpostor: number;
  32172. }
  32173. }
  32174. declare module BABYLON {
  32175. /**
  32176. * @hidden
  32177. **/
  32178. export class _CreationDataStorage {
  32179. closePath?: boolean;
  32180. closeArray?: boolean;
  32181. idx: number[];
  32182. dashSize: number;
  32183. gapSize: number;
  32184. path3D: Path3D;
  32185. pathArray: Vector3[][];
  32186. arc: number;
  32187. radius: number;
  32188. cap: number;
  32189. tessellation: number;
  32190. }
  32191. /**
  32192. * @hidden
  32193. **/
  32194. class _InstanceDataStorage {
  32195. visibleInstances: any;
  32196. batchCache: _InstancesBatch;
  32197. instancesBufferSize: number;
  32198. instancesBuffer: Nullable<Buffer>;
  32199. instancesData: Float32Array;
  32200. overridenInstanceCount: number;
  32201. isFrozen: boolean;
  32202. previousBatch: Nullable<_InstancesBatch>;
  32203. hardwareInstancedRendering: boolean;
  32204. sideOrientation: number;
  32205. manualUpdate: boolean;
  32206. previousRenderId: number;
  32207. }
  32208. /**
  32209. * @hidden
  32210. **/
  32211. export class _InstancesBatch {
  32212. mustReturn: boolean;
  32213. visibleInstances: Nullable<InstancedMesh[]>[];
  32214. renderSelf: boolean[];
  32215. hardwareInstancedRendering: boolean[];
  32216. }
  32217. /**
  32218. * @hidden
  32219. **/
  32220. class _ThinInstanceDataStorage {
  32221. instancesCount: number;
  32222. matrixBuffer: Nullable<Buffer>;
  32223. matrixBufferSize: number;
  32224. matrixData: Nullable<Float32Array>;
  32225. boundingVectors: Array<Vector3>;
  32226. worldMatrices: Nullable<Matrix[]>;
  32227. }
  32228. /**
  32229. * Class used to represent renderable models
  32230. */
  32231. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32232. /**
  32233. * Mesh side orientation : usually the external or front surface
  32234. */
  32235. static readonly FRONTSIDE: number;
  32236. /**
  32237. * Mesh side orientation : usually the internal or back surface
  32238. */
  32239. static readonly BACKSIDE: number;
  32240. /**
  32241. * Mesh side orientation : both internal and external or front and back surfaces
  32242. */
  32243. static readonly DOUBLESIDE: number;
  32244. /**
  32245. * Mesh side orientation : by default, `FRONTSIDE`
  32246. */
  32247. static readonly DEFAULTSIDE: number;
  32248. /**
  32249. * Mesh cap setting : no cap
  32250. */
  32251. static readonly NO_CAP: number;
  32252. /**
  32253. * Mesh cap setting : one cap at the beginning of the mesh
  32254. */
  32255. static readonly CAP_START: number;
  32256. /**
  32257. * Mesh cap setting : one cap at the end of the mesh
  32258. */
  32259. static readonly CAP_END: number;
  32260. /**
  32261. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32262. */
  32263. static readonly CAP_ALL: number;
  32264. /**
  32265. * Mesh pattern setting : no flip or rotate
  32266. */
  32267. static readonly NO_FLIP: number;
  32268. /**
  32269. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32270. */
  32271. static readonly FLIP_TILE: number;
  32272. /**
  32273. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32274. */
  32275. static readonly ROTATE_TILE: number;
  32276. /**
  32277. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32278. */
  32279. static readonly FLIP_ROW: number;
  32280. /**
  32281. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32282. */
  32283. static readonly ROTATE_ROW: number;
  32284. /**
  32285. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32286. */
  32287. static readonly FLIP_N_ROTATE_TILE: number;
  32288. /**
  32289. * Mesh pattern setting : rotate pattern and rotate
  32290. */
  32291. static readonly FLIP_N_ROTATE_ROW: number;
  32292. /**
  32293. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32294. */
  32295. static readonly CENTER: number;
  32296. /**
  32297. * Mesh tile positioning : part tiles on left
  32298. */
  32299. static readonly LEFT: number;
  32300. /**
  32301. * Mesh tile positioning : part tiles on right
  32302. */
  32303. static readonly RIGHT: number;
  32304. /**
  32305. * Mesh tile positioning : part tiles on top
  32306. */
  32307. static readonly TOP: number;
  32308. /**
  32309. * Mesh tile positioning : part tiles on bottom
  32310. */
  32311. static readonly BOTTOM: number;
  32312. /**
  32313. * Gets the default side orientation.
  32314. * @param orientation the orientation to value to attempt to get
  32315. * @returns the default orientation
  32316. * @hidden
  32317. */
  32318. static _GetDefaultSideOrientation(orientation?: number): number;
  32319. private _internalMeshDataInfo;
  32320. get computeBonesUsingShaders(): boolean;
  32321. set computeBonesUsingShaders(value: boolean);
  32322. /**
  32323. * An event triggered before rendering the mesh
  32324. */
  32325. get onBeforeRenderObservable(): Observable<Mesh>;
  32326. /**
  32327. * An event triggered before binding the mesh
  32328. */
  32329. get onBeforeBindObservable(): Observable<Mesh>;
  32330. /**
  32331. * An event triggered after rendering the mesh
  32332. */
  32333. get onAfterRenderObservable(): Observable<Mesh>;
  32334. /**
  32335. * An event triggered before drawing the mesh
  32336. */
  32337. get onBeforeDrawObservable(): Observable<Mesh>;
  32338. private _onBeforeDrawObserver;
  32339. /**
  32340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32341. */
  32342. set onBeforeDraw(callback: () => void);
  32343. get hasInstances(): boolean;
  32344. get hasThinInstances(): boolean;
  32345. /**
  32346. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32347. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32348. */
  32349. delayLoadState: number;
  32350. /**
  32351. * Gets the list of instances created from this mesh
  32352. * it is not supposed to be modified manually.
  32353. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32354. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32355. */
  32356. instances: InstancedMesh[];
  32357. /**
  32358. * Gets the file containing delay loading data for this mesh
  32359. */
  32360. delayLoadingFile: string;
  32361. /** @hidden */
  32362. _binaryInfo: any;
  32363. /**
  32364. * User defined function used to change how LOD level selection is done
  32365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32366. */
  32367. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32368. /**
  32369. * Gets or sets the morph target manager
  32370. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32371. */
  32372. get morphTargetManager(): Nullable<MorphTargetManager>;
  32373. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32374. /** @hidden */
  32375. _creationDataStorage: Nullable<_CreationDataStorage>;
  32376. /** @hidden */
  32377. _geometry: Nullable<Geometry>;
  32378. /** @hidden */
  32379. _delayInfo: Array<string>;
  32380. /** @hidden */
  32381. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32382. /** @hidden */
  32383. _instanceDataStorage: _InstanceDataStorage;
  32384. /** @hidden */
  32385. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32386. private _effectiveMaterial;
  32387. /** @hidden */
  32388. _shouldGenerateFlatShading: boolean;
  32389. /** @hidden */
  32390. _originalBuilderSideOrientation: number;
  32391. /**
  32392. * Use this property to change the original side orientation defined at construction time
  32393. */
  32394. overrideMaterialSideOrientation: Nullable<number>;
  32395. /**
  32396. * Gets the source mesh (the one used to clone this one from)
  32397. */
  32398. get source(): Nullable<Mesh>;
  32399. /**
  32400. * Gets the list of clones of this mesh
  32401. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32402. * Note that useClonedMeshMap=true is the default setting
  32403. */
  32404. get cloneMeshMap(): Nullable<{
  32405. [id: string]: Mesh | undefined;
  32406. }>;
  32407. /**
  32408. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32409. */
  32410. get isUnIndexed(): boolean;
  32411. set isUnIndexed(value: boolean);
  32412. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32413. get worldMatrixInstancedBuffer(): Float32Array;
  32414. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32415. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32416. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32417. /**
  32418. * @constructor
  32419. * @param name The value used by scene.getMeshByName() to do a lookup.
  32420. * @param scene The scene to add this mesh to.
  32421. * @param parent The parent of this mesh, if it has one
  32422. * @param source An optional Mesh from which geometry is shared, cloned.
  32423. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32424. * When false, achieved by calling a clone(), also passing False.
  32425. * This will make creation of children, recursive.
  32426. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32427. */
  32428. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32429. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32430. doNotInstantiate: boolean;
  32431. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32432. /**
  32433. * Gets the class name
  32434. * @returns the string "Mesh".
  32435. */
  32436. getClassName(): string;
  32437. /** @hidden */
  32438. get _isMesh(): boolean;
  32439. /**
  32440. * Returns a description of this mesh
  32441. * @param fullDetails define if full details about this mesh must be used
  32442. * @returns a descriptive string representing this mesh
  32443. */
  32444. toString(fullDetails?: boolean): string;
  32445. /** @hidden */
  32446. _unBindEffect(): void;
  32447. /**
  32448. * Gets a boolean indicating if this mesh has LOD
  32449. */
  32450. get hasLODLevels(): boolean;
  32451. /**
  32452. * Gets the list of MeshLODLevel associated with the current mesh
  32453. * @returns an array of MeshLODLevel
  32454. */
  32455. getLODLevels(): MeshLODLevel[];
  32456. private _sortLODLevels;
  32457. /**
  32458. * Add a mesh as LOD level triggered at the given distance.
  32459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32460. * @param distance The distance from the center of the object to show this level
  32461. * @param mesh The mesh to be added as LOD level (can be null)
  32462. * @return This mesh (for chaining)
  32463. */
  32464. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32465. /**
  32466. * Returns the LOD level mesh at the passed distance or null if not found.
  32467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32468. * @param distance The distance from the center of the object to show this level
  32469. * @returns a Mesh or `null`
  32470. */
  32471. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32472. /**
  32473. * Remove a mesh from the LOD array
  32474. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32475. * @param mesh defines the mesh to be removed
  32476. * @return This mesh (for chaining)
  32477. */
  32478. removeLODLevel(mesh: Mesh): Mesh;
  32479. /**
  32480. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32481. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32482. * @param camera defines the camera to use to compute distance
  32483. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32484. * @return This mesh (for chaining)
  32485. */
  32486. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32487. /**
  32488. * Gets the mesh internal Geometry object
  32489. */
  32490. get geometry(): Nullable<Geometry>;
  32491. /**
  32492. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32493. * @returns the total number of vertices
  32494. */
  32495. getTotalVertices(): number;
  32496. /**
  32497. * Returns the content of an associated vertex buffer
  32498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32499. * - VertexBuffer.PositionKind
  32500. * - VertexBuffer.UVKind
  32501. * - VertexBuffer.UV2Kind
  32502. * - VertexBuffer.UV3Kind
  32503. * - VertexBuffer.UV4Kind
  32504. * - VertexBuffer.UV5Kind
  32505. * - VertexBuffer.UV6Kind
  32506. * - VertexBuffer.ColorKind
  32507. * - VertexBuffer.MatricesIndicesKind
  32508. * - VertexBuffer.MatricesIndicesExtraKind
  32509. * - VertexBuffer.MatricesWeightsKind
  32510. * - VertexBuffer.MatricesWeightsExtraKind
  32511. * @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
  32512. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32513. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32514. */
  32515. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32516. /**
  32517. * Returns the mesh VertexBuffer object from the requested `kind`
  32518. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32519. * - VertexBuffer.PositionKind
  32520. * - VertexBuffer.NormalKind
  32521. * - VertexBuffer.UVKind
  32522. * - VertexBuffer.UV2Kind
  32523. * - VertexBuffer.UV3Kind
  32524. * - VertexBuffer.UV4Kind
  32525. * - VertexBuffer.UV5Kind
  32526. * - VertexBuffer.UV6Kind
  32527. * - VertexBuffer.ColorKind
  32528. * - VertexBuffer.MatricesIndicesKind
  32529. * - VertexBuffer.MatricesIndicesExtraKind
  32530. * - VertexBuffer.MatricesWeightsKind
  32531. * - VertexBuffer.MatricesWeightsExtraKind
  32532. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32533. */
  32534. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32535. /**
  32536. * Tests if a specific vertex buffer is associated with this mesh
  32537. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32538. * - VertexBuffer.PositionKind
  32539. * - VertexBuffer.NormalKind
  32540. * - VertexBuffer.UVKind
  32541. * - VertexBuffer.UV2Kind
  32542. * - VertexBuffer.UV3Kind
  32543. * - VertexBuffer.UV4Kind
  32544. * - VertexBuffer.UV5Kind
  32545. * - VertexBuffer.UV6Kind
  32546. * - VertexBuffer.ColorKind
  32547. * - VertexBuffer.MatricesIndicesKind
  32548. * - VertexBuffer.MatricesIndicesExtraKind
  32549. * - VertexBuffer.MatricesWeightsKind
  32550. * - VertexBuffer.MatricesWeightsExtraKind
  32551. * @returns a boolean
  32552. */
  32553. isVerticesDataPresent(kind: string): boolean;
  32554. /**
  32555. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32556. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32557. * - VertexBuffer.PositionKind
  32558. * - VertexBuffer.UVKind
  32559. * - VertexBuffer.UV2Kind
  32560. * - VertexBuffer.UV3Kind
  32561. * - VertexBuffer.UV4Kind
  32562. * - VertexBuffer.UV5Kind
  32563. * - VertexBuffer.UV6Kind
  32564. * - VertexBuffer.ColorKind
  32565. * - VertexBuffer.MatricesIndicesKind
  32566. * - VertexBuffer.MatricesIndicesExtraKind
  32567. * - VertexBuffer.MatricesWeightsKind
  32568. * - VertexBuffer.MatricesWeightsExtraKind
  32569. * @returns a boolean
  32570. */
  32571. isVertexBufferUpdatable(kind: string): boolean;
  32572. /**
  32573. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32574. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32575. * - VertexBuffer.PositionKind
  32576. * - VertexBuffer.NormalKind
  32577. * - VertexBuffer.UVKind
  32578. * - VertexBuffer.UV2Kind
  32579. * - VertexBuffer.UV3Kind
  32580. * - VertexBuffer.UV4Kind
  32581. * - VertexBuffer.UV5Kind
  32582. * - VertexBuffer.UV6Kind
  32583. * - VertexBuffer.ColorKind
  32584. * - VertexBuffer.MatricesIndicesKind
  32585. * - VertexBuffer.MatricesIndicesExtraKind
  32586. * - VertexBuffer.MatricesWeightsKind
  32587. * - VertexBuffer.MatricesWeightsExtraKind
  32588. * @returns an array of strings
  32589. */
  32590. getVerticesDataKinds(): string[];
  32591. /**
  32592. * Returns a positive integer : the total number of indices in this mesh geometry.
  32593. * @returns the numner of indices or zero if the mesh has no geometry.
  32594. */
  32595. getTotalIndices(): number;
  32596. /**
  32597. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32598. * @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.
  32599. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32600. * @returns the indices array or an empty array if the mesh has no geometry
  32601. */
  32602. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32603. get isBlocked(): boolean;
  32604. /**
  32605. * Determine if the current mesh is ready to be rendered
  32606. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32607. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32608. * @returns true if all associated assets are ready (material, textures, shaders)
  32609. */
  32610. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32611. /**
  32612. * 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.
  32613. */
  32614. get areNormalsFrozen(): boolean;
  32615. /**
  32616. * 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.
  32617. * @returns the current mesh
  32618. */
  32619. freezeNormals(): Mesh;
  32620. /**
  32621. * 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
  32622. * @returns the current mesh
  32623. */
  32624. unfreezeNormals(): Mesh;
  32625. /**
  32626. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32627. */
  32628. set overridenInstanceCount(count: number);
  32629. /** @hidden */
  32630. _preActivate(): Mesh;
  32631. /** @hidden */
  32632. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32633. /** @hidden */
  32634. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32635. protected _afterComputeWorldMatrix(): void;
  32636. /** @hidden */
  32637. _postActivate(): void;
  32638. /**
  32639. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32640. * This means the mesh underlying bounding box and sphere are recomputed.
  32641. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32642. * @returns the current mesh
  32643. */
  32644. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32645. /** @hidden */
  32646. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32647. /**
  32648. * This function will subdivide the mesh into multiple submeshes
  32649. * @param count defines the expected number of submeshes
  32650. */
  32651. subdivide(count: number): void;
  32652. /**
  32653. * Copy a FloatArray into a specific associated vertex buffer
  32654. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32655. * - VertexBuffer.PositionKind
  32656. * - VertexBuffer.UVKind
  32657. * - VertexBuffer.UV2Kind
  32658. * - VertexBuffer.UV3Kind
  32659. * - VertexBuffer.UV4Kind
  32660. * - VertexBuffer.UV5Kind
  32661. * - VertexBuffer.UV6Kind
  32662. * - VertexBuffer.ColorKind
  32663. * - VertexBuffer.MatricesIndicesKind
  32664. * - VertexBuffer.MatricesIndicesExtraKind
  32665. * - VertexBuffer.MatricesWeightsKind
  32666. * - VertexBuffer.MatricesWeightsExtraKind
  32667. * @param data defines the data source
  32668. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32669. * @param stride defines the data stride size (can be null)
  32670. * @returns the current mesh
  32671. */
  32672. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32673. /**
  32674. * Delete a vertex buffer associated with this mesh
  32675. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32676. * - VertexBuffer.PositionKind
  32677. * - VertexBuffer.UVKind
  32678. * - VertexBuffer.UV2Kind
  32679. * - VertexBuffer.UV3Kind
  32680. * - VertexBuffer.UV4Kind
  32681. * - VertexBuffer.UV5Kind
  32682. * - VertexBuffer.UV6Kind
  32683. * - VertexBuffer.ColorKind
  32684. * - VertexBuffer.MatricesIndicesKind
  32685. * - VertexBuffer.MatricesIndicesExtraKind
  32686. * - VertexBuffer.MatricesWeightsKind
  32687. * - VertexBuffer.MatricesWeightsExtraKind
  32688. */
  32689. removeVerticesData(kind: string): void;
  32690. /**
  32691. * Flags an associated vertex buffer as updatable
  32692. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32693. * - VertexBuffer.PositionKind
  32694. * - VertexBuffer.UVKind
  32695. * - VertexBuffer.UV2Kind
  32696. * - VertexBuffer.UV3Kind
  32697. * - VertexBuffer.UV4Kind
  32698. * - VertexBuffer.UV5Kind
  32699. * - VertexBuffer.UV6Kind
  32700. * - VertexBuffer.ColorKind
  32701. * - VertexBuffer.MatricesIndicesKind
  32702. * - VertexBuffer.MatricesIndicesExtraKind
  32703. * - VertexBuffer.MatricesWeightsKind
  32704. * - VertexBuffer.MatricesWeightsExtraKind
  32705. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32706. */
  32707. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32708. /**
  32709. * Sets the mesh global Vertex Buffer
  32710. * @param buffer defines the buffer to use
  32711. * @returns the current mesh
  32712. */
  32713. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32714. /**
  32715. * Update a specific associated vertex buffer
  32716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32717. * - VertexBuffer.PositionKind
  32718. * - VertexBuffer.UVKind
  32719. * - VertexBuffer.UV2Kind
  32720. * - VertexBuffer.UV3Kind
  32721. * - VertexBuffer.UV4Kind
  32722. * - VertexBuffer.UV5Kind
  32723. * - VertexBuffer.UV6Kind
  32724. * - VertexBuffer.ColorKind
  32725. * - VertexBuffer.MatricesIndicesKind
  32726. * - VertexBuffer.MatricesIndicesExtraKind
  32727. * - VertexBuffer.MatricesWeightsKind
  32728. * - VertexBuffer.MatricesWeightsExtraKind
  32729. * @param data defines the data source
  32730. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32731. * @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)
  32732. * @returns the current mesh
  32733. */
  32734. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32735. /**
  32736. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32737. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32738. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32739. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32740. * @returns the current mesh
  32741. */
  32742. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32743. /**
  32744. * Creates a un-shared specific occurence of the geometry for the mesh.
  32745. * @returns the current mesh
  32746. */
  32747. makeGeometryUnique(): Mesh;
  32748. /**
  32749. * Set the index buffer of this mesh
  32750. * @param indices defines the source data
  32751. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32752. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32753. * @returns the current mesh
  32754. */
  32755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32756. /**
  32757. * Update the current index buffer
  32758. * @param indices defines the source data
  32759. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32760. * @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)
  32761. * @returns the current mesh
  32762. */
  32763. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32764. /**
  32765. * Invert the geometry to move from a right handed system to a left handed one.
  32766. * @returns the current mesh
  32767. */
  32768. toLeftHanded(): Mesh;
  32769. /** @hidden */
  32770. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32771. /** @hidden */
  32772. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32773. /**
  32774. * Registers for this mesh a javascript function called just before the rendering process
  32775. * @param func defines the function to call before rendering this mesh
  32776. * @returns the current mesh
  32777. */
  32778. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32779. /**
  32780. * Disposes a previously registered javascript function called before the rendering
  32781. * @param func defines the function to remove
  32782. * @returns the current mesh
  32783. */
  32784. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32785. /**
  32786. * Registers for this mesh a javascript function called just after the rendering is complete
  32787. * @param func defines the function to call after rendering this mesh
  32788. * @returns the current mesh
  32789. */
  32790. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32791. /**
  32792. * Disposes a previously registered javascript function called after the rendering.
  32793. * @param func defines the function to remove
  32794. * @returns the current mesh
  32795. */
  32796. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32797. /** @hidden */
  32798. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32799. /** @hidden */
  32800. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32801. /** @hidden */
  32802. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32803. /** @hidden */
  32804. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32805. /** @hidden */
  32806. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32807. /** @hidden */
  32808. _rebuild(): void;
  32809. /** @hidden */
  32810. _freeze(): void;
  32811. /** @hidden */
  32812. _unFreeze(): void;
  32813. /**
  32814. * 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
  32815. * @param subMesh defines the subMesh to render
  32816. * @param enableAlphaMode defines if alpha mode can be changed
  32817. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32818. * @returns the current mesh
  32819. */
  32820. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32821. private _onBeforeDraw;
  32822. /**
  32823. * Renormalize the mesh and patch it up if there are no weights
  32824. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32825. * However in the case of zero weights then we set just a single influence to 1.
  32826. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32827. */
  32828. cleanMatrixWeights(): void;
  32829. private normalizeSkinFourWeights;
  32830. private normalizeSkinWeightsAndExtra;
  32831. /**
  32832. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32833. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32834. * the user know there was an issue with importing the mesh
  32835. * @returns a validation object with skinned, valid and report string
  32836. */
  32837. validateSkinning(): {
  32838. skinned: boolean;
  32839. valid: boolean;
  32840. report: string;
  32841. };
  32842. /** @hidden */
  32843. _checkDelayState(): Mesh;
  32844. private _queueLoad;
  32845. /**
  32846. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32847. * A mesh is in the frustum if its bounding box intersects the frustum
  32848. * @param frustumPlanes defines the frustum to test
  32849. * @returns true if the mesh is in the frustum planes
  32850. */
  32851. isInFrustum(frustumPlanes: Plane[]): boolean;
  32852. /**
  32853. * Sets the mesh material by the material or multiMaterial `id` property
  32854. * @param id is a string identifying the material or the multiMaterial
  32855. * @returns the current mesh
  32856. */
  32857. setMaterialByID(id: string): Mesh;
  32858. /**
  32859. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32860. * @returns an array of IAnimatable
  32861. */
  32862. getAnimatables(): IAnimatable[];
  32863. /**
  32864. * Modifies the mesh geometry according to the passed transformation matrix.
  32865. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32866. * The mesh normals are modified using the same transformation.
  32867. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32868. * @param transform defines the transform matrix to use
  32869. * @see https://doc.babylonjs.com/resources/baking_transformations
  32870. * @returns the current mesh
  32871. */
  32872. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32873. /**
  32874. * Modifies the mesh geometry according to its own current World Matrix.
  32875. * The mesh World Matrix is then reset.
  32876. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32877. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32878. * @see https://doc.babylonjs.com/resources/baking_transformations
  32879. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32880. * @returns the current mesh
  32881. */
  32882. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32883. /** @hidden */
  32884. get _positions(): Nullable<Vector3[]>;
  32885. /** @hidden */
  32886. _resetPointsArrayCache(): Mesh;
  32887. /** @hidden */
  32888. _generatePointsArray(): boolean;
  32889. /**
  32890. * Returns a new Mesh object generated from the current mesh properties.
  32891. * This method must not get confused with createInstance()
  32892. * @param name is a string, the name given to the new mesh
  32893. * @param newParent can be any Node object (default `null`)
  32894. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32895. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32896. * @returns a new mesh
  32897. */
  32898. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32899. /**
  32900. * Releases resources associated with this mesh.
  32901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32903. */
  32904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32905. /** @hidden */
  32906. _disposeInstanceSpecificData(): void;
  32907. /** @hidden */
  32908. _disposeThinInstanceSpecificData(): void;
  32909. /**
  32910. * Modifies the mesh geometry according to a displacement map.
  32911. * 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.
  32912. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32913. * @param url is a string, the URL from the image file is to be downloaded.
  32914. * @param minHeight is the lower limit of the displacement.
  32915. * @param maxHeight is the upper limit of the displacement.
  32916. * @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.
  32917. * @param uvOffset is an optional vector2 used to offset UV.
  32918. * @param uvScale is an optional vector2 used to scale UV.
  32919. * @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.
  32920. * @returns the Mesh.
  32921. */
  32922. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32923. /**
  32924. * Modifies the mesh geometry according to a displacementMap buffer.
  32925. * 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.
  32926. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32927. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32928. * @param heightMapWidth is the width of the buffer image.
  32929. * @param heightMapHeight is the height of the buffer image.
  32930. * @param minHeight is the lower limit of the displacement.
  32931. * @param maxHeight is the upper limit of the displacement.
  32932. * @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.
  32933. * @param uvOffset is an optional vector2 used to offset UV.
  32934. * @param uvScale is an optional vector2 used to scale UV.
  32935. * @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.
  32936. * @returns the Mesh.
  32937. */
  32938. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32939. /**
  32940. * Modify the mesh to get a flat shading rendering.
  32941. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32942. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32943. * @returns current mesh
  32944. */
  32945. convertToFlatShadedMesh(): Mesh;
  32946. /**
  32947. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32948. * In other words, more vertices, no more indices and a single bigger VBO.
  32949. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32950. * @returns current mesh
  32951. */
  32952. convertToUnIndexedMesh(): Mesh;
  32953. /**
  32954. * Inverses facet orientations.
  32955. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32956. * @param flipNormals will also inverts the normals
  32957. * @returns current mesh
  32958. */
  32959. flipFaces(flipNormals?: boolean): Mesh;
  32960. /**
  32961. * Increase the number of facets and hence vertices in a mesh
  32962. * Vertex normals are interpolated from existing vertex normals
  32963. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32964. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32965. */
  32966. increaseVertices(numberPerEdge: number): void;
  32967. /**
  32968. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32969. * This will undo any application of covertToFlatShadedMesh
  32970. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32971. */
  32972. forceSharedVertices(): void;
  32973. /** @hidden */
  32974. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32975. /** @hidden */
  32976. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32977. /**
  32978. * Creates a new InstancedMesh object from the mesh model.
  32979. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32980. * @param name defines the name of the new instance
  32981. * @returns a new InstancedMesh
  32982. */
  32983. createInstance(name: string): InstancedMesh;
  32984. /**
  32985. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32986. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32987. * @returns the current mesh
  32988. */
  32989. synchronizeInstances(): Mesh;
  32990. /**
  32991. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32992. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32993. * This should be used together with the simplification to avoid disappearing triangles.
  32994. * @param successCallback an optional success callback to be called after the optimization finished.
  32995. * @returns the current mesh
  32996. */
  32997. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32998. /**
  32999. * Serialize current mesh
  33000. * @param serializationObject defines the object which will receive the serialization data
  33001. */
  33002. serialize(serializationObject: any): void;
  33003. /** @hidden */
  33004. _syncGeometryWithMorphTargetManager(): void;
  33005. /** @hidden */
  33006. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33007. /**
  33008. * Returns a new Mesh object parsed from the source provided.
  33009. * @param parsedMesh is the source
  33010. * @param scene defines the hosting scene
  33011. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33012. * @returns a new Mesh
  33013. */
  33014. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33015. /**
  33016. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33018. * @param name defines the name of the mesh to create
  33019. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33020. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33021. * @param closePath creates a seam between the first and the last points of each path of the path array
  33022. * @param offset is taken in account only if the `pathArray` is containing a single path
  33023. * @param scene defines the hosting scene
  33024. * @param updatable defines if the mesh must be flagged as updatable
  33025. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33026. * @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)
  33027. * @returns a new Mesh
  33028. */
  33029. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33030. /**
  33031. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33032. * @param name defines the name of the mesh to create
  33033. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33034. * @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
  33035. * @param scene defines the hosting scene
  33036. * @param updatable defines if the mesh must be flagged as updatable
  33037. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33038. * @returns a new Mesh
  33039. */
  33040. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33041. /**
  33042. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33043. * @param name defines the name of the mesh to create
  33044. * @param size sets the size (float) of each box side (default 1)
  33045. * @param scene defines the hosting scene
  33046. * @param updatable defines if the mesh must be flagged as updatable
  33047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33048. * @returns a new Mesh
  33049. */
  33050. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33051. /**
  33052. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33053. * @param name defines the name of the mesh to create
  33054. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33055. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33056. * @param scene defines the hosting scene
  33057. * @param updatable defines if the mesh must be flagged as updatable
  33058. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33059. * @returns a new Mesh
  33060. */
  33061. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33062. /**
  33063. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33064. * @param name defines the name of the mesh to create
  33065. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33066. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33067. * @param scene defines the hosting scene
  33068. * @returns a new Mesh
  33069. */
  33070. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33071. /**
  33072. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33073. * @param name defines the name of the mesh to create
  33074. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33075. * @param diameterTop set the top cap diameter (floats, default 1)
  33076. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33077. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33078. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33079. * @param scene defines the hosting scene
  33080. * @param updatable defines if the mesh must be flagged as updatable
  33081. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33082. * @returns a new Mesh
  33083. */
  33084. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33085. /**
  33086. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33087. * @param name defines the name of the mesh to create
  33088. * @param diameter sets the diameter size (float) of the torus (default 1)
  33089. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33090. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33091. * @param scene defines the hosting scene
  33092. * @param updatable defines if the mesh must be flagged as updatable
  33093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33094. * @returns a new Mesh
  33095. */
  33096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33097. /**
  33098. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33099. * @param name defines the name of the mesh to create
  33100. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33101. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33102. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33103. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33104. * @param p the number of windings on X axis (positive integers, default 2)
  33105. * @param q the number of windings on Y axis (positive integers, default 3)
  33106. * @param scene defines the hosting scene
  33107. * @param updatable defines if the mesh must be flagged as updatable
  33108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33109. * @returns a new Mesh
  33110. */
  33111. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33112. /**
  33113. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33114. * @param name defines the name of the mesh to create
  33115. * @param points is an array successive Vector3
  33116. * @param scene defines the hosting scene
  33117. * @param updatable defines if the mesh must be flagged as updatable
  33118. * @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).
  33119. * @returns a new Mesh
  33120. */
  33121. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33122. /**
  33123. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33124. * @param name defines the name of the mesh to create
  33125. * @param points is an array successive Vector3
  33126. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33127. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33128. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33129. * @param scene defines the hosting scene
  33130. * @param updatable defines if the mesh must be flagged as updatable
  33131. * @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)
  33132. * @returns a new Mesh
  33133. */
  33134. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33135. /**
  33136. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33138. * 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.
  33139. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33141. * Remember you can only change the shape positions, not their number when updating a polygon.
  33142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33143. * @param name defines the name of the mesh to create
  33144. * @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
  33145. * @param scene defines the hosting scene
  33146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33147. * @param updatable defines if the mesh must be flagged as updatable
  33148. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33149. * @param earcutInjection can be used to inject your own earcut reference
  33150. * @returns a new Mesh
  33151. */
  33152. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33153. /**
  33154. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33156. * @param name defines the name of the mesh to create
  33157. * @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
  33158. * @param depth defines the height of extrusion
  33159. * @param scene defines the hosting scene
  33160. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33161. * @param updatable defines if the mesh must be flagged as updatable
  33162. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33163. * @param earcutInjection can be used to inject your own earcut reference
  33164. * @returns a new Mesh
  33165. */
  33166. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33167. /**
  33168. * Creates an extruded shape mesh.
  33169. * 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
  33170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33172. * @param name defines the name of the mesh to create
  33173. * @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
  33174. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33175. * @param scale is the value to scale the shape
  33176. * @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
  33177. * @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
  33178. * @param scene defines the hosting scene
  33179. * @param updatable defines if the mesh must be flagged as updatable
  33180. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33181. * @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)
  33182. * @returns a new Mesh
  33183. */
  33184. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33185. /**
  33186. * Creates an custom extruded shape mesh.
  33187. * The custom extrusion is a parametric shape.
  33188. * It has no predefined shape. Its final shape will depend on the input parameters.
  33189. * Please consider using the same method from the MeshBuilder class instead
  33190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33191. * @param name defines the name of the mesh to create
  33192. * @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
  33193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33194. * @param scaleFunction is a custom Javascript function called on each path point
  33195. * @param rotationFunction is a custom Javascript function called on each path point
  33196. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33197. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33198. * @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
  33199. * @param scene defines the hosting scene
  33200. * @param updatable defines if the mesh must be flagged as updatable
  33201. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33202. * @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)
  33203. * @returns a new Mesh
  33204. */
  33205. 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;
  33206. /**
  33207. * Creates lathe mesh.
  33208. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33209. * Please consider using the same method from the MeshBuilder class instead
  33210. * @param name defines the name of the mesh to create
  33211. * @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
  33212. * @param radius is the radius value of the lathe
  33213. * @param tessellation is the side number of the lathe.
  33214. * @param scene defines the hosting scene
  33215. * @param updatable defines if the mesh must be flagged as updatable
  33216. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33217. * @returns a new Mesh
  33218. */
  33219. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33220. /**
  33221. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33222. * @param name defines the name of the mesh to create
  33223. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33224. * @param scene defines the hosting scene
  33225. * @param updatable defines if the mesh must be flagged as updatable
  33226. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33227. * @returns a new Mesh
  33228. */
  33229. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33230. /**
  33231. * Creates a ground mesh.
  33232. * Please consider using the same method from the MeshBuilder class instead
  33233. * @param name defines the name of the mesh to create
  33234. * @param width set the width of the ground
  33235. * @param height set the height of the ground
  33236. * @param subdivisions sets the number of subdivisions per side
  33237. * @param scene defines the hosting scene
  33238. * @param updatable defines if the mesh must be flagged as updatable
  33239. * @returns a new Mesh
  33240. */
  33241. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33242. /**
  33243. * Creates a tiled ground mesh.
  33244. * Please consider using the same method from the MeshBuilder class instead
  33245. * @param name defines the name of the mesh to create
  33246. * @param xmin set the ground minimum X coordinate
  33247. * @param zmin set the ground minimum Y coordinate
  33248. * @param xmax set the ground maximum X coordinate
  33249. * @param zmax set the ground maximum Z coordinate
  33250. * @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
  33251. * @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
  33252. * @param scene defines the hosting scene
  33253. * @param updatable defines if the mesh must be flagged as updatable
  33254. * @returns a new Mesh
  33255. */
  33256. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33257. w: number;
  33258. h: number;
  33259. }, precision: {
  33260. w: number;
  33261. h: number;
  33262. }, scene: Scene, updatable?: boolean): Mesh;
  33263. /**
  33264. * Creates a ground mesh from a height map.
  33265. * Please consider using the same method from the MeshBuilder class instead
  33266. * @see https://doc.babylonjs.com/babylon101/height_map
  33267. * @param name defines the name of the mesh to create
  33268. * @param url sets the URL of the height map image resource
  33269. * @param width set the ground width size
  33270. * @param height set the ground height size
  33271. * @param subdivisions sets the number of subdivision per side
  33272. * @param minHeight is the minimum altitude on the ground
  33273. * @param maxHeight is the maximum altitude on the ground
  33274. * @param scene defines the hosting scene
  33275. * @param updatable defines if the mesh must be flagged as updatable
  33276. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33277. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33278. * @returns a new Mesh
  33279. */
  33280. 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;
  33281. /**
  33282. * Creates a tube mesh.
  33283. * The tube is a parametric shape.
  33284. * It has no predefined shape. Its final shape will depend on the input parameters.
  33285. * Please consider using the same method from the MeshBuilder class instead
  33286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33287. * @param name defines the name of the mesh to create
  33288. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33289. * @param radius sets the tube radius size
  33290. * @param tessellation is the number of sides on the tubular surface
  33291. * @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
  33292. * @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
  33293. * @param scene defines the hosting scene
  33294. * @param updatable defines if the mesh must be flagged as updatable
  33295. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33296. * @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)
  33297. * @returns a new Mesh
  33298. */
  33299. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33300. (i: number, distance: number): number;
  33301. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33302. /**
  33303. * Creates a polyhedron mesh.
  33304. * Please consider using the same method from the MeshBuilder class instead.
  33305. * * 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
  33306. * * The parameter `size` (positive float, default 1) sets the polygon size
  33307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33308. * * 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`
  33309. * * 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
  33310. * * 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)`)
  33311. * * 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
  33312. * * 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
  33313. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33314. * * 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
  33315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33316. * @param name defines the name of the mesh to create
  33317. * @param options defines the options used to create the mesh
  33318. * @param scene defines the hosting scene
  33319. * @returns a new Mesh
  33320. */
  33321. static CreatePolyhedron(name: string, options: {
  33322. type?: number;
  33323. size?: number;
  33324. sizeX?: number;
  33325. sizeY?: number;
  33326. sizeZ?: number;
  33327. custom?: any;
  33328. faceUV?: Vector4[];
  33329. faceColors?: Color4[];
  33330. updatable?: boolean;
  33331. sideOrientation?: number;
  33332. }, scene: Scene): Mesh;
  33333. /**
  33334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33336. * * 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`)
  33337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33338. * * 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
  33339. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33340. * * 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
  33341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33342. * @param name defines the name of the mesh
  33343. * @param options defines the options used to create the mesh
  33344. * @param scene defines the hosting scene
  33345. * @returns a new Mesh
  33346. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33347. */
  33348. static CreateIcoSphere(name: string, options: {
  33349. radius?: number;
  33350. flat?: boolean;
  33351. subdivisions?: number;
  33352. sideOrientation?: number;
  33353. updatable?: boolean;
  33354. }, scene: Scene): Mesh;
  33355. /**
  33356. * Creates a decal mesh.
  33357. * Please consider using the same method from the MeshBuilder class instead.
  33358. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33359. * @param name defines the name of the mesh
  33360. * @param sourceMesh defines the mesh receiving the decal
  33361. * @param position sets the position of the decal in world coordinates
  33362. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33363. * @param size sets the decal scaling
  33364. * @param angle sets the angle to rotate the decal
  33365. * @returns a new Mesh
  33366. */
  33367. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33368. /** Creates a Capsule Mesh
  33369. * @param name defines the name of the mesh.
  33370. * @param options the constructors options used to shape the mesh.
  33371. * @param scene defines the scene the mesh is scoped to.
  33372. * @returns the capsule mesh
  33373. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33374. */
  33375. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33376. /**
  33377. * Prepare internal position array for software CPU skinning
  33378. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33379. */
  33380. setPositionsForCPUSkinning(): Float32Array;
  33381. /**
  33382. * Prepare internal normal array for software CPU skinning
  33383. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33384. */
  33385. setNormalsForCPUSkinning(): Float32Array;
  33386. /**
  33387. * Updates the vertex buffer by applying transformation from the bones
  33388. * @param skeleton defines the skeleton to apply to current mesh
  33389. * @returns the current mesh
  33390. */
  33391. applySkeleton(skeleton: Skeleton): Mesh;
  33392. /**
  33393. * 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
  33394. * @param meshes defines the list of meshes to scan
  33395. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33396. */
  33397. static MinMax(meshes: AbstractMesh[]): {
  33398. min: Vector3;
  33399. max: Vector3;
  33400. };
  33401. /**
  33402. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33403. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33404. * @returns a vector3
  33405. */
  33406. static Center(meshesOrMinMaxVector: {
  33407. min: Vector3;
  33408. max: Vector3;
  33409. } | AbstractMesh[]): Vector3;
  33410. /**
  33411. * Merge the array of meshes into a single mesh for performance reasons.
  33412. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33413. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33414. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33415. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33416. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33417. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33418. * @returns a new mesh
  33419. */
  33420. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33421. /** @hidden */
  33422. addInstance(instance: InstancedMesh): void;
  33423. /** @hidden */
  33424. removeInstance(instance: InstancedMesh): void;
  33425. }
  33426. }
  33427. declare module BABYLON {
  33428. /**
  33429. * The options Interface for creating a Capsule Mesh
  33430. */
  33431. export interface ICreateCapsuleOptions {
  33432. /** The Orientation of the capsule. Default : Vector3.Up() */
  33433. orientation?: Vector3;
  33434. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33435. subdivisions: number;
  33436. /** Number of cylindrical segments on the capsule. */
  33437. tessellation: number;
  33438. /** Height or Length of the capsule. */
  33439. height: number;
  33440. /** Radius of the capsule. */
  33441. radius: number;
  33442. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33443. capSubdivisions: number;
  33444. /** Overwrite for the top radius. */
  33445. radiusTop?: number;
  33446. /** Overwrite for the bottom radius. */
  33447. radiusBottom?: number;
  33448. /** Overwrite for the top capSubdivisions. */
  33449. topCapSubdivisions?: number;
  33450. /** Overwrite for the bottom capSubdivisions. */
  33451. bottomCapSubdivisions?: number;
  33452. }
  33453. /**
  33454. * Class containing static functions to help procedurally build meshes
  33455. */
  33456. export class CapsuleBuilder {
  33457. /**
  33458. * Creates a capsule or a pill mesh
  33459. * @param name defines the name of the mesh
  33460. * @param options The constructors options.
  33461. * @param scene The scene the mesh is scoped to.
  33462. * @returns Capsule Mesh
  33463. */
  33464. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33465. }
  33466. }
  33467. declare module BABYLON {
  33468. /**
  33469. * Define an interface for all classes that will get and set the data on vertices
  33470. */
  33471. export interface IGetSetVerticesData {
  33472. /**
  33473. * Gets a boolean indicating if specific vertex data is present
  33474. * @param kind defines the vertex data kind to use
  33475. * @returns true is data kind is present
  33476. */
  33477. isVerticesDataPresent(kind: string): boolean;
  33478. /**
  33479. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33480. * @param kind defines the data kind (Position, normal, etc...)
  33481. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33482. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33483. * @returns a float array containing vertex data
  33484. */
  33485. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33486. /**
  33487. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33488. * @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.
  33489. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33490. * @returns the indices array or an empty array if the mesh has no geometry
  33491. */
  33492. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33493. /**
  33494. * Set specific vertex data
  33495. * @param kind defines the data kind (Position, normal, etc...)
  33496. * @param data defines the vertex data to use
  33497. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33498. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33499. */
  33500. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33501. /**
  33502. * Update a specific associated vertex buffer
  33503. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33504. * - VertexBuffer.PositionKind
  33505. * - VertexBuffer.UVKind
  33506. * - VertexBuffer.UV2Kind
  33507. * - VertexBuffer.UV3Kind
  33508. * - VertexBuffer.UV4Kind
  33509. * - VertexBuffer.UV5Kind
  33510. * - VertexBuffer.UV6Kind
  33511. * - VertexBuffer.ColorKind
  33512. * - VertexBuffer.MatricesIndicesKind
  33513. * - VertexBuffer.MatricesIndicesExtraKind
  33514. * - VertexBuffer.MatricesWeightsKind
  33515. * - VertexBuffer.MatricesWeightsExtraKind
  33516. * @param data defines the data source
  33517. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33518. * @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)
  33519. */
  33520. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33521. /**
  33522. * Creates a new index buffer
  33523. * @param indices defines the indices to store in the index buffer
  33524. * @param totalVertices defines the total number of vertices (could be null)
  33525. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33526. */
  33527. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33528. }
  33529. /**
  33530. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33531. */
  33532. export class VertexData {
  33533. /**
  33534. * Mesh side orientation : usually the external or front surface
  33535. */
  33536. static readonly FRONTSIDE: number;
  33537. /**
  33538. * Mesh side orientation : usually the internal or back surface
  33539. */
  33540. static readonly BACKSIDE: number;
  33541. /**
  33542. * Mesh side orientation : both internal and external or front and back surfaces
  33543. */
  33544. static readonly DOUBLESIDE: number;
  33545. /**
  33546. * Mesh side orientation : by default, `FRONTSIDE`
  33547. */
  33548. static readonly DEFAULTSIDE: number;
  33549. /**
  33550. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33551. */
  33552. positions: Nullable<FloatArray>;
  33553. /**
  33554. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33555. */
  33556. normals: Nullable<FloatArray>;
  33557. /**
  33558. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33559. */
  33560. tangents: Nullable<FloatArray>;
  33561. /**
  33562. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33563. */
  33564. uvs: Nullable<FloatArray>;
  33565. /**
  33566. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33567. */
  33568. uvs2: Nullable<FloatArray>;
  33569. /**
  33570. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33571. */
  33572. uvs3: Nullable<FloatArray>;
  33573. /**
  33574. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33575. */
  33576. uvs4: Nullable<FloatArray>;
  33577. /**
  33578. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33579. */
  33580. uvs5: Nullable<FloatArray>;
  33581. /**
  33582. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33583. */
  33584. uvs6: Nullable<FloatArray>;
  33585. /**
  33586. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33587. */
  33588. colors: Nullable<FloatArray>;
  33589. /**
  33590. * 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).
  33591. */
  33592. matricesIndices: Nullable<FloatArray>;
  33593. /**
  33594. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33595. */
  33596. matricesWeights: Nullable<FloatArray>;
  33597. /**
  33598. * An array extending the number of possible indices
  33599. */
  33600. matricesIndicesExtra: Nullable<FloatArray>;
  33601. /**
  33602. * An array extending the number of possible weights when the number of indices is extended
  33603. */
  33604. matricesWeightsExtra: Nullable<FloatArray>;
  33605. /**
  33606. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33607. */
  33608. indices: Nullable<IndicesArray>;
  33609. /**
  33610. * Uses the passed data array to set the set the values for the specified kind of data
  33611. * @param data a linear array of floating numbers
  33612. * @param kind the type of data that is being set, eg positions, colors etc
  33613. */
  33614. set(data: FloatArray, kind: string): void;
  33615. /**
  33616. * Associates the vertexData to the passed Mesh.
  33617. * Sets it as updatable or not (default `false`)
  33618. * @param mesh the mesh the vertexData is applied to
  33619. * @param updatable when used and having the value true allows new data to update the vertexData
  33620. * @returns the VertexData
  33621. */
  33622. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33623. /**
  33624. * Associates the vertexData to the passed Geometry.
  33625. * Sets it as updatable or not (default `false`)
  33626. * @param geometry the geometry the vertexData is applied to
  33627. * @param updatable when used and having the value true allows new data to update the vertexData
  33628. * @returns VertexData
  33629. */
  33630. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33631. /**
  33632. * Updates the associated mesh
  33633. * @param mesh the mesh to be updated
  33634. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33635. * @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
  33636. * @returns VertexData
  33637. */
  33638. updateMesh(mesh: Mesh): VertexData;
  33639. /**
  33640. * Updates the associated geometry
  33641. * @param geometry the geometry to be updated
  33642. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33643. * @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
  33644. * @returns VertexData.
  33645. */
  33646. updateGeometry(geometry: Geometry): VertexData;
  33647. private _applyTo;
  33648. private _update;
  33649. /**
  33650. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33651. * @param matrix the transforming matrix
  33652. * @returns the VertexData
  33653. */
  33654. transform(matrix: Matrix): VertexData;
  33655. /**
  33656. * Merges the passed VertexData into the current one
  33657. * @param other the VertexData to be merged into the current one
  33658. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33659. * @returns the modified VertexData
  33660. */
  33661. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33662. private _mergeElement;
  33663. private _validate;
  33664. /**
  33665. * Serializes the VertexData
  33666. * @returns a serialized object
  33667. */
  33668. serialize(): any;
  33669. /**
  33670. * Extracts the vertexData from a mesh
  33671. * @param mesh the mesh from which to extract the VertexData
  33672. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33673. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33674. * @returns the object VertexData associated to the passed mesh
  33675. */
  33676. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33677. /**
  33678. * Extracts the vertexData from the geometry
  33679. * @param geometry the geometry from which to extract the VertexData
  33680. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33681. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33682. * @returns the object VertexData associated to the passed mesh
  33683. */
  33684. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33685. private static _ExtractFrom;
  33686. /**
  33687. * Creates the VertexData for a Ribbon
  33688. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33689. * * pathArray array of paths, each of which an array of successive Vector3
  33690. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33691. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33692. * * 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
  33693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33694. * * 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)
  33695. * * 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)
  33696. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33697. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33698. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33699. * @returns the VertexData of the ribbon
  33700. */
  33701. static CreateRibbon(options: {
  33702. pathArray: Vector3[][];
  33703. closeArray?: boolean;
  33704. closePath?: boolean;
  33705. offset?: number;
  33706. sideOrientation?: number;
  33707. frontUVs?: Vector4;
  33708. backUVs?: Vector4;
  33709. invertUV?: boolean;
  33710. uvs?: Vector2[];
  33711. colors?: Color4[];
  33712. }): VertexData;
  33713. /**
  33714. * Creates the VertexData for a box
  33715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33716. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33717. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33718. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33719. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33720. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33721. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33723. * * 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)
  33724. * * 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)
  33725. * @returns the VertexData of the box
  33726. */
  33727. static CreateBox(options: {
  33728. size?: number;
  33729. width?: number;
  33730. height?: number;
  33731. depth?: number;
  33732. faceUV?: Vector4[];
  33733. faceColors?: Color4[];
  33734. sideOrientation?: number;
  33735. frontUVs?: Vector4;
  33736. backUVs?: Vector4;
  33737. }): VertexData;
  33738. /**
  33739. * Creates the VertexData for a tiled box
  33740. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33741. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33742. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33743. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33745. * @returns the VertexData of the box
  33746. */
  33747. static CreateTiledBox(options: {
  33748. pattern?: number;
  33749. width?: number;
  33750. height?: number;
  33751. depth?: number;
  33752. tileSize?: number;
  33753. tileWidth?: number;
  33754. tileHeight?: number;
  33755. alignHorizontal?: number;
  33756. alignVertical?: number;
  33757. faceUV?: Vector4[];
  33758. faceColors?: Color4[];
  33759. sideOrientation?: number;
  33760. }): VertexData;
  33761. /**
  33762. * Creates the VertexData for a tiled plane
  33763. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33764. * * pattern a limited pattern arrangement depending on the number
  33765. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33766. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33767. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33769. * * 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)
  33770. * * 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)
  33771. * @returns the VertexData of the tiled plane
  33772. */
  33773. static CreateTiledPlane(options: {
  33774. pattern?: number;
  33775. tileSize?: number;
  33776. tileWidth?: number;
  33777. tileHeight?: number;
  33778. size?: number;
  33779. width?: number;
  33780. height?: number;
  33781. alignHorizontal?: number;
  33782. alignVertical?: number;
  33783. sideOrientation?: number;
  33784. frontUVs?: Vector4;
  33785. backUVs?: Vector4;
  33786. }): VertexData;
  33787. /**
  33788. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33789. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33790. * * segments sets the number of horizontal strips optional, default 32
  33791. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33792. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33793. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33794. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33795. * * 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
  33796. * * 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
  33797. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33798. * * 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)
  33799. * * 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)
  33800. * @returns the VertexData of the ellipsoid
  33801. */
  33802. static CreateSphere(options: {
  33803. segments?: number;
  33804. diameter?: number;
  33805. diameterX?: number;
  33806. diameterY?: number;
  33807. diameterZ?: number;
  33808. arc?: number;
  33809. slice?: number;
  33810. sideOrientation?: number;
  33811. frontUVs?: Vector4;
  33812. backUVs?: Vector4;
  33813. }): VertexData;
  33814. /**
  33815. * Creates the VertexData for a cylinder, cone or prism
  33816. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33817. * * height sets the height (y direction) of the cylinder, optional, default 2
  33818. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33819. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33820. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33821. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33822. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33823. * * 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
  33824. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33825. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33826. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33827. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33829. * * 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)
  33830. * * 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)
  33831. * @returns the VertexData of the cylinder, cone or prism
  33832. */
  33833. static CreateCylinder(options: {
  33834. height?: number;
  33835. diameterTop?: number;
  33836. diameterBottom?: number;
  33837. diameter?: number;
  33838. tessellation?: number;
  33839. subdivisions?: number;
  33840. arc?: number;
  33841. faceColors?: Color4[];
  33842. faceUV?: Vector4[];
  33843. hasRings?: boolean;
  33844. enclose?: boolean;
  33845. sideOrientation?: number;
  33846. frontUVs?: Vector4;
  33847. backUVs?: Vector4;
  33848. }): VertexData;
  33849. /**
  33850. * Creates the VertexData for a torus
  33851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33852. * * diameter the diameter of the torus, optional default 1
  33853. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33854. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33856. * * 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)
  33857. * * 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)
  33858. * @returns the VertexData of the torus
  33859. */
  33860. static CreateTorus(options: {
  33861. diameter?: number;
  33862. thickness?: number;
  33863. tessellation?: number;
  33864. sideOrientation?: number;
  33865. frontUVs?: Vector4;
  33866. backUVs?: Vector4;
  33867. }): VertexData;
  33868. /**
  33869. * Creates the VertexData of the LineSystem
  33870. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33871. * - lines an array of lines, each line being an array of successive Vector3
  33872. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33873. * @returns the VertexData of the LineSystem
  33874. */
  33875. static CreateLineSystem(options: {
  33876. lines: Vector3[][];
  33877. colors?: Nullable<Color4[][]>;
  33878. }): VertexData;
  33879. /**
  33880. * Create the VertexData for a DashedLines
  33881. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33882. * - points an array successive Vector3
  33883. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33884. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33885. * - dashNb the intended total number of dashes, optional, default 200
  33886. * @returns the VertexData for the DashedLines
  33887. */
  33888. static CreateDashedLines(options: {
  33889. points: Vector3[];
  33890. dashSize?: number;
  33891. gapSize?: number;
  33892. dashNb?: number;
  33893. }): VertexData;
  33894. /**
  33895. * Creates the VertexData for a Ground
  33896. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33897. * - width the width (x direction) of the ground, optional, default 1
  33898. * - height the height (z direction) of the ground, optional, default 1
  33899. * - subdivisions the number of subdivisions per side, optional, default 1
  33900. * @returns the VertexData of the Ground
  33901. */
  33902. static CreateGround(options: {
  33903. width?: number;
  33904. height?: number;
  33905. subdivisions?: number;
  33906. subdivisionsX?: number;
  33907. subdivisionsY?: number;
  33908. }): VertexData;
  33909. /**
  33910. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33911. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33912. * * xmin the ground minimum X coordinate, optional, default -1
  33913. * * zmin the ground minimum Z coordinate, optional, default -1
  33914. * * xmax the ground maximum X coordinate, optional, default 1
  33915. * * zmax the ground maximum Z coordinate, optional, default 1
  33916. * * 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}
  33917. * * 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}
  33918. * @returns the VertexData of the TiledGround
  33919. */
  33920. static CreateTiledGround(options: {
  33921. xmin: number;
  33922. zmin: number;
  33923. xmax: number;
  33924. zmax: number;
  33925. subdivisions?: {
  33926. w: number;
  33927. h: number;
  33928. };
  33929. precision?: {
  33930. w: number;
  33931. h: number;
  33932. };
  33933. }): VertexData;
  33934. /**
  33935. * Creates the VertexData of the Ground designed from a heightmap
  33936. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33937. * * width the width (x direction) of the ground
  33938. * * height the height (z direction) of the ground
  33939. * * subdivisions the number of subdivisions per side
  33940. * * minHeight the minimum altitude on the ground, optional, default 0
  33941. * * maxHeight the maximum altitude on the ground, optional default 1
  33942. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33943. * * buffer the array holding the image color data
  33944. * * bufferWidth the width of image
  33945. * * bufferHeight the height of image
  33946. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33947. * @returns the VertexData of the Ground designed from a heightmap
  33948. */
  33949. static CreateGroundFromHeightMap(options: {
  33950. width: number;
  33951. height: number;
  33952. subdivisions: number;
  33953. minHeight: number;
  33954. maxHeight: number;
  33955. colorFilter: Color3;
  33956. buffer: Uint8Array;
  33957. bufferWidth: number;
  33958. bufferHeight: number;
  33959. alphaFilter: number;
  33960. }): VertexData;
  33961. /**
  33962. * Creates the VertexData for a Plane
  33963. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33964. * * size sets the width and height of the plane to the value of size, optional default 1
  33965. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33966. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33968. * * 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)
  33969. * * 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)
  33970. * @returns the VertexData of the box
  33971. */
  33972. static CreatePlane(options: {
  33973. size?: number;
  33974. width?: number;
  33975. height?: number;
  33976. sideOrientation?: number;
  33977. frontUVs?: Vector4;
  33978. backUVs?: Vector4;
  33979. }): VertexData;
  33980. /**
  33981. * Creates the VertexData of the Disc or regular Polygon
  33982. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33983. * * radius the radius of the disc, optional default 0.5
  33984. * * tessellation the number of polygon sides, optional, default 64
  33985. * * 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
  33986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33987. * * 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)
  33988. * * 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)
  33989. * @returns the VertexData of the box
  33990. */
  33991. static CreateDisc(options: {
  33992. radius?: number;
  33993. tessellation?: number;
  33994. arc?: number;
  33995. sideOrientation?: number;
  33996. frontUVs?: Vector4;
  33997. backUVs?: Vector4;
  33998. }): VertexData;
  33999. /**
  34000. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34001. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34002. * @param polygon a mesh built from polygonTriangulation.build()
  34003. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34004. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34005. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34006. * @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)
  34007. * @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)
  34008. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34009. * @returns the VertexData of the Polygon
  34010. */
  34011. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34012. /**
  34013. * Creates the VertexData of the IcoSphere
  34014. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34015. * * radius the radius of the IcoSphere, optional default 1
  34016. * * radiusX allows stretching in the x direction, optional, default radius
  34017. * * radiusY allows stretching in the y direction, optional, default radius
  34018. * * radiusZ allows stretching in the z direction, optional, default radius
  34019. * * flat when true creates a flat shaded mesh, optional, default true
  34020. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34022. * * 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)
  34023. * * 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)
  34024. * @returns the VertexData of the IcoSphere
  34025. */
  34026. static CreateIcoSphere(options: {
  34027. radius?: number;
  34028. radiusX?: number;
  34029. radiusY?: number;
  34030. radiusZ?: number;
  34031. flat?: boolean;
  34032. subdivisions?: number;
  34033. sideOrientation?: number;
  34034. frontUVs?: Vector4;
  34035. backUVs?: Vector4;
  34036. }): VertexData;
  34037. /**
  34038. * Creates the VertexData for a Polyhedron
  34039. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34040. * * type provided types are:
  34041. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34042. * * 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)
  34043. * * size the size of the IcoSphere, optional default 1
  34044. * * sizeX allows stretching in the x direction, optional, default size
  34045. * * sizeY allows stretching in the y direction, optional, default size
  34046. * * sizeZ allows stretching in the z direction, optional, default size
  34047. * * 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
  34048. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34049. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34050. * * flat when true creates a flat shaded mesh, optional, default true
  34051. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34053. * * 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)
  34054. * * 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)
  34055. * @returns the VertexData of the Polyhedron
  34056. */
  34057. static CreatePolyhedron(options: {
  34058. type?: number;
  34059. size?: number;
  34060. sizeX?: number;
  34061. sizeY?: number;
  34062. sizeZ?: number;
  34063. custom?: any;
  34064. faceUV?: Vector4[];
  34065. faceColors?: Color4[];
  34066. flat?: boolean;
  34067. sideOrientation?: number;
  34068. frontUVs?: Vector4;
  34069. backUVs?: Vector4;
  34070. }): VertexData;
  34071. /**
  34072. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34073. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34074. * @returns the VertexData of the Capsule
  34075. */
  34076. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34077. /**
  34078. * Creates the VertexData for a TorusKnot
  34079. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34080. * * radius the radius of the torus knot, optional, default 2
  34081. * * tube the thickness of the tube, optional, default 0.5
  34082. * * radialSegments the number of sides on each tube segments, optional, default 32
  34083. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34084. * * p the number of windings around the z axis, optional, default 2
  34085. * * q the number of windings around the x axis, optional, default 3
  34086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34087. * * 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)
  34088. * * 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)
  34089. * @returns the VertexData of the Torus Knot
  34090. */
  34091. static CreateTorusKnot(options: {
  34092. radius?: number;
  34093. tube?: number;
  34094. radialSegments?: number;
  34095. tubularSegments?: number;
  34096. p?: number;
  34097. q?: number;
  34098. sideOrientation?: number;
  34099. frontUVs?: Vector4;
  34100. backUVs?: Vector4;
  34101. }): VertexData;
  34102. /**
  34103. * Compute normals for given positions and indices
  34104. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34105. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34106. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34107. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34108. * * facetNormals : optional array of facet normals (vector3)
  34109. * * facetPositions : optional array of facet positions (vector3)
  34110. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34111. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34112. * * bInfo : optional bounding info, required for facetPartitioning computation
  34113. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34114. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34115. * * useRightHandedSystem: optional boolean to for right handed system computation
  34116. * * depthSort : optional boolean to enable the facet depth sort computation
  34117. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34118. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34119. */
  34120. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34121. facetNormals?: any;
  34122. facetPositions?: any;
  34123. facetPartitioning?: any;
  34124. ratio?: number;
  34125. bInfo?: any;
  34126. bbSize?: Vector3;
  34127. subDiv?: any;
  34128. useRightHandedSystem?: boolean;
  34129. depthSort?: boolean;
  34130. distanceTo?: Vector3;
  34131. depthSortedFacets?: any;
  34132. }): void;
  34133. /** @hidden */
  34134. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34135. /**
  34136. * Applies VertexData created from the imported parameters to the geometry
  34137. * @param parsedVertexData the parsed data from an imported file
  34138. * @param geometry the geometry to apply the VertexData to
  34139. */
  34140. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34141. }
  34142. }
  34143. declare module BABYLON {
  34144. /**
  34145. * Class containing static functions to help procedurally build meshes
  34146. */
  34147. export class DiscBuilder {
  34148. /**
  34149. * Creates a plane polygonal mesh. By default, this is a disc
  34150. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34151. * * 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
  34152. * * 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
  34153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34154. * * 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
  34155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34156. * @param name defines the name of the mesh
  34157. * @param options defines the options used to create the mesh
  34158. * @param scene defines the hosting scene
  34159. * @returns the plane polygonal mesh
  34160. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34161. */
  34162. static CreateDisc(name: string, options: {
  34163. radius?: number;
  34164. tessellation?: number;
  34165. arc?: number;
  34166. updatable?: boolean;
  34167. sideOrientation?: number;
  34168. frontUVs?: Vector4;
  34169. backUVs?: Vector4;
  34170. }, scene?: Nullable<Scene>): Mesh;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34176. *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.
  34177. * The SPS is also a particle system. It provides some methods to manage the particles.
  34178. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34179. *
  34180. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34181. */
  34182. export class SolidParticleSystem implements IDisposable {
  34183. /**
  34184. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34185. * Example : var p = SPS.particles[i];
  34186. */
  34187. particles: SolidParticle[];
  34188. /**
  34189. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34190. */
  34191. nbParticles: number;
  34192. /**
  34193. * If the particles must ever face the camera (default false). Useful for planar particles.
  34194. */
  34195. billboard: boolean;
  34196. /**
  34197. * Recompute normals when adding a shape
  34198. */
  34199. recomputeNormals: boolean;
  34200. /**
  34201. * This a counter ofr your own usage. It's not set by any SPS functions.
  34202. */
  34203. counter: number;
  34204. /**
  34205. * The SPS name. This name is also given to the underlying mesh.
  34206. */
  34207. name: string;
  34208. /**
  34209. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34210. */
  34211. mesh: Mesh;
  34212. /**
  34213. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34214. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34215. */
  34216. vars: any;
  34217. /**
  34218. * This array is populated when the SPS is set as 'pickable'.
  34219. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34220. * Each element of this array is an object `{idx: int, faceId: int}`.
  34221. * `idx` is the picked particle index in the `SPS.particles` array
  34222. * `faceId` is the picked face index counted within this particle.
  34223. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34224. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34225. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34226. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34227. */
  34228. pickedParticles: {
  34229. idx: number;
  34230. faceId: number;
  34231. }[];
  34232. /**
  34233. * This array is populated when the SPS is set as 'pickable'
  34234. * Each key of this array is a submesh index.
  34235. * Each element of this array is a second array defined like this :
  34236. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34237. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34238. * `idx` is the picked particle index in the `SPS.particles` array
  34239. * `faceId` is the picked face index counted within this particle.
  34240. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34241. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34242. */
  34243. pickedBySubMesh: {
  34244. idx: number;
  34245. faceId: number;
  34246. }[][];
  34247. /**
  34248. * This array is populated when `enableDepthSort` is set to true.
  34249. * Each element of this array is an instance of the class DepthSortedParticle.
  34250. */
  34251. depthSortedParticles: DepthSortedParticle[];
  34252. /**
  34253. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34254. * @hidden
  34255. */
  34256. _bSphereOnly: boolean;
  34257. /**
  34258. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34259. * @hidden
  34260. */
  34261. _bSphereRadiusFactor: number;
  34262. private _scene;
  34263. private _positions;
  34264. private _indices;
  34265. private _normals;
  34266. private _colors;
  34267. private _uvs;
  34268. private _indices32;
  34269. private _positions32;
  34270. private _normals32;
  34271. private _fixedNormal32;
  34272. private _colors32;
  34273. private _uvs32;
  34274. private _index;
  34275. private _updatable;
  34276. private _pickable;
  34277. private _isVisibilityBoxLocked;
  34278. private _alwaysVisible;
  34279. private _depthSort;
  34280. private _expandable;
  34281. private _shapeCounter;
  34282. private _copy;
  34283. private _color;
  34284. private _computeParticleColor;
  34285. private _computeParticleTexture;
  34286. private _computeParticleRotation;
  34287. private _computeParticleVertex;
  34288. private _computeBoundingBox;
  34289. private _depthSortParticles;
  34290. private _camera;
  34291. private _mustUnrotateFixedNormals;
  34292. private _particlesIntersect;
  34293. private _needs32Bits;
  34294. private _isNotBuilt;
  34295. private _lastParticleId;
  34296. private _idxOfId;
  34297. private _multimaterialEnabled;
  34298. private _useModelMaterial;
  34299. private _indicesByMaterial;
  34300. private _materialIndexes;
  34301. private _depthSortFunction;
  34302. private _materialSortFunction;
  34303. private _materials;
  34304. private _multimaterial;
  34305. private _materialIndexesById;
  34306. private _defaultMaterial;
  34307. private _autoUpdateSubMeshes;
  34308. private _tmpVertex;
  34309. /**
  34310. * Creates a SPS (Solid Particle System) object.
  34311. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34312. * @param scene (Scene) is the scene in which the SPS is added.
  34313. * @param options defines the options of the sps e.g.
  34314. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34315. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34316. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34317. * * 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.
  34318. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34319. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34320. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34321. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34322. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34323. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34324. */
  34325. constructor(name: string, scene: Scene, options?: {
  34326. updatable?: boolean;
  34327. isPickable?: boolean;
  34328. enableDepthSort?: boolean;
  34329. particleIntersection?: boolean;
  34330. boundingSphereOnly?: boolean;
  34331. bSphereRadiusFactor?: number;
  34332. expandable?: boolean;
  34333. useModelMaterial?: boolean;
  34334. enableMultiMaterial?: boolean;
  34335. });
  34336. /**
  34337. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34338. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34339. * @returns the created mesh
  34340. */
  34341. buildMesh(): Mesh;
  34342. /**
  34343. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34344. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34345. * Thus the particles generated from `digest()` have their property `position` set yet.
  34346. * @param mesh ( Mesh ) is the mesh to be digested
  34347. * @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
  34348. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34349. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34350. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34351. * @returns the current SPS
  34352. */
  34353. digest(mesh: Mesh, options?: {
  34354. facetNb?: number;
  34355. number?: number;
  34356. delta?: number;
  34357. storage?: [];
  34358. }): SolidParticleSystem;
  34359. /**
  34360. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34361. * @hidden
  34362. */
  34363. private _unrotateFixedNormals;
  34364. /**
  34365. * Resets the temporary working copy particle
  34366. * @hidden
  34367. */
  34368. private _resetCopy;
  34369. /**
  34370. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34371. * @param p the current index in the positions array to be updated
  34372. * @param ind the current index in the indices array
  34373. * @param shape a Vector3 array, the shape geometry
  34374. * @param positions the positions array to be updated
  34375. * @param meshInd the shape indices array
  34376. * @param indices the indices array to be updated
  34377. * @param meshUV the shape uv array
  34378. * @param uvs the uv array to be updated
  34379. * @param meshCol the shape color array
  34380. * @param colors the color array to be updated
  34381. * @param meshNor the shape normals array
  34382. * @param normals the normals array to be updated
  34383. * @param idx the particle index
  34384. * @param idxInShape the particle index in its shape
  34385. * @param options the addShape() method passed options
  34386. * @model the particle model
  34387. * @hidden
  34388. */
  34389. private _meshBuilder;
  34390. /**
  34391. * Returns a shape Vector3 array from positions float array
  34392. * @param positions float array
  34393. * @returns a vector3 array
  34394. * @hidden
  34395. */
  34396. private _posToShape;
  34397. /**
  34398. * Returns a shapeUV array from a float uvs (array deep copy)
  34399. * @param uvs as a float array
  34400. * @returns a shapeUV array
  34401. * @hidden
  34402. */
  34403. private _uvsToShapeUV;
  34404. /**
  34405. * Adds a new particle object in the particles array
  34406. * @param idx particle index in particles array
  34407. * @param id particle id
  34408. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34409. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34410. * @param model particle ModelShape object
  34411. * @param shapeId model shape identifier
  34412. * @param idxInShape index of the particle in the current model
  34413. * @param bInfo model bounding info object
  34414. * @param storage target storage array, if any
  34415. * @hidden
  34416. */
  34417. private _addParticle;
  34418. /**
  34419. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34420. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34421. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34422. * @param nb (positive integer) the number of particles to be created from this model
  34423. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34424. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34425. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34426. * @returns the number of shapes in the system
  34427. */
  34428. addShape(mesh: Mesh, nb: number, options?: {
  34429. positionFunction?: any;
  34430. vertexFunction?: any;
  34431. storage?: [];
  34432. }): number;
  34433. /**
  34434. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34435. * @hidden
  34436. */
  34437. private _rebuildParticle;
  34438. /**
  34439. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34440. * @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.
  34441. * @returns the SPS.
  34442. */
  34443. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34444. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34445. * Returns an array with the removed particles.
  34446. * 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.
  34447. * The SPS can't be empty so at least one particle needs to remain in place.
  34448. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34449. * @param start index of the first particle to remove
  34450. * @param end index of the last particle to remove (included)
  34451. * @returns an array populated with the removed particles
  34452. */
  34453. removeParticles(start: number, end: number): SolidParticle[];
  34454. /**
  34455. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34456. * @param solidParticleArray an array populated with Solid Particles objects
  34457. * @returns the SPS
  34458. */
  34459. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34460. /**
  34461. * Creates a new particle and modifies the SPS mesh geometry :
  34462. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34463. * - calls _addParticle() to populate the particle array
  34464. * factorized code from addShape() and insertParticlesFromArray()
  34465. * @param idx particle index in the particles array
  34466. * @param i particle index in its shape
  34467. * @param modelShape particle ModelShape object
  34468. * @param shape shape vertex array
  34469. * @param meshInd shape indices array
  34470. * @param meshUV shape uv array
  34471. * @param meshCol shape color array
  34472. * @param meshNor shape normals array
  34473. * @param bbInfo shape bounding info
  34474. * @param storage target particle storage
  34475. * @options addShape() passed options
  34476. * @hidden
  34477. */
  34478. private _insertNewParticle;
  34479. /**
  34480. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34481. * This method calls `updateParticle()` for each particle of the SPS.
  34482. * For an animated SPS, it is usually called within the render loop.
  34483. * 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.
  34484. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34485. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34486. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34487. * @returns the SPS.
  34488. */
  34489. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34490. /**
  34491. * Disposes the SPS.
  34492. */
  34493. dispose(): void;
  34494. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34495. * idx is the particle index in the SPS
  34496. * faceId is the picked face index counted within this particle.
  34497. * Returns null if the pickInfo can't identify a picked particle.
  34498. * @param pickingInfo (PickingInfo object)
  34499. * @returns {idx: number, faceId: number} or null
  34500. */
  34501. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34502. idx: number;
  34503. faceId: number;
  34504. }>;
  34505. /**
  34506. * Returns a SolidParticle object from its identifier : particle.id
  34507. * @param id (integer) the particle Id
  34508. * @returns the searched particle or null if not found in the SPS.
  34509. */
  34510. getParticleById(id: number): Nullable<SolidParticle>;
  34511. /**
  34512. * Returns a new array populated with the particles having the passed shapeId.
  34513. * @param shapeId (integer) the shape identifier
  34514. * @returns a new solid particle array
  34515. */
  34516. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34517. /**
  34518. * Populates the passed array "ref" with the particles having the passed shapeId.
  34519. * @param shapeId the shape identifier
  34520. * @returns the SPS
  34521. * @param ref
  34522. */
  34523. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34524. /**
  34525. * Computes the required SubMeshes according the materials assigned to the particles.
  34526. * @returns the solid particle system.
  34527. * Does nothing if called before the SPS mesh is built.
  34528. */
  34529. computeSubMeshes(): SolidParticleSystem;
  34530. /**
  34531. * Sorts the solid particles by material when MultiMaterial is enabled.
  34532. * Updates the indices32 array.
  34533. * Updates the indicesByMaterial array.
  34534. * Updates the mesh indices array.
  34535. * @returns the SPS
  34536. * @hidden
  34537. */
  34538. private _sortParticlesByMaterial;
  34539. /**
  34540. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34541. * @hidden
  34542. */
  34543. private _setMaterialIndexesById;
  34544. /**
  34545. * Returns an array with unique values of Materials from the passed array
  34546. * @param array the material array to be checked and filtered
  34547. * @hidden
  34548. */
  34549. private _filterUniqueMaterialId;
  34550. /**
  34551. * Sets a new Standard Material as _defaultMaterial if not already set.
  34552. * @hidden
  34553. */
  34554. private _setDefaultMaterial;
  34555. /**
  34556. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34557. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34558. * @returns the SPS.
  34559. */
  34560. refreshVisibleSize(): SolidParticleSystem;
  34561. /**
  34562. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34563. * @param size the size (float) of the visibility box
  34564. * note : this doesn't lock the SPS mesh bounding box.
  34565. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34566. */
  34567. setVisibilityBox(size: number): void;
  34568. /**
  34569. * Gets whether the SPS as always visible or not
  34570. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34571. */
  34572. get isAlwaysVisible(): boolean;
  34573. /**
  34574. * Sets the SPS as always visible or not
  34575. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34576. */
  34577. set isAlwaysVisible(val: boolean);
  34578. /**
  34579. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34580. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34581. */
  34582. set isVisibilityBoxLocked(val: boolean);
  34583. /**
  34584. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34585. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34586. */
  34587. get isVisibilityBoxLocked(): boolean;
  34588. /**
  34589. * Tells to `setParticles()` to compute the particle rotations or not.
  34590. * Default value : true. The SPS is faster when it's set to false.
  34591. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34592. */
  34593. set computeParticleRotation(val: boolean);
  34594. /**
  34595. * Tells to `setParticles()` to compute the particle colors or not.
  34596. * Default value : true. The SPS is faster when it's set to false.
  34597. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34598. */
  34599. set computeParticleColor(val: boolean);
  34600. set computeParticleTexture(val: boolean);
  34601. /**
  34602. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34603. * Default value : false. The SPS is faster when it's set to false.
  34604. * Note : the particle custom vertex positions aren't stored values.
  34605. */
  34606. set computeParticleVertex(val: boolean);
  34607. /**
  34608. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34609. */
  34610. set computeBoundingBox(val: boolean);
  34611. /**
  34612. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34613. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34614. * Default : `true`
  34615. */
  34616. set depthSortParticles(val: boolean);
  34617. /**
  34618. * Gets if `setParticles()` computes the particle rotations or not.
  34619. * Default value : true. The SPS is faster when it's set to false.
  34620. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34621. */
  34622. get computeParticleRotation(): boolean;
  34623. /**
  34624. * Gets if `setParticles()` computes the particle colors or not.
  34625. * Default value : true. The SPS is faster when it's set to false.
  34626. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34627. */
  34628. get computeParticleColor(): boolean;
  34629. /**
  34630. * Gets if `setParticles()` computes the particle textures or not.
  34631. * Default value : true. The SPS is faster when it's set to false.
  34632. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34633. */
  34634. get computeParticleTexture(): boolean;
  34635. /**
  34636. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34637. * Default value : false. The SPS is faster when it's set to false.
  34638. * Note : the particle custom vertex positions aren't stored values.
  34639. */
  34640. get computeParticleVertex(): boolean;
  34641. /**
  34642. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34643. */
  34644. get computeBoundingBox(): boolean;
  34645. /**
  34646. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34647. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34648. * Default : `true`
  34649. */
  34650. get depthSortParticles(): boolean;
  34651. /**
  34652. * Gets if the SPS is created as expandable at construction time.
  34653. * Default : `false`
  34654. */
  34655. get expandable(): boolean;
  34656. /**
  34657. * Gets if the SPS supports the Multi Materials
  34658. */
  34659. get multimaterialEnabled(): boolean;
  34660. /**
  34661. * Gets if the SPS uses the model materials for its own multimaterial.
  34662. */
  34663. get useModelMaterial(): boolean;
  34664. /**
  34665. * The SPS used material array.
  34666. */
  34667. get materials(): Material[];
  34668. /**
  34669. * Sets the SPS MultiMaterial from the passed materials.
  34670. * Note : the passed array is internally copied and not used then by reference.
  34671. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34672. */
  34673. setMultiMaterial(materials: Material[]): void;
  34674. /**
  34675. * The SPS computed multimaterial object
  34676. */
  34677. get multimaterial(): MultiMaterial;
  34678. set multimaterial(mm: MultiMaterial);
  34679. /**
  34680. * If the subMeshes must be updated on the next call to setParticles()
  34681. */
  34682. get autoUpdateSubMeshes(): boolean;
  34683. set autoUpdateSubMeshes(val: boolean);
  34684. /**
  34685. * This function does nothing. It may be overwritten to set all the particle first values.
  34686. * The SPS doesn't call this function, you may have to call it by your own.
  34687. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34688. */
  34689. initParticles(): void;
  34690. /**
  34691. * This function does nothing. It may be overwritten to recycle a particle.
  34692. * The SPS doesn't call this function, you may have to call it by your own.
  34693. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34694. * @param particle The particle to recycle
  34695. * @returns the recycled particle
  34696. */
  34697. recycleParticle(particle: SolidParticle): SolidParticle;
  34698. /**
  34699. * Updates a particle : this function should be overwritten by the user.
  34700. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34701. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34702. * @example : just set a particle position or velocity and recycle conditions
  34703. * @param particle The particle to update
  34704. * @returns the updated particle
  34705. */
  34706. updateParticle(particle: SolidParticle): SolidParticle;
  34707. /**
  34708. * Updates a vertex of a particle : it can be overwritten by the user.
  34709. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34710. * @param particle the current particle
  34711. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34712. * @param pt the index of the current vertex in the particle shape
  34713. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34714. * @example : just set a vertex particle position or color
  34715. * @returns the sps
  34716. */
  34717. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34718. /**
  34719. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34720. * This does nothing and may be overwritten by the user.
  34721. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34722. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34723. * @param update the boolean update value actually passed to setParticles()
  34724. */
  34725. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34726. /**
  34727. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34728. * This will be passed three parameters.
  34729. * This does nothing and may be overwritten by the user.
  34730. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34731. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34732. * @param update the boolean update value actually passed to setParticles()
  34733. */
  34734. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34735. }
  34736. }
  34737. declare module BABYLON {
  34738. /**
  34739. * Represents one particle of a solid particle system.
  34740. */
  34741. export class SolidParticle {
  34742. /**
  34743. * particle global index
  34744. */
  34745. idx: number;
  34746. /**
  34747. * particle identifier
  34748. */
  34749. id: number;
  34750. /**
  34751. * The color of the particle
  34752. */
  34753. color: Nullable<Color4>;
  34754. /**
  34755. * The world space position of the particle.
  34756. */
  34757. position: Vector3;
  34758. /**
  34759. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34760. */
  34761. rotation: Vector3;
  34762. /**
  34763. * The world space rotation quaternion of the particle.
  34764. */
  34765. rotationQuaternion: Nullable<Quaternion>;
  34766. /**
  34767. * The scaling of the particle.
  34768. */
  34769. scaling: Vector3;
  34770. /**
  34771. * The uvs of the particle.
  34772. */
  34773. uvs: Vector4;
  34774. /**
  34775. * The current speed of the particle.
  34776. */
  34777. velocity: Vector3;
  34778. /**
  34779. * The pivot point in the particle local space.
  34780. */
  34781. pivot: Vector3;
  34782. /**
  34783. * Must the particle be translated from its pivot point in its local space ?
  34784. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34785. * Default : false
  34786. */
  34787. translateFromPivot: boolean;
  34788. /**
  34789. * Is the particle active or not ?
  34790. */
  34791. alive: boolean;
  34792. /**
  34793. * Is the particle visible or not ?
  34794. */
  34795. isVisible: boolean;
  34796. /**
  34797. * Index of this particle in the global "positions" array (Internal use)
  34798. * @hidden
  34799. */
  34800. _pos: number;
  34801. /**
  34802. * @hidden Index of this particle in the global "indices" array (Internal use)
  34803. */
  34804. _ind: number;
  34805. /**
  34806. * @hidden ModelShape of this particle (Internal use)
  34807. */
  34808. _model: ModelShape;
  34809. /**
  34810. * ModelShape id of this particle
  34811. */
  34812. shapeId: number;
  34813. /**
  34814. * Index of the particle in its shape id
  34815. */
  34816. idxInShape: number;
  34817. /**
  34818. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34819. */
  34820. _modelBoundingInfo: BoundingInfo;
  34821. /**
  34822. * @hidden Particle BoundingInfo object (Internal use)
  34823. */
  34824. _boundingInfo: BoundingInfo;
  34825. /**
  34826. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34827. */
  34828. _sps: SolidParticleSystem;
  34829. /**
  34830. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34831. */
  34832. _stillInvisible: boolean;
  34833. /**
  34834. * @hidden Last computed particle rotation matrix
  34835. */
  34836. _rotationMatrix: number[];
  34837. /**
  34838. * Parent particle Id, if any.
  34839. * Default null.
  34840. */
  34841. parentId: Nullable<number>;
  34842. /**
  34843. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34844. */
  34845. materialIndex: Nullable<number>;
  34846. /**
  34847. * Custom object or properties.
  34848. */
  34849. props: Nullable<any>;
  34850. /**
  34851. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34852. * The possible values are :
  34853. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34854. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34855. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34856. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34857. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34858. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34859. * */
  34860. cullingStrategy: number;
  34861. /**
  34862. * @hidden Internal global position in the SPS.
  34863. */
  34864. _globalPosition: Vector3;
  34865. /**
  34866. * Creates a Solid Particle object.
  34867. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34868. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34869. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34870. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34871. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34872. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34873. * @param shapeId (integer) is the model shape identifier in the SPS.
  34874. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34875. * @param sps defines the sps it is associated to
  34876. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34877. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34878. */
  34879. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34880. /**
  34881. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34882. * @param target the particle target
  34883. * @returns the current particle
  34884. */
  34885. copyToRef(target: SolidParticle): SolidParticle;
  34886. /**
  34887. * Legacy support, changed scale to scaling
  34888. */
  34889. get scale(): Vector3;
  34890. /**
  34891. * Legacy support, changed scale to scaling
  34892. */
  34893. set scale(scale: Vector3);
  34894. /**
  34895. * Legacy support, changed quaternion to rotationQuaternion
  34896. */
  34897. get quaternion(): Nullable<Quaternion>;
  34898. /**
  34899. * Legacy support, changed quaternion to rotationQuaternion
  34900. */
  34901. set quaternion(q: Nullable<Quaternion>);
  34902. /**
  34903. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34904. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34905. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34906. * @returns true if it intersects
  34907. */
  34908. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34909. /**
  34910. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34911. * A particle is in the frustum if its bounding box intersects the frustum
  34912. * @param frustumPlanes defines the frustum to test
  34913. * @returns true if the particle is in the frustum planes
  34914. */
  34915. isInFrustum(frustumPlanes: Plane[]): boolean;
  34916. /**
  34917. * get the rotation matrix of the particle
  34918. * @hidden
  34919. */
  34920. getRotationMatrix(m: Matrix): void;
  34921. }
  34922. /**
  34923. * Represents the shape of the model used by one particle of a solid particle system.
  34924. * SPS internal tool, don't use it manually.
  34925. */
  34926. export class ModelShape {
  34927. /**
  34928. * The shape id
  34929. * @hidden
  34930. */
  34931. shapeID: number;
  34932. /**
  34933. * flat array of model positions (internal use)
  34934. * @hidden
  34935. */
  34936. _shape: Vector3[];
  34937. /**
  34938. * flat array of model UVs (internal use)
  34939. * @hidden
  34940. */
  34941. _shapeUV: number[];
  34942. /**
  34943. * color array of the model
  34944. * @hidden
  34945. */
  34946. _shapeColors: number[];
  34947. /**
  34948. * indices array of the model
  34949. * @hidden
  34950. */
  34951. _indices: number[];
  34952. /**
  34953. * normals array of the model
  34954. * @hidden
  34955. */
  34956. _normals: number[];
  34957. /**
  34958. * length of the shape in the model indices array (internal use)
  34959. * @hidden
  34960. */
  34961. _indicesLength: number;
  34962. /**
  34963. * Custom position function (internal use)
  34964. * @hidden
  34965. */
  34966. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34967. /**
  34968. * Custom vertex function (internal use)
  34969. * @hidden
  34970. */
  34971. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34972. /**
  34973. * Model material (internal use)
  34974. * @hidden
  34975. */
  34976. _material: Nullable<Material>;
  34977. /**
  34978. * 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.
  34979. * SPS internal tool, don't use it manually.
  34980. * @hidden
  34981. */
  34982. 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>);
  34983. }
  34984. /**
  34985. * Represents a Depth Sorted Particle in the solid particle system.
  34986. * @hidden
  34987. */
  34988. export class DepthSortedParticle {
  34989. /**
  34990. * Particle index
  34991. */
  34992. idx: number;
  34993. /**
  34994. * Index of the particle in the "indices" array
  34995. */
  34996. ind: number;
  34997. /**
  34998. * Length of the particle shape in the "indices" array
  34999. */
  35000. indicesLength: number;
  35001. /**
  35002. * Squared distance from the particle to the camera
  35003. */
  35004. sqDistance: number;
  35005. /**
  35006. * Material index when used with MultiMaterials
  35007. */
  35008. materialIndex: number;
  35009. /**
  35010. * Creates a new sorted particle
  35011. * @param materialIndex
  35012. */
  35013. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35014. }
  35015. /**
  35016. * Represents a solid particle vertex
  35017. */
  35018. export class SolidParticleVertex {
  35019. /**
  35020. * Vertex position
  35021. */
  35022. position: Vector3;
  35023. /**
  35024. * Vertex color
  35025. */
  35026. color: Color4;
  35027. /**
  35028. * Vertex UV
  35029. */
  35030. uv: Vector2;
  35031. /**
  35032. * Creates a new solid particle vertex
  35033. */
  35034. constructor();
  35035. /** Vertex x coordinate */
  35036. get x(): number;
  35037. set x(val: number);
  35038. /** Vertex y coordinate */
  35039. get y(): number;
  35040. set y(val: number);
  35041. /** Vertex z coordinate */
  35042. get z(): number;
  35043. set z(val: number);
  35044. }
  35045. }
  35046. declare module BABYLON {
  35047. /**
  35048. * @hidden
  35049. */
  35050. export class _MeshCollisionData {
  35051. _checkCollisions: boolean;
  35052. _collisionMask: number;
  35053. _collisionGroup: number;
  35054. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35055. _collider: Nullable<Collider>;
  35056. _oldPositionForCollisions: Vector3;
  35057. _diffPositionForCollisions: Vector3;
  35058. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35059. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35060. _collisionResponse: boolean;
  35061. }
  35062. }
  35063. declare module BABYLON {
  35064. /** @hidden */
  35065. class _FacetDataStorage {
  35066. facetPositions: Vector3[];
  35067. facetNormals: Vector3[];
  35068. facetPartitioning: number[][];
  35069. facetNb: number;
  35070. partitioningSubdivisions: number;
  35071. partitioningBBoxRatio: number;
  35072. facetDataEnabled: boolean;
  35073. facetParameters: any;
  35074. bbSize: Vector3;
  35075. subDiv: {
  35076. max: number;
  35077. X: number;
  35078. Y: number;
  35079. Z: number;
  35080. };
  35081. facetDepthSort: boolean;
  35082. facetDepthSortEnabled: boolean;
  35083. depthSortedIndices: IndicesArray;
  35084. depthSortedFacets: {
  35085. ind: number;
  35086. sqDistance: number;
  35087. }[];
  35088. facetDepthSortFunction: (f1: {
  35089. ind: number;
  35090. sqDistance: number;
  35091. }, f2: {
  35092. ind: number;
  35093. sqDistance: number;
  35094. }) => number;
  35095. facetDepthSortFrom: Vector3;
  35096. facetDepthSortOrigin: Vector3;
  35097. invertedMatrix: Matrix;
  35098. }
  35099. /**
  35100. * @hidden
  35101. **/
  35102. class _InternalAbstractMeshDataInfo {
  35103. _hasVertexAlpha: boolean;
  35104. _useVertexColors: boolean;
  35105. _numBoneInfluencers: number;
  35106. _applyFog: boolean;
  35107. _receiveShadows: boolean;
  35108. _facetData: _FacetDataStorage;
  35109. _visibility: number;
  35110. _skeleton: Nullable<Skeleton>;
  35111. _layerMask: number;
  35112. _computeBonesUsingShaders: boolean;
  35113. _isActive: boolean;
  35114. _onlyForInstances: boolean;
  35115. _isActiveIntermediate: boolean;
  35116. _onlyForInstancesIntermediate: boolean;
  35117. _actAsRegularMesh: boolean;
  35118. _currentLOD: Nullable<AbstractMesh>;
  35119. _currentLODIsUpToDate: boolean;
  35120. }
  35121. /**
  35122. * Class used to store all common mesh properties
  35123. */
  35124. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35125. /** No occlusion */
  35126. static OCCLUSION_TYPE_NONE: number;
  35127. /** Occlusion set to optimisitic */
  35128. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35129. /** Occlusion set to strict */
  35130. static OCCLUSION_TYPE_STRICT: number;
  35131. /** Use an accurante occlusion algorithm */
  35132. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35133. /** Use a conservative occlusion algorithm */
  35134. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35135. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35136. * Test order :
  35137. * Is the bounding sphere outside the frustum ?
  35138. * If not, are the bounding box vertices outside the frustum ?
  35139. * It not, then the cullable object is in the frustum.
  35140. */
  35141. static readonly CULLINGSTRATEGY_STANDARD: number;
  35142. /** Culling strategy : Bounding Sphere Only.
  35143. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35144. * It's also less accurate than the standard because some not visible objects can still be selected.
  35145. * Test : is the bounding sphere outside the frustum ?
  35146. * If not, then the cullable object is in the frustum.
  35147. */
  35148. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35149. /** Culling strategy : Optimistic Inclusion.
  35150. * This in an inclusion test first, then the standard exclusion test.
  35151. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35152. * 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.
  35153. * Anyway, it's as accurate as the standard strategy.
  35154. * Test :
  35155. * Is the cullable object bounding sphere center in the frustum ?
  35156. * If not, apply the default culling strategy.
  35157. */
  35158. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35159. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35160. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35161. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35162. * 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.
  35163. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35164. * Test :
  35165. * Is the cullable object bounding sphere center in the frustum ?
  35166. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35167. */
  35168. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35169. /**
  35170. * No billboard
  35171. */
  35172. static get BILLBOARDMODE_NONE(): number;
  35173. /** Billboard on X axis */
  35174. static get BILLBOARDMODE_X(): number;
  35175. /** Billboard on Y axis */
  35176. static get BILLBOARDMODE_Y(): number;
  35177. /** Billboard on Z axis */
  35178. static get BILLBOARDMODE_Z(): number;
  35179. /** Billboard on all axes */
  35180. static get BILLBOARDMODE_ALL(): number;
  35181. /** Billboard on using position instead of orientation */
  35182. static get BILLBOARDMODE_USE_POSITION(): number;
  35183. /** @hidden */
  35184. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35185. /**
  35186. * The culling strategy to use to check whether the mesh must be rendered or not.
  35187. * This value can be changed at any time and will be used on the next render mesh selection.
  35188. * The possible values are :
  35189. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35190. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35191. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35192. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35193. * Please read each static variable documentation to get details about the culling process.
  35194. * */
  35195. cullingStrategy: number;
  35196. /**
  35197. * Gets the number of facets in the mesh
  35198. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35199. */
  35200. get facetNb(): number;
  35201. /**
  35202. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35204. */
  35205. get partitioningSubdivisions(): number;
  35206. set partitioningSubdivisions(nb: number);
  35207. /**
  35208. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35209. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35210. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35211. */
  35212. get partitioningBBoxRatio(): number;
  35213. set partitioningBBoxRatio(ratio: number);
  35214. /**
  35215. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35216. * Works only for updatable meshes.
  35217. * Doesn't work with multi-materials
  35218. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35219. */
  35220. get mustDepthSortFacets(): boolean;
  35221. set mustDepthSortFacets(sort: boolean);
  35222. /**
  35223. * The location (Vector3) where the facet depth sort must be computed from.
  35224. * By default, the active camera position.
  35225. * Used only when facet depth sort is enabled
  35226. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35227. */
  35228. get facetDepthSortFrom(): Vector3;
  35229. set facetDepthSortFrom(location: Vector3);
  35230. /**
  35231. * gets a boolean indicating if facetData is enabled
  35232. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35233. */
  35234. get isFacetDataEnabled(): boolean;
  35235. /** @hidden */
  35236. _updateNonUniformScalingState(value: boolean): boolean;
  35237. /**
  35238. * An event triggered when this mesh collides with another one
  35239. */
  35240. onCollideObservable: Observable<AbstractMesh>;
  35241. /** Set a function to call when this mesh collides with another one */
  35242. set onCollide(callback: () => void);
  35243. /**
  35244. * An event triggered when the collision's position changes
  35245. */
  35246. onCollisionPositionChangeObservable: Observable<Vector3>;
  35247. /** Set a function to call when the collision's position changes */
  35248. set onCollisionPositionChange(callback: () => void);
  35249. /**
  35250. * An event triggered when material is changed
  35251. */
  35252. onMaterialChangedObservable: Observable<AbstractMesh>;
  35253. /**
  35254. * Gets or sets the orientation for POV movement & rotation
  35255. */
  35256. definedFacingForward: boolean;
  35257. /** @hidden */
  35258. _occlusionQuery: Nullable<WebGLQuery>;
  35259. /** @hidden */
  35260. _renderingGroup: Nullable<RenderingGroup>;
  35261. /**
  35262. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35263. */
  35264. get visibility(): number;
  35265. /**
  35266. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35267. */
  35268. set visibility(value: number);
  35269. /** Gets or sets the alpha index used to sort transparent meshes
  35270. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35271. */
  35272. alphaIndex: number;
  35273. /**
  35274. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35275. */
  35276. isVisible: boolean;
  35277. /**
  35278. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35279. */
  35280. isPickable: boolean;
  35281. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35282. showSubMeshesBoundingBox: boolean;
  35283. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35284. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35285. */
  35286. isBlocker: boolean;
  35287. /**
  35288. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35289. */
  35290. enablePointerMoveEvents: boolean;
  35291. private _renderingGroupId;
  35292. /**
  35293. * Specifies the rendering group id for this mesh (0 by default)
  35294. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35295. */
  35296. get renderingGroupId(): number;
  35297. set renderingGroupId(value: number);
  35298. private _material;
  35299. /** Gets or sets current material */
  35300. get material(): Nullable<Material>;
  35301. set material(value: Nullable<Material>);
  35302. /**
  35303. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35304. * @see https://doc.babylonjs.com/babylon101/shadows
  35305. */
  35306. get receiveShadows(): boolean;
  35307. set receiveShadows(value: boolean);
  35308. /** Defines color to use when rendering outline */
  35309. outlineColor: Color3;
  35310. /** Define width to use when rendering outline */
  35311. outlineWidth: number;
  35312. /** Defines color to use when rendering overlay */
  35313. overlayColor: Color3;
  35314. /** Defines alpha to use when rendering overlay */
  35315. overlayAlpha: number;
  35316. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35317. get hasVertexAlpha(): boolean;
  35318. set hasVertexAlpha(value: boolean);
  35319. /** 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) */
  35320. get useVertexColors(): boolean;
  35321. set useVertexColors(value: boolean);
  35322. /**
  35323. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35324. */
  35325. get computeBonesUsingShaders(): boolean;
  35326. set computeBonesUsingShaders(value: boolean);
  35327. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35328. get numBoneInfluencers(): number;
  35329. set numBoneInfluencers(value: number);
  35330. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35331. get applyFog(): boolean;
  35332. set applyFog(value: boolean);
  35333. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35334. useOctreeForRenderingSelection: boolean;
  35335. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35336. useOctreeForPicking: boolean;
  35337. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35338. useOctreeForCollisions: boolean;
  35339. /**
  35340. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35341. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35342. */
  35343. get layerMask(): number;
  35344. set layerMask(value: number);
  35345. /**
  35346. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35347. */
  35348. alwaysSelectAsActiveMesh: boolean;
  35349. /**
  35350. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35351. */
  35352. doNotSyncBoundingInfo: boolean;
  35353. /**
  35354. * Gets or sets the current action manager
  35355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35356. */
  35357. actionManager: Nullable<AbstractActionManager>;
  35358. private _meshCollisionData;
  35359. /**
  35360. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35361. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35362. */
  35363. ellipsoid: Vector3;
  35364. /**
  35365. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35366. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35367. */
  35368. ellipsoidOffset: Vector3;
  35369. /**
  35370. * Gets or sets a collision mask used to mask collisions (default is -1).
  35371. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35372. */
  35373. get collisionMask(): number;
  35374. set collisionMask(mask: number);
  35375. /**
  35376. * Gets or sets a collision response flag (default is true).
  35377. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35378. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35379. * to respond to the collision.
  35380. */
  35381. get collisionResponse(): boolean;
  35382. set collisionResponse(response: boolean);
  35383. /**
  35384. * Gets or sets the current collision group mask (-1 by default).
  35385. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35386. */
  35387. get collisionGroup(): number;
  35388. set collisionGroup(mask: number);
  35389. /**
  35390. * Gets or sets current surrounding meshes (null by default).
  35391. *
  35392. * By default collision detection is tested against every mesh in the scene.
  35393. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35394. * meshes will be tested for the collision.
  35395. *
  35396. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35397. */
  35398. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35399. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35400. /**
  35401. * Defines edge width used when edgesRenderer is enabled
  35402. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35403. */
  35404. edgesWidth: number;
  35405. /**
  35406. * Defines edge color used when edgesRenderer is enabled
  35407. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35408. */
  35409. edgesColor: Color4;
  35410. /** @hidden */
  35411. _edgesRenderer: Nullable<IEdgesRenderer>;
  35412. /** @hidden */
  35413. _masterMesh: Nullable<AbstractMesh>;
  35414. /** @hidden */
  35415. _boundingInfo: Nullable<BoundingInfo>;
  35416. /** @hidden */
  35417. _renderId: number;
  35418. /**
  35419. * Gets or sets the list of subMeshes
  35420. * @see https://doc.babylonjs.com/how_to/multi_materials
  35421. */
  35422. subMeshes: SubMesh[];
  35423. /** @hidden */
  35424. _intersectionsInProgress: AbstractMesh[];
  35425. /** @hidden */
  35426. _unIndexed: boolean;
  35427. /** @hidden */
  35428. _lightSources: Light[];
  35429. /** Gets the list of lights affecting that mesh */
  35430. get lightSources(): Light[];
  35431. /** @hidden */
  35432. get _positions(): Nullable<Vector3[]>;
  35433. /** @hidden */
  35434. _waitingData: {
  35435. lods: Nullable<any>;
  35436. actions: Nullable<any>;
  35437. freezeWorldMatrix: Nullable<boolean>;
  35438. };
  35439. /** @hidden */
  35440. _bonesTransformMatrices: Nullable<Float32Array>;
  35441. /** @hidden */
  35442. _transformMatrixTexture: Nullable<RawTexture>;
  35443. /**
  35444. * Gets or sets a skeleton to apply skining transformations
  35445. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35446. */
  35447. set skeleton(value: Nullable<Skeleton>);
  35448. get skeleton(): Nullable<Skeleton>;
  35449. /**
  35450. * An event triggered when the mesh is rebuilt.
  35451. */
  35452. onRebuildObservable: Observable<AbstractMesh>;
  35453. /**
  35454. * Creates a new AbstractMesh
  35455. * @param name defines the name of the mesh
  35456. * @param scene defines the hosting scene
  35457. */
  35458. constructor(name: string, scene?: Nullable<Scene>);
  35459. /**
  35460. * Returns the string "AbstractMesh"
  35461. * @returns "AbstractMesh"
  35462. */
  35463. getClassName(): string;
  35464. /**
  35465. * Gets a string representation of the current mesh
  35466. * @param fullDetails defines a boolean indicating if full details must be included
  35467. * @returns a string representation of the current mesh
  35468. */
  35469. toString(fullDetails?: boolean): string;
  35470. /**
  35471. * @hidden
  35472. */
  35473. protected _getEffectiveParent(): Nullable<Node>;
  35474. /** @hidden */
  35475. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35476. /** @hidden */
  35477. _rebuild(): void;
  35478. /** @hidden */
  35479. _resyncLightSources(): void;
  35480. /** @hidden */
  35481. _resyncLightSource(light: Light): void;
  35482. /** @hidden */
  35483. _unBindEffect(): void;
  35484. /** @hidden */
  35485. _removeLightSource(light: Light, dispose: boolean): void;
  35486. private _markSubMeshesAsDirty;
  35487. /** @hidden */
  35488. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35489. /** @hidden */
  35490. _markSubMeshesAsAttributesDirty(): void;
  35491. /** @hidden */
  35492. _markSubMeshesAsMiscDirty(): void;
  35493. /**
  35494. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35495. */
  35496. get scaling(): Vector3;
  35497. set scaling(newScaling: Vector3);
  35498. /**
  35499. * Returns true if the mesh is blocked. Implemented by child classes
  35500. */
  35501. get isBlocked(): boolean;
  35502. /**
  35503. * Returns the mesh itself by default. Implemented by child classes
  35504. * @param camera defines the camera to use to pick the right LOD level
  35505. * @returns the currentAbstractMesh
  35506. */
  35507. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35508. /**
  35509. * Returns 0 by default. Implemented by child classes
  35510. * @returns an integer
  35511. */
  35512. getTotalVertices(): number;
  35513. /**
  35514. * Returns a positive integer : the total number of indices in this mesh geometry.
  35515. * @returns the numner of indices or zero if the mesh has no geometry.
  35516. */
  35517. getTotalIndices(): number;
  35518. /**
  35519. * Returns null by default. Implemented by child classes
  35520. * @returns null
  35521. */
  35522. getIndices(): Nullable<IndicesArray>;
  35523. /**
  35524. * Returns the array of the requested vertex data kind. Implemented by child classes
  35525. * @param kind defines the vertex data kind to use
  35526. * @returns null
  35527. */
  35528. getVerticesData(kind: string): Nullable<FloatArray>;
  35529. /**
  35530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35532. * Note that a new underlying VertexBuffer object is created each call.
  35533. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35534. * @param kind defines vertex data kind:
  35535. * * VertexBuffer.PositionKind
  35536. * * VertexBuffer.UVKind
  35537. * * VertexBuffer.UV2Kind
  35538. * * VertexBuffer.UV3Kind
  35539. * * VertexBuffer.UV4Kind
  35540. * * VertexBuffer.UV5Kind
  35541. * * VertexBuffer.UV6Kind
  35542. * * VertexBuffer.ColorKind
  35543. * * VertexBuffer.MatricesIndicesKind
  35544. * * VertexBuffer.MatricesIndicesExtraKind
  35545. * * VertexBuffer.MatricesWeightsKind
  35546. * * VertexBuffer.MatricesWeightsExtraKind
  35547. * @param data defines the data source
  35548. * @param updatable defines if the data must be flagged as updatable (or static)
  35549. * @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
  35550. * @returns the current mesh
  35551. */
  35552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35553. /**
  35554. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35555. * If the mesh has no geometry, it is simply returned as it is.
  35556. * @param kind defines vertex data kind:
  35557. * * VertexBuffer.PositionKind
  35558. * * VertexBuffer.UVKind
  35559. * * VertexBuffer.UV2Kind
  35560. * * VertexBuffer.UV3Kind
  35561. * * VertexBuffer.UV4Kind
  35562. * * VertexBuffer.UV5Kind
  35563. * * VertexBuffer.UV6Kind
  35564. * * VertexBuffer.ColorKind
  35565. * * VertexBuffer.MatricesIndicesKind
  35566. * * VertexBuffer.MatricesIndicesExtraKind
  35567. * * VertexBuffer.MatricesWeightsKind
  35568. * * VertexBuffer.MatricesWeightsExtraKind
  35569. * @param data defines the data source
  35570. * @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
  35571. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35572. * @returns the current mesh
  35573. */
  35574. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35575. /**
  35576. * Sets the mesh indices,
  35577. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35578. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35579. * @param totalVertices Defines the total number of vertices
  35580. * @returns the current mesh
  35581. */
  35582. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35583. /**
  35584. * Gets a boolean indicating if specific vertex data is present
  35585. * @param kind defines the vertex data kind to use
  35586. * @returns true is data kind is present
  35587. */
  35588. isVerticesDataPresent(kind: string): boolean;
  35589. /**
  35590. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35591. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35592. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35593. * @returns a BoundingInfo
  35594. */
  35595. getBoundingInfo(): BoundingInfo;
  35596. /**
  35597. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35598. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35599. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35600. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35601. * @returns the current mesh
  35602. */
  35603. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35604. /**
  35605. * Overwrite the current bounding info
  35606. * @param boundingInfo defines the new bounding info
  35607. * @returns the current mesh
  35608. */
  35609. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35610. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35611. get useBones(): boolean;
  35612. /** @hidden */
  35613. _preActivate(): void;
  35614. /** @hidden */
  35615. _preActivateForIntermediateRendering(renderId: number): void;
  35616. /** @hidden */
  35617. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35618. /** @hidden */
  35619. _postActivate(): void;
  35620. /** @hidden */
  35621. _freeze(): void;
  35622. /** @hidden */
  35623. _unFreeze(): void;
  35624. /**
  35625. * Gets the current world matrix
  35626. * @returns a Matrix
  35627. */
  35628. getWorldMatrix(): Matrix;
  35629. /** @hidden */
  35630. _getWorldMatrixDeterminant(): number;
  35631. /**
  35632. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35633. */
  35634. get isAnInstance(): boolean;
  35635. /**
  35636. * Gets a boolean indicating if this mesh has instances
  35637. */
  35638. get hasInstances(): boolean;
  35639. /**
  35640. * Gets a boolean indicating if this mesh has thin instances
  35641. */
  35642. get hasThinInstances(): boolean;
  35643. /**
  35644. * Perform relative position change from the point of view of behind the front of the mesh.
  35645. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35646. * Supports definition of mesh facing forward or backward
  35647. * @param amountRight defines the distance on the right axis
  35648. * @param amountUp defines the distance on the up axis
  35649. * @param amountForward defines the distance on the forward axis
  35650. * @returns the current mesh
  35651. */
  35652. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35653. /**
  35654. * Calculate relative position change from the point of view of behind the front of the mesh.
  35655. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35656. * Supports definition of mesh facing forward or backward
  35657. * @param amountRight defines the distance on the right axis
  35658. * @param amountUp defines the distance on the up axis
  35659. * @param amountForward defines the distance on the forward axis
  35660. * @returns the new displacement vector
  35661. */
  35662. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35663. /**
  35664. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35665. * Supports definition of mesh facing forward or backward
  35666. * @param flipBack defines the flip
  35667. * @param twirlClockwise defines the twirl
  35668. * @param tiltRight defines the tilt
  35669. * @returns the current mesh
  35670. */
  35671. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35672. /**
  35673. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35674. * Supports definition of mesh facing forward or backward.
  35675. * @param flipBack defines the flip
  35676. * @param twirlClockwise defines the twirl
  35677. * @param tiltRight defines the tilt
  35678. * @returns the new rotation vector
  35679. */
  35680. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35681. /**
  35682. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35683. * This means the mesh underlying bounding box and sphere are recomputed.
  35684. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35685. * @returns the current mesh
  35686. */
  35687. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35688. /** @hidden */
  35689. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35690. /** @hidden */
  35691. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35692. /** @hidden */
  35693. _updateBoundingInfo(): AbstractMesh;
  35694. /** @hidden */
  35695. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35696. /** @hidden */
  35697. protected _afterComputeWorldMatrix(): void;
  35698. /** @hidden */
  35699. get _effectiveMesh(): AbstractMesh;
  35700. /**
  35701. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35702. * A mesh is in the frustum if its bounding box intersects the frustum
  35703. * @param frustumPlanes defines the frustum to test
  35704. * @returns true if the mesh is in the frustum planes
  35705. */
  35706. isInFrustum(frustumPlanes: Plane[]): boolean;
  35707. /**
  35708. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35709. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35710. * @param frustumPlanes defines the frustum to test
  35711. * @returns true if the mesh is completely in the frustum planes
  35712. */
  35713. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35714. /**
  35715. * True if the mesh intersects another mesh or a SolidParticle object
  35716. * @param mesh defines a target mesh or SolidParticle to test
  35717. * @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)
  35718. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35719. * @returns true if there is an intersection
  35720. */
  35721. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35722. /**
  35723. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35724. * @param point defines the point to test
  35725. * @returns true if there is an intersection
  35726. */
  35727. intersectsPoint(point: Vector3): boolean;
  35728. /**
  35729. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35730. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35731. */
  35732. get checkCollisions(): boolean;
  35733. set checkCollisions(collisionEnabled: boolean);
  35734. /**
  35735. * Gets Collider object used to compute collisions (not physics)
  35736. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35737. */
  35738. get collider(): Nullable<Collider>;
  35739. /**
  35740. * Move the mesh using collision engine
  35741. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35742. * @param displacement defines the requested displacement vector
  35743. * @returns the current mesh
  35744. */
  35745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35746. private _onCollisionPositionChange;
  35747. /** @hidden */
  35748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35749. /** @hidden */
  35750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35751. /** @hidden */
  35752. _checkCollision(collider: Collider): AbstractMesh;
  35753. /** @hidden */
  35754. _generatePointsArray(): boolean;
  35755. /**
  35756. * Checks if the passed Ray intersects with the mesh
  35757. * @param ray defines the ray to use
  35758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35760. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35761. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35762. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35763. * @returns the picking info
  35764. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35765. */
  35766. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35767. /**
  35768. * Clones the current mesh
  35769. * @param name defines the mesh name
  35770. * @param newParent defines the new mesh parent
  35771. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35772. * @returns the new mesh
  35773. */
  35774. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35775. /**
  35776. * Disposes all the submeshes of the current meshnp
  35777. * @returns the current mesh
  35778. */
  35779. releaseSubMeshes(): AbstractMesh;
  35780. /**
  35781. * Releases resources associated with this abstract mesh.
  35782. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35783. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35784. */
  35785. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35786. /**
  35787. * Adds the passed mesh as a child to the current mesh
  35788. * @param mesh defines the child mesh
  35789. * @returns the current mesh
  35790. */
  35791. addChild(mesh: AbstractMesh): AbstractMesh;
  35792. /**
  35793. * Removes the passed mesh from the current mesh children list
  35794. * @param mesh defines the child mesh
  35795. * @returns the current mesh
  35796. */
  35797. removeChild(mesh: AbstractMesh): AbstractMesh;
  35798. /** @hidden */
  35799. private _initFacetData;
  35800. /**
  35801. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35802. * This method can be called within the render loop.
  35803. * 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
  35804. * @returns the current mesh
  35805. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35806. */
  35807. updateFacetData(): AbstractMesh;
  35808. /**
  35809. * Returns the facetLocalNormals array.
  35810. * The normals are expressed in the mesh local spac
  35811. * @returns an array of Vector3
  35812. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35813. */
  35814. getFacetLocalNormals(): Vector3[];
  35815. /**
  35816. * Returns the facetLocalPositions array.
  35817. * The facet positions are expressed in the mesh local space
  35818. * @returns an array of Vector3
  35819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35820. */
  35821. getFacetLocalPositions(): Vector3[];
  35822. /**
  35823. * Returns the facetLocalPartioning array
  35824. * @returns an array of array of numbers
  35825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35826. */
  35827. getFacetLocalPartitioning(): number[][];
  35828. /**
  35829. * Returns the i-th facet position in the world system.
  35830. * This method allocates a new Vector3 per call
  35831. * @param i defines the facet index
  35832. * @returns a new Vector3
  35833. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35834. */
  35835. getFacetPosition(i: number): Vector3;
  35836. /**
  35837. * Sets the reference Vector3 with the i-th facet position in the world system
  35838. * @param i defines the facet index
  35839. * @param ref defines the target vector
  35840. * @returns the current mesh
  35841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35842. */
  35843. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35844. /**
  35845. * Returns the i-th facet normal in the world system.
  35846. * This method allocates a new Vector3 per call
  35847. * @param i defines the facet index
  35848. * @returns a new Vector3
  35849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35850. */
  35851. getFacetNormal(i: number): Vector3;
  35852. /**
  35853. * Sets the reference Vector3 with the i-th facet normal in the world system
  35854. * @param i defines the facet index
  35855. * @param ref defines the target vector
  35856. * @returns the current mesh
  35857. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35858. */
  35859. getFacetNormalToRef(i: number, ref: Vector3): this;
  35860. /**
  35861. * 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)
  35862. * @param x defines x coordinate
  35863. * @param y defines y coordinate
  35864. * @param z defines z coordinate
  35865. * @returns the array of facet indexes
  35866. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35867. */
  35868. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35869. /**
  35870. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35871. * @param projected sets as the (x,y,z) world projection on the facet
  35872. * @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
  35873. * @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
  35874. * @param x defines x coordinate
  35875. * @param y defines y coordinate
  35876. * @param z defines z coordinate
  35877. * @returns the face index if found (or null instead)
  35878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35879. */
  35880. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35881. /**
  35882. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35883. * @param projected sets as the (x,y,z) local projection on the facet
  35884. * @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
  35885. * @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
  35886. * @param x defines x coordinate
  35887. * @param y defines y coordinate
  35888. * @param z defines z coordinate
  35889. * @returns the face index if found (or null instead)
  35890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35891. */
  35892. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35893. /**
  35894. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35895. * @returns the parameters
  35896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35897. */
  35898. getFacetDataParameters(): any;
  35899. /**
  35900. * Disables the feature FacetData and frees the related memory
  35901. * @returns the current mesh
  35902. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35903. */
  35904. disableFacetData(): AbstractMesh;
  35905. /**
  35906. * Updates the AbstractMesh indices array
  35907. * @param indices defines the data source
  35908. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35909. * @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)
  35910. * @returns the current mesh
  35911. */
  35912. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35913. /**
  35914. * Creates new normals data for the mesh
  35915. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35916. * @returns the current mesh
  35917. */
  35918. createNormals(updatable: boolean): AbstractMesh;
  35919. /**
  35920. * Align the mesh with a normal
  35921. * @param normal defines the normal to use
  35922. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35923. * @returns the current mesh
  35924. */
  35925. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35926. /** @hidden */
  35927. _checkOcclusionQuery(): boolean;
  35928. /**
  35929. * Disables the mesh edge rendering mode
  35930. * @returns the currentAbstractMesh
  35931. */
  35932. disableEdgesRendering(): AbstractMesh;
  35933. /**
  35934. * Enables the edge rendering mode on the mesh.
  35935. * This mode makes the mesh edges visible
  35936. * @param epsilon defines the maximal distance between two angles to detect a face
  35937. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35938. * @param options options to the edge renderer
  35939. * @returns the currentAbstractMesh
  35940. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35941. */
  35942. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35943. /**
  35944. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35945. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35946. */
  35947. getConnectedParticleSystems(): IParticleSystem[];
  35948. }
  35949. }
  35950. declare module BABYLON {
  35951. /**
  35952. * Interface used to define ActionEvent
  35953. */
  35954. export interface IActionEvent {
  35955. /** The mesh or sprite that triggered the action */
  35956. source: any;
  35957. /** The X mouse cursor position at the time of the event */
  35958. pointerX: number;
  35959. /** The Y mouse cursor position at the time of the event */
  35960. pointerY: number;
  35961. /** The mesh that is currently pointed at (can be null) */
  35962. meshUnderPointer: Nullable<AbstractMesh>;
  35963. /** the original (browser) event that triggered the ActionEvent */
  35964. sourceEvent?: any;
  35965. /** additional data for the event */
  35966. additionalData?: any;
  35967. }
  35968. /**
  35969. * ActionEvent is the event being sent when an action is triggered.
  35970. */
  35971. export class ActionEvent implements IActionEvent {
  35972. /** The mesh or sprite that triggered the action */
  35973. source: any;
  35974. /** The X mouse cursor position at the time of the event */
  35975. pointerX: number;
  35976. /** The Y mouse cursor position at the time of the event */
  35977. pointerY: number;
  35978. /** The mesh that is currently pointed at (can be null) */
  35979. meshUnderPointer: Nullable<AbstractMesh>;
  35980. /** the original (browser) event that triggered the ActionEvent */
  35981. sourceEvent?: any;
  35982. /** additional data for the event */
  35983. additionalData?: any;
  35984. /**
  35985. * Creates a new ActionEvent
  35986. * @param source The mesh or sprite that triggered the action
  35987. * @param pointerX The X mouse cursor position at the time of the event
  35988. * @param pointerY The Y mouse cursor position at the time of the event
  35989. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35990. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35991. * @param additionalData additional data for the event
  35992. */
  35993. constructor(
  35994. /** The mesh or sprite that triggered the action */
  35995. source: any,
  35996. /** The X mouse cursor position at the time of the event */
  35997. pointerX: number,
  35998. /** The Y mouse cursor position at the time of the event */
  35999. pointerY: number,
  36000. /** The mesh that is currently pointed at (can be null) */
  36001. meshUnderPointer: Nullable<AbstractMesh>,
  36002. /** the original (browser) event that triggered the ActionEvent */
  36003. sourceEvent?: any,
  36004. /** additional data for the event */
  36005. additionalData?: any);
  36006. /**
  36007. * Helper function to auto-create an ActionEvent from a source mesh.
  36008. * @param source The source mesh that triggered the event
  36009. * @param evt The original (browser) event
  36010. * @param additionalData additional data for the event
  36011. * @returns the new ActionEvent
  36012. */
  36013. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36014. /**
  36015. * Helper function to auto-create an ActionEvent from a source sprite
  36016. * @param source The source sprite that triggered the event
  36017. * @param scene Scene associated with the sprite
  36018. * @param evt The original (browser) event
  36019. * @param additionalData additional data for the event
  36020. * @returns the new ActionEvent
  36021. */
  36022. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36023. /**
  36024. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36025. * @param scene the scene where the event occurred
  36026. * @param evt The original (browser) event
  36027. * @returns the new ActionEvent
  36028. */
  36029. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36030. /**
  36031. * Helper function to auto-create an ActionEvent from a primitive
  36032. * @param prim defines the target primitive
  36033. * @param pointerPos defines the pointer position
  36034. * @param evt The original (browser) event
  36035. * @param additionalData additional data for the event
  36036. * @returns the new ActionEvent
  36037. */
  36038. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36039. }
  36040. }
  36041. declare module BABYLON {
  36042. /**
  36043. * Abstract class used to decouple action Manager from scene and meshes.
  36044. * Do not instantiate.
  36045. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36046. */
  36047. export abstract class AbstractActionManager implements IDisposable {
  36048. /** Gets the list of active triggers */
  36049. static Triggers: {
  36050. [key: string]: number;
  36051. };
  36052. /** Gets the cursor to use when hovering items */
  36053. hoverCursor: string;
  36054. /** Gets the list of actions */
  36055. actions: IAction[];
  36056. /**
  36057. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36058. */
  36059. isRecursive: boolean;
  36060. /**
  36061. * Releases all associated resources
  36062. */
  36063. abstract dispose(): void;
  36064. /**
  36065. * Does this action manager has pointer triggers
  36066. */
  36067. abstract get hasPointerTriggers(): boolean;
  36068. /**
  36069. * Does this action manager has pick triggers
  36070. */
  36071. abstract get hasPickTriggers(): boolean;
  36072. /**
  36073. * Process a specific trigger
  36074. * @param trigger defines the trigger to process
  36075. * @param evt defines the event details to be processed
  36076. */
  36077. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36078. /**
  36079. * Does this action manager handles actions of any of the given triggers
  36080. * @param triggers defines the triggers to be tested
  36081. * @return a boolean indicating whether one (or more) of the triggers is handled
  36082. */
  36083. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36084. /**
  36085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36086. * speed.
  36087. * @param triggerA defines the trigger to be tested
  36088. * @param triggerB defines the trigger to be tested
  36089. * @return a boolean indicating whether one (or more) of the triggers is handled
  36090. */
  36091. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36092. /**
  36093. * Does this action manager handles actions of a given trigger
  36094. * @param trigger defines the trigger to be tested
  36095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36096. * @return whether the trigger is handled
  36097. */
  36098. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36099. /**
  36100. * Serialize this manager to a JSON object
  36101. * @param name defines the property name to store this manager
  36102. * @returns a JSON representation of this manager
  36103. */
  36104. abstract serialize(name: string): any;
  36105. /**
  36106. * Registers an action to this action manager
  36107. * @param action defines the action to be registered
  36108. * @return the action amended (prepared) after registration
  36109. */
  36110. abstract registerAction(action: IAction): Nullable<IAction>;
  36111. /**
  36112. * Unregisters an action to this action manager
  36113. * @param action defines the action to be unregistered
  36114. * @return a boolean indicating whether the action has been unregistered
  36115. */
  36116. abstract unregisterAction(action: IAction): Boolean;
  36117. /**
  36118. * Does exist one action manager with at least one trigger
  36119. **/
  36120. static get HasTriggers(): boolean;
  36121. /**
  36122. * Does exist one action manager with at least one pick trigger
  36123. **/
  36124. static get HasPickTriggers(): boolean;
  36125. /**
  36126. * Does exist one action manager that handles actions of a given trigger
  36127. * @param trigger defines the trigger to be tested
  36128. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36129. **/
  36130. static HasSpecificTrigger(trigger: number): boolean;
  36131. }
  36132. }
  36133. declare module BABYLON {
  36134. /**
  36135. * Defines how a node can be built from a string name.
  36136. */
  36137. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36138. /**
  36139. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36140. */
  36141. export class Node implements IBehaviorAware<Node> {
  36142. /** @hidden */
  36143. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36144. private static _NodeConstructors;
  36145. /**
  36146. * Add a new node constructor
  36147. * @param type defines the type name of the node to construct
  36148. * @param constructorFunc defines the constructor function
  36149. */
  36150. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36151. /**
  36152. * Returns a node constructor based on type name
  36153. * @param type defines the type name
  36154. * @param name defines the new node name
  36155. * @param scene defines the hosting scene
  36156. * @param options defines optional options to transmit to constructors
  36157. * @returns the new constructor or null
  36158. */
  36159. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36160. /**
  36161. * Gets or sets the name of the node
  36162. */
  36163. name: string;
  36164. /**
  36165. * Gets or sets the id of the node
  36166. */
  36167. id: string;
  36168. /**
  36169. * Gets or sets the unique id of the node
  36170. */
  36171. uniqueId: number;
  36172. /**
  36173. * Gets or sets a string used to store user defined state for the node
  36174. */
  36175. state: string;
  36176. /**
  36177. * Gets or sets an object used to store user defined information for the node
  36178. */
  36179. metadata: any;
  36180. /**
  36181. * For internal use only. Please do not use.
  36182. */
  36183. reservedDataStore: any;
  36184. /**
  36185. * List of inspectable custom properties (used by the Inspector)
  36186. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36187. */
  36188. inspectableCustomProperties: IInspectable[];
  36189. private _doNotSerialize;
  36190. /**
  36191. * Gets or sets a boolean used to define if the node must be serialized
  36192. */
  36193. get doNotSerialize(): boolean;
  36194. set doNotSerialize(value: boolean);
  36195. /** @hidden */
  36196. _isDisposed: boolean;
  36197. /**
  36198. * Gets a list of Animations associated with the node
  36199. */
  36200. animations: Animation[];
  36201. protected _ranges: {
  36202. [name: string]: Nullable<AnimationRange>;
  36203. };
  36204. /**
  36205. * Callback raised when the node is ready to be used
  36206. */
  36207. onReady: Nullable<(node: Node) => void>;
  36208. private _isEnabled;
  36209. private _isParentEnabled;
  36210. private _isReady;
  36211. /** @hidden */
  36212. _currentRenderId: number;
  36213. private _parentUpdateId;
  36214. /** @hidden */
  36215. _childUpdateId: number;
  36216. /** @hidden */
  36217. _waitingParentId: Nullable<string>;
  36218. /** @hidden */
  36219. _scene: Scene;
  36220. /** @hidden */
  36221. _cache: any;
  36222. private _parentNode;
  36223. private _children;
  36224. /** @hidden */
  36225. _worldMatrix: Matrix;
  36226. /** @hidden */
  36227. _worldMatrixDeterminant: number;
  36228. /** @hidden */
  36229. _worldMatrixDeterminantIsDirty: boolean;
  36230. /** @hidden */
  36231. private _sceneRootNodesIndex;
  36232. /**
  36233. * Gets a boolean indicating if the node has been disposed
  36234. * @returns true if the node was disposed
  36235. */
  36236. isDisposed(): boolean;
  36237. /**
  36238. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36239. * @see https://doc.babylonjs.com/how_to/parenting
  36240. */
  36241. set parent(parent: Nullable<Node>);
  36242. get parent(): Nullable<Node>;
  36243. /** @hidden */
  36244. _addToSceneRootNodes(): void;
  36245. /** @hidden */
  36246. _removeFromSceneRootNodes(): void;
  36247. private _animationPropertiesOverride;
  36248. /**
  36249. * Gets or sets the animation properties override
  36250. */
  36251. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36252. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36253. /**
  36254. * Gets a string identifying the name of the class
  36255. * @returns "Node" string
  36256. */
  36257. getClassName(): string;
  36258. /** @hidden */
  36259. readonly _isNode: boolean;
  36260. /**
  36261. * An event triggered when the mesh is disposed
  36262. */
  36263. onDisposeObservable: Observable<Node>;
  36264. private _onDisposeObserver;
  36265. /**
  36266. * Sets a callback that will be raised when the node will be disposed
  36267. */
  36268. set onDispose(callback: () => void);
  36269. /**
  36270. * Creates a new Node
  36271. * @param name the name and id to be given to this node
  36272. * @param scene the scene this node will be added to
  36273. */
  36274. constructor(name: string, scene?: Nullable<Scene>);
  36275. /**
  36276. * Gets the scene of the node
  36277. * @returns a scene
  36278. */
  36279. getScene(): Scene;
  36280. /**
  36281. * Gets the engine of the node
  36282. * @returns a Engine
  36283. */
  36284. getEngine(): Engine;
  36285. private _behaviors;
  36286. /**
  36287. * Attach a behavior to the node
  36288. * @see https://doc.babylonjs.com/features/behaviour
  36289. * @param behavior defines the behavior to attach
  36290. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36291. * @returns the current Node
  36292. */
  36293. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36294. /**
  36295. * Remove an attached behavior
  36296. * @see https://doc.babylonjs.com/features/behaviour
  36297. * @param behavior defines the behavior to attach
  36298. * @returns the current Node
  36299. */
  36300. removeBehavior(behavior: Behavior<Node>): Node;
  36301. /**
  36302. * Gets the list of attached behaviors
  36303. * @see https://doc.babylonjs.com/features/behaviour
  36304. */
  36305. get behaviors(): Behavior<Node>[];
  36306. /**
  36307. * Gets an attached behavior by name
  36308. * @param name defines the name of the behavior to look for
  36309. * @see https://doc.babylonjs.com/features/behaviour
  36310. * @returns null if behavior was not found else the requested behavior
  36311. */
  36312. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36313. /**
  36314. * Returns the latest update of the World matrix
  36315. * @returns a Matrix
  36316. */
  36317. getWorldMatrix(): Matrix;
  36318. /** @hidden */
  36319. _getWorldMatrixDeterminant(): number;
  36320. /**
  36321. * Returns directly the latest state of the mesh World matrix.
  36322. * A Matrix is returned.
  36323. */
  36324. get worldMatrixFromCache(): Matrix;
  36325. /** @hidden */
  36326. _initCache(): void;
  36327. /** @hidden */
  36328. updateCache(force?: boolean): void;
  36329. /** @hidden */
  36330. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36331. /** @hidden */
  36332. _updateCache(ignoreParentClass?: boolean): void;
  36333. /** @hidden */
  36334. _isSynchronized(): boolean;
  36335. /** @hidden */
  36336. _markSyncedWithParent(): void;
  36337. /** @hidden */
  36338. isSynchronizedWithParent(): boolean;
  36339. /** @hidden */
  36340. isSynchronized(): boolean;
  36341. /**
  36342. * Is this node ready to be used/rendered
  36343. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36344. * @return true if the node is ready
  36345. */
  36346. isReady(completeCheck?: boolean): boolean;
  36347. /**
  36348. * Is this node enabled?
  36349. * 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
  36350. * @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
  36351. * @return whether this node (and its parent) is enabled
  36352. */
  36353. isEnabled(checkAncestors?: boolean): boolean;
  36354. /** @hidden */
  36355. protected _syncParentEnabledState(): void;
  36356. /**
  36357. * Set the enabled state of this node
  36358. * @param value defines the new enabled state
  36359. */
  36360. setEnabled(value: boolean): void;
  36361. /**
  36362. * Is this node a descendant of the given node?
  36363. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36364. * @param ancestor defines the parent node to inspect
  36365. * @returns a boolean indicating if this node is a descendant of the given node
  36366. */
  36367. isDescendantOf(ancestor: Node): boolean;
  36368. /** @hidden */
  36369. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36370. /**
  36371. * Will return all nodes that have this node as ascendant
  36372. * @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
  36373. * @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
  36374. * @return all children nodes of all types
  36375. */
  36376. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36377. /**
  36378. * Get all child-meshes of this node
  36379. * @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)
  36380. * @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
  36381. * @returns an array of AbstractMesh
  36382. */
  36383. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36384. /**
  36385. * Get all direct children of this node
  36386. * @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
  36387. * @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)
  36388. * @returns an array of Node
  36389. */
  36390. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36391. /** @hidden */
  36392. _setReady(state: boolean): void;
  36393. /**
  36394. * Get an animation by name
  36395. * @param name defines the name of the animation to look for
  36396. * @returns null if not found else the requested animation
  36397. */
  36398. getAnimationByName(name: string): Nullable<Animation>;
  36399. /**
  36400. * Creates an animation range for this node
  36401. * @param name defines the name of the range
  36402. * @param from defines the starting key
  36403. * @param to defines the end key
  36404. */
  36405. createAnimationRange(name: string, from: number, to: number): void;
  36406. /**
  36407. * Delete a specific animation range
  36408. * @param name defines the name of the range to delete
  36409. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36410. */
  36411. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36412. /**
  36413. * Get an animation range by name
  36414. * @param name defines the name of the animation range to look for
  36415. * @returns null if not found else the requested animation range
  36416. */
  36417. getAnimationRange(name: string): Nullable<AnimationRange>;
  36418. /**
  36419. * Gets the list of all animation ranges defined on this node
  36420. * @returns an array
  36421. */
  36422. getAnimationRanges(): Nullable<AnimationRange>[];
  36423. /**
  36424. * Will start the animation sequence
  36425. * @param name defines the range frames for animation sequence
  36426. * @param loop defines if the animation should loop (false by default)
  36427. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36428. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36429. * @returns the object created for this animation. If range does not exist, it will return null
  36430. */
  36431. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36432. /**
  36433. * Serialize animation ranges into a JSON compatible object
  36434. * @returns serialization object
  36435. */
  36436. serializeAnimationRanges(): any;
  36437. /**
  36438. * Computes the world matrix of the node
  36439. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36440. * @returns the world matrix
  36441. */
  36442. computeWorldMatrix(force?: boolean): Matrix;
  36443. /**
  36444. * Releases resources associated with this node.
  36445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36447. */
  36448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36449. /**
  36450. * Parse animation range data from a serialization object and store them into a given node
  36451. * @param node defines where to store the animation ranges
  36452. * @param parsedNode defines the serialization object to read data from
  36453. * @param scene defines the hosting scene
  36454. */
  36455. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36456. /**
  36457. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36458. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36459. * @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
  36460. * @returns the new bounding vectors
  36461. */
  36462. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36463. min: Vector3;
  36464. max: Vector3;
  36465. };
  36466. }
  36467. }
  36468. declare module BABYLON {
  36469. /**
  36470. * @hidden
  36471. */
  36472. export class _IAnimationState {
  36473. key: number;
  36474. repeatCount: number;
  36475. workValue?: any;
  36476. loopMode?: number;
  36477. offsetValue?: any;
  36478. highLimitValue?: any;
  36479. }
  36480. /**
  36481. * Class used to store any kind of animation
  36482. */
  36483. export class Animation {
  36484. /**Name of the animation */
  36485. name: string;
  36486. /**Property to animate */
  36487. targetProperty: string;
  36488. /**The frames per second of the animation */
  36489. framePerSecond: number;
  36490. /**The data type of the animation */
  36491. dataType: number;
  36492. /**The loop mode of the animation */
  36493. loopMode?: number | undefined;
  36494. /**Specifies if blending should be enabled */
  36495. enableBlending?: boolean | undefined;
  36496. /**
  36497. * Use matrix interpolation instead of using direct key value when animating matrices
  36498. */
  36499. static AllowMatricesInterpolation: boolean;
  36500. /**
  36501. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36502. */
  36503. static AllowMatrixDecomposeForInterpolation: boolean;
  36504. /** Define the Url to load snippets */
  36505. static SnippetUrl: string;
  36506. /** Snippet ID if the animation was created from the snippet server */
  36507. snippetId: string;
  36508. /**
  36509. * Stores the key frames of the animation
  36510. */
  36511. private _keys;
  36512. /**
  36513. * Stores the easing function of the animation
  36514. */
  36515. private _easingFunction;
  36516. /**
  36517. * @hidden Internal use only
  36518. */
  36519. _runtimeAnimations: RuntimeAnimation[];
  36520. /**
  36521. * The set of event that will be linked to this animation
  36522. */
  36523. private _events;
  36524. /**
  36525. * Stores an array of target property paths
  36526. */
  36527. targetPropertyPath: string[];
  36528. /**
  36529. * Stores the blending speed of the animation
  36530. */
  36531. blendingSpeed: number;
  36532. /**
  36533. * Stores the animation ranges for the animation
  36534. */
  36535. private _ranges;
  36536. /**
  36537. * @hidden Internal use
  36538. */
  36539. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36540. /**
  36541. * Sets up an animation
  36542. * @param property The property to animate
  36543. * @param animationType The animation type to apply
  36544. * @param framePerSecond The frames per second of the animation
  36545. * @param easingFunction The easing function used in the animation
  36546. * @returns The created animation
  36547. */
  36548. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36549. /**
  36550. * Create and start an animation on a node
  36551. * @param name defines the name of the global animation that will be run on all nodes
  36552. * @param node defines the root node where the animation will take place
  36553. * @param targetProperty defines property to animate
  36554. * @param framePerSecond defines the number of frame per second yo use
  36555. * @param totalFrame defines the number of frames in total
  36556. * @param from defines the initial value
  36557. * @param to defines the final value
  36558. * @param loopMode defines which loop mode you want to use (off by default)
  36559. * @param easingFunction defines the easing function to use (linear by default)
  36560. * @param onAnimationEnd defines the callback to call when animation end
  36561. * @returns the animatable created for this animation
  36562. */
  36563. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36564. /**
  36565. * Create and start an animation on a node and its descendants
  36566. * @param name defines the name of the global animation that will be run on all nodes
  36567. * @param node defines the root node where the animation will take place
  36568. * @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
  36569. * @param targetProperty defines property to animate
  36570. * @param framePerSecond defines the number of frame per second to use
  36571. * @param totalFrame defines the number of frames in total
  36572. * @param from defines the initial value
  36573. * @param to defines the final value
  36574. * @param loopMode defines which loop mode you want to use (off by default)
  36575. * @param easingFunction defines the easing function to use (linear by default)
  36576. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36577. * @returns the list of animatables created for all nodes
  36578. * @example https://www.babylonjs-playground.com/#MH0VLI
  36579. */
  36580. 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[]>;
  36581. /**
  36582. * Creates a new animation, merges it with the existing animations and starts it
  36583. * @param name Name of the animation
  36584. * @param node Node which contains the scene that begins the animations
  36585. * @param targetProperty Specifies which property to animate
  36586. * @param framePerSecond The frames per second of the animation
  36587. * @param totalFrame The total number of frames
  36588. * @param from The frame at the beginning of the animation
  36589. * @param to The frame at the end of the animation
  36590. * @param loopMode Specifies the loop mode of the animation
  36591. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36592. * @param onAnimationEnd Callback to run once the animation is complete
  36593. * @returns Nullable animation
  36594. */
  36595. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36596. /**
  36597. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36598. * @param sourceAnimation defines the Animation containing keyframes to convert
  36599. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36600. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36601. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36602. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36603. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36604. */
  36605. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36606. /**
  36607. * Transition property of an host to the target Value
  36608. * @param property The property to transition
  36609. * @param targetValue The target Value of the property
  36610. * @param host The object where the property to animate belongs
  36611. * @param scene Scene used to run the animation
  36612. * @param frameRate Framerate (in frame/s) to use
  36613. * @param transition The transition type we want to use
  36614. * @param duration The duration of the animation, in milliseconds
  36615. * @param onAnimationEnd Callback trigger at the end of the animation
  36616. * @returns Nullable animation
  36617. */
  36618. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36619. /**
  36620. * Return the array of runtime animations currently using this animation
  36621. */
  36622. get runtimeAnimations(): RuntimeAnimation[];
  36623. /**
  36624. * Specifies if any of the runtime animations are currently running
  36625. */
  36626. get hasRunningRuntimeAnimations(): boolean;
  36627. /**
  36628. * Initializes the animation
  36629. * @param name Name of the animation
  36630. * @param targetProperty Property to animate
  36631. * @param framePerSecond The frames per second of the animation
  36632. * @param dataType The data type of the animation
  36633. * @param loopMode The loop mode of the animation
  36634. * @param enableBlending Specifies if blending should be enabled
  36635. */
  36636. constructor(
  36637. /**Name of the animation */
  36638. name: string,
  36639. /**Property to animate */
  36640. targetProperty: string,
  36641. /**The frames per second of the animation */
  36642. framePerSecond: number,
  36643. /**The data type of the animation */
  36644. dataType: number,
  36645. /**The loop mode of the animation */
  36646. loopMode?: number | undefined,
  36647. /**Specifies if blending should be enabled */
  36648. enableBlending?: boolean | undefined);
  36649. /**
  36650. * Converts the animation to a string
  36651. * @param fullDetails support for multiple levels of logging within scene loading
  36652. * @returns String form of the animation
  36653. */
  36654. toString(fullDetails?: boolean): string;
  36655. /**
  36656. * Add an event to this animation
  36657. * @param event Event to add
  36658. */
  36659. addEvent(event: AnimationEvent): void;
  36660. /**
  36661. * Remove all events found at the given frame
  36662. * @param frame The frame to remove events from
  36663. */
  36664. removeEvents(frame: number): void;
  36665. /**
  36666. * Retrieves all the events from the animation
  36667. * @returns Events from the animation
  36668. */
  36669. getEvents(): AnimationEvent[];
  36670. /**
  36671. * Creates an animation range
  36672. * @param name Name of the animation range
  36673. * @param from Starting frame of the animation range
  36674. * @param to Ending frame of the animation
  36675. */
  36676. createRange(name: string, from: number, to: number): void;
  36677. /**
  36678. * Deletes an animation range by name
  36679. * @param name Name of the animation range to delete
  36680. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36681. */
  36682. deleteRange(name: string, deleteFrames?: boolean): void;
  36683. /**
  36684. * Gets the animation range by name, or null if not defined
  36685. * @param name Name of the animation range
  36686. * @returns Nullable animation range
  36687. */
  36688. getRange(name: string): Nullable<AnimationRange>;
  36689. /**
  36690. * Gets the key frames from the animation
  36691. * @returns The key frames of the animation
  36692. */
  36693. getKeys(): Array<IAnimationKey>;
  36694. /**
  36695. * Gets the highest frame rate of the animation
  36696. * @returns Highest frame rate of the animation
  36697. */
  36698. getHighestFrame(): number;
  36699. /**
  36700. * Gets the easing function of the animation
  36701. * @returns Easing function of the animation
  36702. */
  36703. getEasingFunction(): IEasingFunction;
  36704. /**
  36705. * Sets the easing function of the animation
  36706. * @param easingFunction A custom mathematical formula for animation
  36707. */
  36708. setEasingFunction(easingFunction: EasingFunction): void;
  36709. /**
  36710. * Interpolates a scalar linearly
  36711. * @param startValue Start value of the animation curve
  36712. * @param endValue End value of the animation curve
  36713. * @param gradient Scalar amount to interpolate
  36714. * @returns Interpolated scalar value
  36715. */
  36716. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36717. /**
  36718. * Interpolates a scalar cubically
  36719. * @param startValue Start value of the animation curve
  36720. * @param outTangent End tangent of the animation
  36721. * @param endValue End value of the animation curve
  36722. * @param inTangent Start tangent of the animation curve
  36723. * @param gradient Scalar amount to interpolate
  36724. * @returns Interpolated scalar value
  36725. */
  36726. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36727. /**
  36728. * Interpolates a quaternion using a spherical linear interpolation
  36729. * @param startValue Start value of the animation curve
  36730. * @param endValue End value of the animation curve
  36731. * @param gradient Scalar amount to interpolate
  36732. * @returns Interpolated quaternion value
  36733. */
  36734. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36735. /**
  36736. * Interpolates a quaternion cubically
  36737. * @param startValue Start value of the animation curve
  36738. * @param outTangent End tangent of the animation curve
  36739. * @param endValue End value of the animation curve
  36740. * @param inTangent Start tangent of the animation curve
  36741. * @param gradient Scalar amount to interpolate
  36742. * @returns Interpolated quaternion value
  36743. */
  36744. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36745. /**
  36746. * Interpolates a Vector3 linearl
  36747. * @param startValue Start value of the animation curve
  36748. * @param endValue End value of the animation curve
  36749. * @param gradient Scalar amount to interpolate
  36750. * @returns Interpolated scalar value
  36751. */
  36752. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36753. /**
  36754. * Interpolates a Vector3 cubically
  36755. * @param startValue Start value of the animation curve
  36756. * @param outTangent End tangent of the animation
  36757. * @param endValue End value of the animation curve
  36758. * @param inTangent Start tangent of the animation curve
  36759. * @param gradient Scalar amount to interpolate
  36760. * @returns InterpolatedVector3 value
  36761. */
  36762. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36763. /**
  36764. * Interpolates a Vector2 linearly
  36765. * @param startValue Start value of the animation curve
  36766. * @param endValue End value of the animation curve
  36767. * @param gradient Scalar amount to interpolate
  36768. * @returns Interpolated Vector2 value
  36769. */
  36770. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36771. /**
  36772. * Interpolates a Vector2 cubically
  36773. * @param startValue Start value of the animation curve
  36774. * @param outTangent End tangent of the animation
  36775. * @param endValue End value of the animation curve
  36776. * @param inTangent Start tangent of the animation curve
  36777. * @param gradient Scalar amount to interpolate
  36778. * @returns Interpolated Vector2 value
  36779. */
  36780. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36781. /**
  36782. * Interpolates a size linearly
  36783. * @param startValue Start value of the animation curve
  36784. * @param endValue End value of the animation curve
  36785. * @param gradient Scalar amount to interpolate
  36786. * @returns Interpolated Size value
  36787. */
  36788. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36789. /**
  36790. * Interpolates a Color3 linearly
  36791. * @param startValue Start value of the animation curve
  36792. * @param endValue End value of the animation curve
  36793. * @param gradient Scalar amount to interpolate
  36794. * @returns Interpolated Color3 value
  36795. */
  36796. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36797. /**
  36798. * Interpolates a Color4 linearly
  36799. * @param startValue Start value of the animation curve
  36800. * @param endValue End value of the animation curve
  36801. * @param gradient Scalar amount to interpolate
  36802. * @returns Interpolated Color3 value
  36803. */
  36804. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36805. /**
  36806. * @hidden Internal use only
  36807. */
  36808. _getKeyValue(value: any): any;
  36809. /**
  36810. * @hidden Internal use only
  36811. */
  36812. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36813. /**
  36814. * Defines the function to use to interpolate matrices
  36815. * @param startValue defines the start matrix
  36816. * @param endValue defines the end matrix
  36817. * @param gradient defines the gradient between both matrices
  36818. * @param result defines an optional target matrix where to store the interpolation
  36819. * @returns the interpolated matrix
  36820. */
  36821. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36822. /**
  36823. * Makes a copy of the animation
  36824. * @returns Cloned animation
  36825. */
  36826. clone(): Animation;
  36827. /**
  36828. * Sets the key frames of the animation
  36829. * @param values The animation key frames to set
  36830. */
  36831. setKeys(values: Array<IAnimationKey>): void;
  36832. /**
  36833. * Serializes the animation to an object
  36834. * @returns Serialized object
  36835. */
  36836. serialize(): any;
  36837. /**
  36838. * Float animation type
  36839. */
  36840. static readonly ANIMATIONTYPE_FLOAT: number;
  36841. /**
  36842. * Vector3 animation type
  36843. */
  36844. static readonly ANIMATIONTYPE_VECTOR3: number;
  36845. /**
  36846. * Quaternion animation type
  36847. */
  36848. static readonly ANIMATIONTYPE_QUATERNION: number;
  36849. /**
  36850. * Matrix animation type
  36851. */
  36852. static readonly ANIMATIONTYPE_MATRIX: number;
  36853. /**
  36854. * Color3 animation type
  36855. */
  36856. static readonly ANIMATIONTYPE_COLOR3: number;
  36857. /**
  36858. * Color3 animation type
  36859. */
  36860. static readonly ANIMATIONTYPE_COLOR4: number;
  36861. /**
  36862. * Vector2 animation type
  36863. */
  36864. static readonly ANIMATIONTYPE_VECTOR2: number;
  36865. /**
  36866. * Size animation type
  36867. */
  36868. static readonly ANIMATIONTYPE_SIZE: number;
  36869. /**
  36870. * Relative Loop Mode
  36871. */
  36872. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36873. /**
  36874. * Cycle Loop Mode
  36875. */
  36876. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36877. /**
  36878. * Constant Loop Mode
  36879. */
  36880. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36881. /** @hidden */
  36882. static _UniversalLerp(left: any, right: any, amount: number): any;
  36883. /**
  36884. * Parses an animation object and creates an animation
  36885. * @param parsedAnimation Parsed animation object
  36886. * @returns Animation object
  36887. */
  36888. static Parse(parsedAnimation: any): Animation;
  36889. /**
  36890. * Appends the serialized animations from the source animations
  36891. * @param source Source containing the animations
  36892. * @param destination Target to store the animations
  36893. */
  36894. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36895. /**
  36896. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36897. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36898. * @param url defines the url to load from
  36899. * @returns a promise that will resolve to the new animation or an array of animations
  36900. */
  36901. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36902. /**
  36903. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36904. * @param snippetId defines the snippet to load
  36905. * @returns a promise that will resolve to the new animation or a new array of animations
  36906. */
  36907. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36908. }
  36909. }
  36910. declare module BABYLON {
  36911. /**
  36912. * Interface containing an array of animations
  36913. */
  36914. export interface IAnimatable {
  36915. /**
  36916. * Array of animations
  36917. */
  36918. animations: Nullable<Array<Animation>>;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36923. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36924. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36925. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36926. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36927. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36928. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36929. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36930. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36931. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36932. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36933. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36934. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36935. /**
  36936. * Decorator used to define property that can be serialized as reference to a camera
  36937. * @param sourceName defines the name of the property to decorate
  36938. */
  36939. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36940. /**
  36941. * Class used to help serialization objects
  36942. */
  36943. export class SerializationHelper {
  36944. /** @hidden */
  36945. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36946. /** @hidden */
  36947. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36948. /** @hidden */
  36949. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36950. /** @hidden */
  36951. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36952. /**
  36953. * Appends the serialized animations from the source animations
  36954. * @param source Source containing the animations
  36955. * @param destination Target to store the animations
  36956. */
  36957. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36958. /**
  36959. * Static function used to serialized a specific entity
  36960. * @param entity defines the entity to serialize
  36961. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36962. * @returns a JSON compatible object representing the serialization of the entity
  36963. */
  36964. static Serialize<T>(entity: T, serializationObject?: any): any;
  36965. /**
  36966. * Creates a new entity from a serialization data object
  36967. * @param creationFunction defines a function used to instanciated the new entity
  36968. * @param source defines the source serialization data
  36969. * @param scene defines the hosting scene
  36970. * @param rootUrl defines the root url for resources
  36971. * @returns a new entity
  36972. */
  36973. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36974. /**
  36975. * Clones an object
  36976. * @param creationFunction defines the function used to instanciate the new object
  36977. * @param source defines the source object
  36978. * @returns the cloned object
  36979. */
  36980. static Clone<T>(creationFunction: () => T, source: T): T;
  36981. /**
  36982. * Instanciates a new object based on a source one (some data will be shared between both object)
  36983. * @param creationFunction defines the function used to instanciate the new object
  36984. * @param source defines the source object
  36985. * @returns the new object
  36986. */
  36987. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36988. }
  36989. }
  36990. declare module BABYLON {
  36991. /**
  36992. * This is the base class of all the camera used in the application.
  36993. * @see https://doc.babylonjs.com/features/cameras
  36994. */
  36995. export class Camera extends Node {
  36996. /** @hidden */
  36997. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36998. /**
  36999. * This is the default projection mode used by the cameras.
  37000. * It helps recreating a feeling of perspective and better appreciate depth.
  37001. * This is the best way to simulate real life cameras.
  37002. */
  37003. static readonly PERSPECTIVE_CAMERA: number;
  37004. /**
  37005. * This helps creating camera with an orthographic mode.
  37006. * 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.
  37007. */
  37008. static readonly ORTHOGRAPHIC_CAMERA: number;
  37009. /**
  37010. * This is the default FOV mode for perspective cameras.
  37011. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37012. */
  37013. static readonly FOVMODE_VERTICAL_FIXED: number;
  37014. /**
  37015. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37016. */
  37017. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37018. /**
  37019. * This specifies ther is no need for a camera rig.
  37020. * Basically only one eye is rendered corresponding to the camera.
  37021. */
  37022. static readonly RIG_MODE_NONE: number;
  37023. /**
  37024. * Simulates a camera Rig with one blue eye and one red eye.
  37025. * This can be use with 3d blue and red glasses.
  37026. */
  37027. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37028. /**
  37029. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37030. */
  37031. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37032. /**
  37033. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37034. */
  37035. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37036. /**
  37037. * Defines that both eyes of the camera will be rendered over under each other.
  37038. */
  37039. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37040. /**
  37041. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37042. */
  37043. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37044. /**
  37045. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37046. */
  37047. static readonly RIG_MODE_VR: number;
  37048. /**
  37049. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37050. */
  37051. static readonly RIG_MODE_WEBVR: number;
  37052. /**
  37053. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37054. */
  37055. static readonly RIG_MODE_CUSTOM: number;
  37056. /**
  37057. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37058. */
  37059. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37060. /**
  37061. * Define the input manager associated with the camera.
  37062. */
  37063. inputs: CameraInputsManager<Camera>;
  37064. /** @hidden */
  37065. _position: Vector3;
  37066. /**
  37067. * Define the current local position of the camera in the scene
  37068. */
  37069. get position(): Vector3;
  37070. set position(newPosition: Vector3);
  37071. protected _upVector: Vector3;
  37072. /**
  37073. * The vector the camera should consider as up.
  37074. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37075. */
  37076. set upVector(vec: Vector3);
  37077. get upVector(): Vector3;
  37078. /**
  37079. * Define the current limit on the left side for an orthographic camera
  37080. * In scene unit
  37081. */
  37082. orthoLeft: Nullable<number>;
  37083. /**
  37084. * Define the current limit on the right side for an orthographic camera
  37085. * In scene unit
  37086. */
  37087. orthoRight: Nullable<number>;
  37088. /**
  37089. * Define the current limit on the bottom side for an orthographic camera
  37090. * In scene unit
  37091. */
  37092. orthoBottom: Nullable<number>;
  37093. /**
  37094. * Define the current limit on the top side for an orthographic camera
  37095. * In scene unit
  37096. */
  37097. orthoTop: Nullable<number>;
  37098. /**
  37099. * Field Of View is set in Radians. (default is 0.8)
  37100. */
  37101. fov: number;
  37102. /**
  37103. * Define the minimum distance the camera can see from.
  37104. * This is important to note that the depth buffer are not infinite and the closer it starts
  37105. * the more your scene might encounter depth fighting issue.
  37106. */
  37107. minZ: number;
  37108. /**
  37109. * Define the maximum distance the camera can see to.
  37110. * This is important to note that the depth buffer are not infinite and the further it end
  37111. * the more your scene might encounter depth fighting issue.
  37112. */
  37113. maxZ: number;
  37114. /**
  37115. * Define the default inertia of the camera.
  37116. * This helps giving a smooth feeling to the camera movement.
  37117. */
  37118. inertia: number;
  37119. /**
  37120. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37121. */
  37122. mode: number;
  37123. /**
  37124. * Define whether the camera is intermediate.
  37125. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37126. */
  37127. isIntermediate: boolean;
  37128. /**
  37129. * Define the viewport of the camera.
  37130. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37131. */
  37132. viewport: Viewport;
  37133. /**
  37134. * Restricts the camera to viewing objects with the same layerMask.
  37135. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37136. */
  37137. layerMask: number;
  37138. /**
  37139. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37140. */
  37141. fovMode: number;
  37142. /**
  37143. * Rig mode of the camera.
  37144. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37145. * This is normally controlled byt the camera themselves as internal use.
  37146. */
  37147. cameraRigMode: number;
  37148. /**
  37149. * Defines the distance between both "eyes" in case of a RIG
  37150. */
  37151. interaxialDistance: number;
  37152. /**
  37153. * Defines if stereoscopic rendering is done side by side or over under.
  37154. */
  37155. isStereoscopicSideBySide: boolean;
  37156. /**
  37157. * 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
  37158. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37159. * else in the scene. (Eg. security camera)
  37160. *
  37161. * 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)
  37162. */
  37163. customRenderTargets: RenderTargetTexture[];
  37164. /**
  37165. * When set, the camera will render to this render target instead of the default canvas
  37166. *
  37167. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37168. */
  37169. outputRenderTarget: Nullable<RenderTargetTexture>;
  37170. /**
  37171. * Observable triggered when the camera view matrix has changed.
  37172. */
  37173. onViewMatrixChangedObservable: Observable<Camera>;
  37174. /**
  37175. * Observable triggered when the camera Projection matrix has changed.
  37176. */
  37177. onProjectionMatrixChangedObservable: Observable<Camera>;
  37178. /**
  37179. * Observable triggered when the inputs have been processed.
  37180. */
  37181. onAfterCheckInputsObservable: Observable<Camera>;
  37182. /**
  37183. * Observable triggered when reset has been called and applied to the camera.
  37184. */
  37185. onRestoreStateObservable: Observable<Camera>;
  37186. /**
  37187. * Is this camera a part of a rig system?
  37188. */
  37189. isRigCamera: boolean;
  37190. /**
  37191. * If isRigCamera set to true this will be set with the parent camera.
  37192. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37193. */
  37194. rigParent?: Camera;
  37195. /** @hidden */
  37196. _cameraRigParams: any;
  37197. /** @hidden */
  37198. _rigCameras: Camera[];
  37199. /** @hidden */
  37200. _rigPostProcess: Nullable<PostProcess>;
  37201. protected _webvrViewMatrix: Matrix;
  37202. /** @hidden */
  37203. _skipRendering: boolean;
  37204. /** @hidden */
  37205. _projectionMatrix: Matrix;
  37206. /** @hidden */
  37207. _postProcesses: Nullable<PostProcess>[];
  37208. /** @hidden */
  37209. _activeMeshes: SmartArray<AbstractMesh>;
  37210. protected _globalPosition: Vector3;
  37211. /** @hidden */
  37212. _computedViewMatrix: Matrix;
  37213. private _doNotComputeProjectionMatrix;
  37214. private _transformMatrix;
  37215. private _frustumPlanes;
  37216. private _refreshFrustumPlanes;
  37217. private _storedFov;
  37218. private _stateStored;
  37219. /**
  37220. * Instantiates a new camera object.
  37221. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37222. * @see https://doc.babylonjs.com/features/cameras
  37223. * @param name Defines the name of the camera in the scene
  37224. * @param position Defines the position of the camera
  37225. * @param scene Defines the scene the camera belongs too
  37226. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37227. */
  37228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37229. /**
  37230. * Store current camera state (fov, position, etc..)
  37231. * @returns the camera
  37232. */
  37233. storeState(): Camera;
  37234. /**
  37235. * Restores the camera state values if it has been stored. You must call storeState() first
  37236. */
  37237. protected _restoreStateValues(): boolean;
  37238. /**
  37239. * Restored camera state. You must call storeState() first.
  37240. * @returns true if restored and false otherwise
  37241. */
  37242. restoreState(): boolean;
  37243. /**
  37244. * Gets the class name of the camera.
  37245. * @returns the class name
  37246. */
  37247. getClassName(): string;
  37248. /** @hidden */
  37249. readonly _isCamera: boolean;
  37250. /**
  37251. * Gets a string representation of the camera useful for debug purpose.
  37252. * @param fullDetails Defines that a more verboe level of logging is required
  37253. * @returns the string representation
  37254. */
  37255. toString(fullDetails?: boolean): string;
  37256. /**
  37257. * Gets the current world space position of the camera.
  37258. */
  37259. get globalPosition(): Vector3;
  37260. /**
  37261. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37262. * @returns the active meshe list
  37263. */
  37264. getActiveMeshes(): SmartArray<AbstractMesh>;
  37265. /**
  37266. * Check whether a mesh is part of the current active mesh list of the camera
  37267. * @param mesh Defines the mesh to check
  37268. * @returns true if active, false otherwise
  37269. */
  37270. isActiveMesh(mesh: Mesh): boolean;
  37271. /**
  37272. * Is this camera ready to be used/rendered
  37273. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37274. * @return true if the camera is ready
  37275. */
  37276. isReady(completeCheck?: boolean): boolean;
  37277. /** @hidden */
  37278. _initCache(): void;
  37279. /** @hidden */
  37280. _updateCache(ignoreParentClass?: boolean): void;
  37281. /** @hidden */
  37282. _isSynchronized(): boolean;
  37283. /** @hidden */
  37284. _isSynchronizedViewMatrix(): boolean;
  37285. /** @hidden */
  37286. _isSynchronizedProjectionMatrix(): boolean;
  37287. /**
  37288. * Attach the input controls to a specific dom element to get the input from.
  37289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37290. */
  37291. attachControl(noPreventDefault?: boolean): void;
  37292. /**
  37293. * Attach the input controls to a specific dom element to get the input from.
  37294. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37296. * BACK COMPAT SIGNATURE ONLY.
  37297. */
  37298. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37299. /**
  37300. * Detach the current controls from the specified dom element.
  37301. */
  37302. detachControl(): void;
  37303. /**
  37304. * Detach the current controls from the specified dom element.
  37305. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37306. */
  37307. detachControl(ignored: any): void;
  37308. /**
  37309. * Update the camera state according to the different inputs gathered during the frame.
  37310. */
  37311. update(): void;
  37312. /** @hidden */
  37313. _checkInputs(): void;
  37314. /** @hidden */
  37315. get rigCameras(): Camera[];
  37316. /**
  37317. * Gets the post process used by the rig cameras
  37318. */
  37319. get rigPostProcess(): Nullable<PostProcess>;
  37320. /**
  37321. * Internal, gets the first post proces.
  37322. * @returns the first post process to be run on this camera.
  37323. */
  37324. _getFirstPostProcess(): Nullable<PostProcess>;
  37325. private _cascadePostProcessesToRigCams;
  37326. /**
  37327. * Attach a post process to the camera.
  37328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37329. * @param postProcess The post process to attach to the camera
  37330. * @param insertAt The position of the post process in case several of them are in use in the scene
  37331. * @returns the position the post process has been inserted at
  37332. */
  37333. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37334. /**
  37335. * Detach a post process to the camera.
  37336. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37337. * @param postProcess The post process to detach from the camera
  37338. */
  37339. detachPostProcess(postProcess: PostProcess): void;
  37340. /**
  37341. * Gets the current world matrix of the camera
  37342. */
  37343. getWorldMatrix(): Matrix;
  37344. /** @hidden */
  37345. _getViewMatrix(): Matrix;
  37346. /**
  37347. * Gets the current view matrix of the camera.
  37348. * @param force forces the camera to recompute the matrix without looking at the cached state
  37349. * @returns the view matrix
  37350. */
  37351. getViewMatrix(force?: boolean): Matrix;
  37352. /**
  37353. * Freeze the projection matrix.
  37354. * It will prevent the cache check of the camera projection compute and can speed up perf
  37355. * if no parameter of the camera are meant to change
  37356. * @param projection Defines manually a projection if necessary
  37357. */
  37358. freezeProjectionMatrix(projection?: Matrix): void;
  37359. /**
  37360. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37361. */
  37362. unfreezeProjectionMatrix(): void;
  37363. /**
  37364. * Gets the current projection matrix of the camera.
  37365. * @param force forces the camera to recompute the matrix without looking at the cached state
  37366. * @returns the projection matrix
  37367. */
  37368. getProjectionMatrix(force?: boolean): Matrix;
  37369. /**
  37370. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37371. * @returns a Matrix
  37372. */
  37373. getTransformationMatrix(): Matrix;
  37374. private _updateFrustumPlanes;
  37375. /**
  37376. * Checks if a cullable object (mesh...) is in the camera frustum
  37377. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37378. * @param target The object to check
  37379. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37380. * @returns true if the object is in frustum otherwise false
  37381. */
  37382. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37383. /**
  37384. * Checks if a cullable object (mesh...) is in the camera frustum
  37385. * Unlike isInFrustum this cheks the full bounding box
  37386. * @param target The object to check
  37387. * @returns true if the object is in frustum otherwise false
  37388. */
  37389. isCompletelyInFrustum(target: ICullable): boolean;
  37390. /**
  37391. * Gets a ray in the forward direction from the camera.
  37392. * @param length Defines the length of the ray to create
  37393. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37394. * @param origin Defines the start point of the ray which defaults to the camera position
  37395. * @returns the forward ray
  37396. */
  37397. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37398. /**
  37399. * Gets a ray in the forward direction from the camera.
  37400. * @param refRay the ray to (re)use when setting the values
  37401. * @param length Defines the length of the ray to create
  37402. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37403. * @param origin Defines the start point of the ray which defaults to the camera position
  37404. * @returns the forward ray
  37405. */
  37406. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37407. /**
  37408. * Releases resources associated with this node.
  37409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37411. */
  37412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37413. /** @hidden */
  37414. _isLeftCamera: boolean;
  37415. /**
  37416. * Gets the left camera of a rig setup in case of Rigged Camera
  37417. */
  37418. get isLeftCamera(): boolean;
  37419. /** @hidden */
  37420. _isRightCamera: boolean;
  37421. /**
  37422. * Gets the right camera of a rig setup in case of Rigged Camera
  37423. */
  37424. get isRightCamera(): boolean;
  37425. /**
  37426. * Gets the left camera of a rig setup in case of Rigged Camera
  37427. */
  37428. get leftCamera(): Nullable<FreeCamera>;
  37429. /**
  37430. * Gets the right camera of a rig setup in case of Rigged Camera
  37431. */
  37432. get rightCamera(): Nullable<FreeCamera>;
  37433. /**
  37434. * Gets the left camera target of a rig setup in case of Rigged Camera
  37435. * @returns the target position
  37436. */
  37437. getLeftTarget(): Nullable<Vector3>;
  37438. /**
  37439. * Gets the right camera target of a rig setup in case of Rigged Camera
  37440. * @returns the target position
  37441. */
  37442. getRightTarget(): Nullable<Vector3>;
  37443. /**
  37444. * @hidden
  37445. */
  37446. setCameraRigMode(mode: number, rigParams: any): void;
  37447. /** @hidden */
  37448. static _setStereoscopicRigMode(camera: Camera): void;
  37449. /** @hidden */
  37450. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37451. /** @hidden */
  37452. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37453. /** @hidden */
  37454. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37455. /** @hidden */
  37456. _getVRProjectionMatrix(): Matrix;
  37457. protected _updateCameraRotationMatrix(): void;
  37458. protected _updateWebVRCameraRotationMatrix(): void;
  37459. /**
  37460. * This function MUST be overwritten by the different WebVR cameras available.
  37461. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37462. * @hidden
  37463. */
  37464. _getWebVRProjectionMatrix(): Matrix;
  37465. /**
  37466. * This function MUST be overwritten by the different WebVR cameras available.
  37467. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37468. * @hidden
  37469. */
  37470. _getWebVRViewMatrix(): Matrix;
  37471. /** @hidden */
  37472. setCameraRigParameter(name: string, value: any): void;
  37473. /**
  37474. * needs to be overridden by children so sub has required properties to be copied
  37475. * @hidden
  37476. */
  37477. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37478. /**
  37479. * May need to be overridden by children
  37480. * @hidden
  37481. */
  37482. _updateRigCameras(): void;
  37483. /** @hidden */
  37484. _setupInputs(): void;
  37485. /**
  37486. * Serialiaze the camera setup to a json represention
  37487. * @returns the JSON representation
  37488. */
  37489. serialize(): any;
  37490. /**
  37491. * Clones the current camera.
  37492. * @param name The cloned camera name
  37493. * @returns the cloned camera
  37494. */
  37495. clone(name: string): Camera;
  37496. /**
  37497. * Gets the direction of the camera relative to a given local axis.
  37498. * @param localAxis Defines the reference axis to provide a relative direction.
  37499. * @return the direction
  37500. */
  37501. getDirection(localAxis: Vector3): Vector3;
  37502. /**
  37503. * Returns the current camera absolute rotation
  37504. */
  37505. get absoluteRotation(): Quaternion;
  37506. /**
  37507. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37508. * @param localAxis Defines the reference axis to provide a relative direction.
  37509. * @param result Defines the vector to store the result in
  37510. */
  37511. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37512. /**
  37513. * Gets a camera constructor for a given camera type
  37514. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37515. * @param name The name of the camera the result will be able to instantiate
  37516. * @param scene The scene the result will construct the camera in
  37517. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37518. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37519. * @returns a factory method to construc the camera
  37520. */
  37521. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37522. /**
  37523. * Compute the world matrix of the camera.
  37524. * @returns the camera world matrix
  37525. */
  37526. computeWorldMatrix(): Matrix;
  37527. /**
  37528. * Parse a JSON and creates the camera from the parsed information
  37529. * @param parsedCamera The JSON to parse
  37530. * @param scene The scene to instantiate the camera in
  37531. * @returns the newly constructed camera
  37532. */
  37533. static Parse(parsedCamera: any, scene: Scene): Camera;
  37534. }
  37535. }
  37536. declare module BABYLON {
  37537. /**
  37538. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37539. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37540. */
  37541. export class PostProcessManager {
  37542. private _scene;
  37543. private _indexBuffer;
  37544. private _vertexBuffers;
  37545. /**
  37546. * Creates a new instance PostProcess
  37547. * @param scene The scene that the post process is associated with.
  37548. */
  37549. constructor(scene: Scene);
  37550. private _prepareBuffers;
  37551. private _buildIndexBuffer;
  37552. /**
  37553. * Rebuilds the vertex buffers of the manager.
  37554. * @hidden
  37555. */
  37556. _rebuild(): void;
  37557. /**
  37558. * Prepares a frame to be run through a post process.
  37559. * @param sourceTexture The input texture to the post procesess. (default: null)
  37560. * @param postProcesses An array of post processes to be run. (default: null)
  37561. * @returns True if the post processes were able to be run.
  37562. * @hidden
  37563. */
  37564. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37565. /**
  37566. * Manually render a set of post processes to a texture.
  37567. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37568. * @param postProcesses An array of post processes to be run.
  37569. * @param targetTexture The target texture to render to.
  37570. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37571. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37572. * @param lodLevel defines which lod of the texture to render to
  37573. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37574. */
  37575. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37576. /**
  37577. * Finalize the result of the output of the postprocesses.
  37578. * @param doNotPresent If true the result will not be displayed to the screen.
  37579. * @param targetTexture The target texture to render to.
  37580. * @param faceIndex The index of the face to bind the target texture to.
  37581. * @param postProcesses The array of post processes to render.
  37582. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37583. * @hidden
  37584. */
  37585. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37586. /**
  37587. * Disposes of the post process manager.
  37588. */
  37589. dispose(): void;
  37590. }
  37591. }
  37592. declare module BABYLON {
  37593. /**
  37594. * This Helps creating a texture that will be created from a camera in your scene.
  37595. * It is basically a dynamic texture that could be used to create special effects for instance.
  37596. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37597. */
  37598. export class RenderTargetTexture extends Texture {
  37599. /**
  37600. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37601. */
  37602. static readonly REFRESHRATE_RENDER_ONCE: number;
  37603. /**
  37604. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37605. */
  37606. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37607. /**
  37608. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37609. * the central point of your effect and can save a lot of performances.
  37610. */
  37611. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37612. /**
  37613. * Use this predicate to dynamically define the list of mesh you want to render.
  37614. * If set, the renderList property will be overwritten.
  37615. */
  37616. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37617. private _renderList;
  37618. /**
  37619. * Use this list to define the list of mesh you want to render.
  37620. */
  37621. get renderList(): Nullable<Array<AbstractMesh>>;
  37622. set renderList(value: Nullable<Array<AbstractMesh>>);
  37623. /**
  37624. * Use this function to overload the renderList array at rendering time.
  37625. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37626. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37627. * the cube (if the RTT is a cube, else layerOrFace=0).
  37628. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37629. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37630. * hold dummy elements!
  37631. */
  37632. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37633. private _hookArray;
  37634. /**
  37635. * Define if particles should be rendered in your texture.
  37636. */
  37637. renderParticles: boolean;
  37638. /**
  37639. * Define if sprites should be rendered in your texture.
  37640. */
  37641. renderSprites: boolean;
  37642. /**
  37643. * Define the camera used to render the texture.
  37644. */
  37645. activeCamera: Nullable<Camera>;
  37646. /**
  37647. * Override the mesh isReady function with your own one.
  37648. */
  37649. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37650. /**
  37651. * Override the render function of the texture with your own one.
  37652. */
  37653. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37654. /**
  37655. * Define if camera post processes should be use while rendering the texture.
  37656. */
  37657. useCameraPostProcesses: boolean;
  37658. /**
  37659. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37660. */
  37661. ignoreCameraViewport: boolean;
  37662. private _postProcessManager;
  37663. private _postProcesses;
  37664. private _resizeObserver;
  37665. /**
  37666. * An event triggered when the texture is unbind.
  37667. */
  37668. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37669. /**
  37670. * An event triggered when the texture is unbind.
  37671. */
  37672. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37673. private _onAfterUnbindObserver;
  37674. /**
  37675. * Set a after unbind callback in the texture.
  37676. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37677. */
  37678. set onAfterUnbind(callback: () => void);
  37679. /**
  37680. * An event triggered before rendering the texture
  37681. */
  37682. onBeforeRenderObservable: Observable<number>;
  37683. private _onBeforeRenderObserver;
  37684. /**
  37685. * Set a before render callback in the texture.
  37686. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37687. */
  37688. set onBeforeRender(callback: (faceIndex: number) => void);
  37689. /**
  37690. * An event triggered after rendering the texture
  37691. */
  37692. onAfterRenderObservable: Observable<number>;
  37693. private _onAfterRenderObserver;
  37694. /**
  37695. * Set a after render callback in the texture.
  37696. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37697. */
  37698. set onAfterRender(callback: (faceIndex: number) => void);
  37699. /**
  37700. * An event triggered after the texture clear
  37701. */
  37702. onClearObservable: Observable<Engine>;
  37703. private _onClearObserver;
  37704. /**
  37705. * Set a clear callback in the texture.
  37706. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37707. */
  37708. set onClear(callback: (Engine: Engine) => void);
  37709. /**
  37710. * An event triggered when the texture is resized.
  37711. */
  37712. onResizeObservable: Observable<RenderTargetTexture>;
  37713. /**
  37714. * Define the clear color of the Render Target if it should be different from the scene.
  37715. */
  37716. clearColor: Color4;
  37717. protected _size: number | {
  37718. width: number;
  37719. height: number;
  37720. layers?: number;
  37721. };
  37722. protected _initialSizeParameter: number | {
  37723. width: number;
  37724. height: number;
  37725. } | {
  37726. ratio: number;
  37727. };
  37728. protected _sizeRatio: Nullable<number>;
  37729. /** @hidden */
  37730. _generateMipMaps: boolean;
  37731. protected _renderingManager: RenderingManager;
  37732. /** @hidden */
  37733. _waitingRenderList?: string[];
  37734. protected _doNotChangeAspectRatio: boolean;
  37735. protected _currentRefreshId: number;
  37736. protected _refreshRate: number;
  37737. protected _textureMatrix: Matrix;
  37738. protected _samples: number;
  37739. protected _renderTargetOptions: RenderTargetCreationOptions;
  37740. /**
  37741. * Gets render target creation options that were used.
  37742. */
  37743. get renderTargetOptions(): RenderTargetCreationOptions;
  37744. protected _onRatioRescale(): void;
  37745. /**
  37746. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37747. * It must define where the camera used to render the texture is set
  37748. */
  37749. boundingBoxPosition: Vector3;
  37750. private _boundingBoxSize;
  37751. /**
  37752. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37753. * When defined, the cubemap will switch to local mode
  37754. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37755. * @example https://www.babylonjs-playground.com/#RNASML
  37756. */
  37757. set boundingBoxSize(value: Vector3);
  37758. get boundingBoxSize(): Vector3;
  37759. /**
  37760. * In case the RTT has been created with a depth texture, get the associated
  37761. * depth texture.
  37762. * Otherwise, return null.
  37763. */
  37764. get depthStencilTexture(): Nullable<InternalTexture>;
  37765. /**
  37766. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37767. * or used a shadow, depth texture...
  37768. * @param name The friendly name of the texture
  37769. * @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)
  37770. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37771. * @param generateMipMaps True if mip maps need to be generated after render.
  37772. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37773. * @param type The type of the buffer in the RTT (int, half float, float...)
  37774. * @param isCube True if a cube texture needs to be created
  37775. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37776. * @param generateDepthBuffer True to generate a depth buffer
  37777. * @param generateStencilBuffer True to generate a stencil buffer
  37778. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37779. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37780. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37781. */
  37782. constructor(name: string, size: number | {
  37783. width: number;
  37784. height: number;
  37785. layers?: number;
  37786. } | {
  37787. ratio: number;
  37788. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37789. /**
  37790. * Creates a depth stencil texture.
  37791. * This is only available in WebGL 2 or with the depth texture extension available.
  37792. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37793. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37794. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37795. */
  37796. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37797. private _processSizeParameter;
  37798. /**
  37799. * Define the number of samples to use in case of MSAA.
  37800. * It defaults to one meaning no MSAA has been enabled.
  37801. */
  37802. get samples(): number;
  37803. set samples(value: number);
  37804. /**
  37805. * Resets the refresh counter of the texture and start bak from scratch.
  37806. * Could be useful to regenerate the texture if it is setup to render only once.
  37807. */
  37808. resetRefreshCounter(): void;
  37809. /**
  37810. * Define the refresh rate of the texture or the rendering frequency.
  37811. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37812. */
  37813. get refreshRate(): number;
  37814. set refreshRate(value: number);
  37815. /**
  37816. * Adds a post process to the render target rendering passes.
  37817. * @param postProcess define the post process to add
  37818. */
  37819. addPostProcess(postProcess: PostProcess): void;
  37820. /**
  37821. * Clear all the post processes attached to the render target
  37822. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37823. */
  37824. clearPostProcesses(dispose?: boolean): void;
  37825. /**
  37826. * Remove one of the post process from the list of attached post processes to the texture
  37827. * @param postProcess define the post process to remove from the list
  37828. */
  37829. removePostProcess(postProcess: PostProcess): void;
  37830. /** @hidden */
  37831. _shouldRender(): boolean;
  37832. /**
  37833. * Gets the actual render size of the texture.
  37834. * @returns the width of the render size
  37835. */
  37836. getRenderSize(): number;
  37837. /**
  37838. * Gets the actual render width of the texture.
  37839. * @returns the width of the render size
  37840. */
  37841. getRenderWidth(): number;
  37842. /**
  37843. * Gets the actual render height of the texture.
  37844. * @returns the height of the render size
  37845. */
  37846. getRenderHeight(): number;
  37847. /**
  37848. * Gets the actual number of layers of the texture.
  37849. * @returns the number of layers
  37850. */
  37851. getRenderLayers(): number;
  37852. /**
  37853. * Get if the texture can be rescaled or not.
  37854. */
  37855. get canRescale(): boolean;
  37856. /**
  37857. * Resize the texture using a ratio.
  37858. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37859. */
  37860. scale(ratio: number): void;
  37861. /**
  37862. * Get the texture reflection matrix used to rotate/transform the reflection.
  37863. * @returns the reflection matrix
  37864. */
  37865. getReflectionTextureMatrix(): Matrix;
  37866. /**
  37867. * Resize the texture to a new desired size.
  37868. * Be carrefull as it will recreate all the data in the new texture.
  37869. * @param size Define the new size. It can be:
  37870. * - a number for squared texture,
  37871. * - an object containing { width: number, height: number }
  37872. * - or an object containing a ratio { ratio: number }
  37873. */
  37874. resize(size: number | {
  37875. width: number;
  37876. height: number;
  37877. } | {
  37878. ratio: number;
  37879. }): void;
  37880. private _defaultRenderListPrepared;
  37881. /**
  37882. * Renders all the objects from the render list into the texture.
  37883. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37884. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37885. */
  37886. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37887. private _bestReflectionRenderTargetDimension;
  37888. private _prepareRenderingManager;
  37889. /**
  37890. * @hidden
  37891. * @param faceIndex face index to bind to if this is a cubetexture
  37892. * @param layer defines the index of the texture to bind in the array
  37893. */
  37894. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37895. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37896. private renderToTarget;
  37897. /**
  37898. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37899. * This allowed control for front to back rendering or reversly depending of the special needs.
  37900. *
  37901. * @param renderingGroupId The rendering group id corresponding to its index
  37902. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37903. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37904. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37905. */
  37906. 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;
  37907. /**
  37908. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37909. *
  37910. * @param renderingGroupId The rendering group id corresponding to its index
  37911. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37912. */
  37913. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37914. /**
  37915. * Clones the texture.
  37916. * @returns the cloned texture
  37917. */
  37918. clone(): RenderTargetTexture;
  37919. /**
  37920. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37921. * @returns The JSON representation of the texture
  37922. */
  37923. serialize(): any;
  37924. /**
  37925. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37926. */
  37927. disposeFramebufferObjects(): void;
  37928. /**
  37929. * Dispose the texture and release its associated resources.
  37930. */
  37931. dispose(): void;
  37932. /** @hidden */
  37933. _rebuild(): void;
  37934. /**
  37935. * Clear the info related to rendering groups preventing retention point in material dispose.
  37936. */
  37937. freeRenderingGroups(): void;
  37938. /**
  37939. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37940. * @returns the view count
  37941. */
  37942. getViewCount(): number;
  37943. }
  37944. }
  37945. declare module BABYLON {
  37946. /**
  37947. * Options to be used when creating an effect.
  37948. */
  37949. export interface IEffectCreationOptions {
  37950. /**
  37951. * Atrributes that will be used in the shader.
  37952. */
  37953. attributes: string[];
  37954. /**
  37955. * Uniform varible names that will be set in the shader.
  37956. */
  37957. uniformsNames: string[];
  37958. /**
  37959. * Uniform buffer variable names that will be set in the shader.
  37960. */
  37961. uniformBuffersNames: string[];
  37962. /**
  37963. * Sampler texture variable names that will be set in the shader.
  37964. */
  37965. samplers: string[];
  37966. /**
  37967. * Define statements that will be set in the shader.
  37968. */
  37969. defines: any;
  37970. /**
  37971. * Possible fallbacks for this effect to improve performance when needed.
  37972. */
  37973. fallbacks: Nullable<IEffectFallbacks>;
  37974. /**
  37975. * Callback that will be called when the shader is compiled.
  37976. */
  37977. onCompiled: Nullable<(effect: Effect) => void>;
  37978. /**
  37979. * Callback that will be called if an error occurs during shader compilation.
  37980. */
  37981. onError: Nullable<(effect: Effect, errors: string) => void>;
  37982. /**
  37983. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37984. */
  37985. indexParameters?: any;
  37986. /**
  37987. * Max number of lights that can be used in the shader.
  37988. */
  37989. maxSimultaneousLights?: number;
  37990. /**
  37991. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37992. */
  37993. transformFeedbackVaryings?: Nullable<string[]>;
  37994. /**
  37995. * 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
  37996. */
  37997. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37998. /**
  37999. * Is this effect rendering to several color attachments ?
  38000. */
  38001. multiTarget?: boolean;
  38002. }
  38003. /**
  38004. * Effect containing vertex and fragment shader that can be executed on an object.
  38005. */
  38006. export class Effect implements IDisposable {
  38007. /**
  38008. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38009. */
  38010. static ShadersRepository: string;
  38011. /**
  38012. * Enable logging of the shader code when a compilation error occurs
  38013. */
  38014. static LogShaderCodeOnCompilationError: boolean;
  38015. /**
  38016. * Name of the effect.
  38017. */
  38018. name: any;
  38019. /**
  38020. * String container all the define statements that should be set on the shader.
  38021. */
  38022. defines: string;
  38023. /**
  38024. * Callback that will be called when the shader is compiled.
  38025. */
  38026. onCompiled: Nullable<(effect: Effect) => void>;
  38027. /**
  38028. * Callback that will be called if an error occurs during shader compilation.
  38029. */
  38030. onError: Nullable<(effect: Effect, errors: string) => void>;
  38031. /**
  38032. * Callback that will be called when effect is bound.
  38033. */
  38034. onBind: Nullable<(effect: Effect) => void>;
  38035. /**
  38036. * Unique ID of the effect.
  38037. */
  38038. uniqueId: number;
  38039. /**
  38040. * Observable that will be called when the shader is compiled.
  38041. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38042. */
  38043. onCompileObservable: Observable<Effect>;
  38044. /**
  38045. * Observable that will be called if an error occurs during shader compilation.
  38046. */
  38047. onErrorObservable: Observable<Effect>;
  38048. /** @hidden */
  38049. _onBindObservable: Nullable<Observable<Effect>>;
  38050. /**
  38051. * @hidden
  38052. * Specifies if the effect was previously ready
  38053. */
  38054. _wasPreviouslyReady: boolean;
  38055. /**
  38056. * Observable that will be called when effect is bound.
  38057. */
  38058. get onBindObservable(): Observable<Effect>;
  38059. /** @hidden */
  38060. _bonesComputationForcedToCPU: boolean;
  38061. /** @hidden */
  38062. _multiTarget: boolean;
  38063. private static _uniqueIdSeed;
  38064. private _engine;
  38065. private _uniformBuffersNames;
  38066. private _uniformBuffersNamesList;
  38067. private _uniformsNames;
  38068. private _samplerList;
  38069. private _samplers;
  38070. private _isReady;
  38071. private _compilationError;
  38072. private _allFallbacksProcessed;
  38073. private _attributesNames;
  38074. private _attributes;
  38075. private _attributeLocationByName;
  38076. private _uniforms;
  38077. /**
  38078. * Key for the effect.
  38079. * @hidden
  38080. */
  38081. _key: string;
  38082. private _indexParameters;
  38083. private _fallbacks;
  38084. private _vertexSourceCode;
  38085. private _fragmentSourceCode;
  38086. private _vertexSourceCodeOverride;
  38087. private _fragmentSourceCodeOverride;
  38088. private _transformFeedbackVaryings;
  38089. private _rawVertexSourceCode;
  38090. private _rawFragmentSourceCode;
  38091. /**
  38092. * Compiled shader to webGL program.
  38093. * @hidden
  38094. */
  38095. _pipelineContext: Nullable<IPipelineContext>;
  38096. private _valueCache;
  38097. private static _baseCache;
  38098. /**
  38099. * Instantiates an effect.
  38100. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38101. * @param baseName Name of the effect.
  38102. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38103. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38104. * @param samplers List of sampler variables that will be passed to the shader.
  38105. * @param engine Engine to be used to render the effect
  38106. * @param defines Define statements to be added to the shader.
  38107. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38108. * @param onCompiled Callback that will be called when the shader is compiled.
  38109. * @param onError Callback that will be called if an error occurs during shader compilation.
  38110. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38111. */
  38112. 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);
  38113. private _useFinalCode;
  38114. /**
  38115. * Unique key for this effect
  38116. */
  38117. get key(): string;
  38118. /**
  38119. * If the effect has been compiled and prepared.
  38120. * @returns if the effect is compiled and prepared.
  38121. */
  38122. isReady(): boolean;
  38123. private _isReadyInternal;
  38124. /**
  38125. * The engine the effect was initialized with.
  38126. * @returns the engine.
  38127. */
  38128. getEngine(): Engine;
  38129. /**
  38130. * The pipeline context for this effect
  38131. * @returns the associated pipeline context
  38132. */
  38133. getPipelineContext(): Nullable<IPipelineContext>;
  38134. /**
  38135. * The set of names of attribute variables for the shader.
  38136. * @returns An array of attribute names.
  38137. */
  38138. getAttributesNames(): string[];
  38139. /**
  38140. * Returns the attribute at the given index.
  38141. * @param index The index of the attribute.
  38142. * @returns The location of the attribute.
  38143. */
  38144. getAttributeLocation(index: number): number;
  38145. /**
  38146. * Returns the attribute based on the name of the variable.
  38147. * @param name of the attribute to look up.
  38148. * @returns the attribute location.
  38149. */
  38150. getAttributeLocationByName(name: string): number;
  38151. /**
  38152. * The number of attributes.
  38153. * @returns the numnber of attributes.
  38154. */
  38155. getAttributesCount(): number;
  38156. /**
  38157. * Gets the index of a uniform variable.
  38158. * @param uniformName of the uniform to look up.
  38159. * @returns the index.
  38160. */
  38161. getUniformIndex(uniformName: string): number;
  38162. /**
  38163. * Returns the attribute based on the name of the variable.
  38164. * @param uniformName of the uniform to look up.
  38165. * @returns the location of the uniform.
  38166. */
  38167. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38168. /**
  38169. * Returns an array of sampler variable names
  38170. * @returns The array of sampler variable names.
  38171. */
  38172. getSamplers(): string[];
  38173. /**
  38174. * Returns an array of uniform variable names
  38175. * @returns The array of uniform variable names.
  38176. */
  38177. getUniformNames(): string[];
  38178. /**
  38179. * Returns an array of uniform buffer variable names
  38180. * @returns The array of uniform buffer variable names.
  38181. */
  38182. getUniformBuffersNames(): string[];
  38183. /**
  38184. * Returns the index parameters used to create the effect
  38185. * @returns The index parameters object
  38186. */
  38187. getIndexParameters(): any;
  38188. /**
  38189. * The error from the last compilation.
  38190. * @returns the error string.
  38191. */
  38192. getCompilationError(): string;
  38193. /**
  38194. * Gets a boolean indicating that all fallbacks were used during compilation
  38195. * @returns true if all fallbacks were used
  38196. */
  38197. allFallbacksProcessed(): boolean;
  38198. /**
  38199. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38200. * @param func The callback to be used.
  38201. */
  38202. executeWhenCompiled(func: (effect: Effect) => void): void;
  38203. private _checkIsReady;
  38204. private _loadShader;
  38205. /**
  38206. * Gets the vertex shader source code of this effect
  38207. */
  38208. get vertexSourceCode(): string;
  38209. /**
  38210. * Gets the fragment shader source code of this effect
  38211. */
  38212. get fragmentSourceCode(): string;
  38213. /**
  38214. * Gets the vertex shader source code before it has been processed by the preprocessor
  38215. */
  38216. get rawVertexSourceCode(): string;
  38217. /**
  38218. * Gets the fragment shader source code before it has been processed by the preprocessor
  38219. */
  38220. get rawFragmentSourceCode(): string;
  38221. /**
  38222. * Recompiles the webGL program
  38223. * @param vertexSourceCode The source code for the vertex shader.
  38224. * @param fragmentSourceCode The source code for the fragment shader.
  38225. * @param onCompiled Callback called when completed.
  38226. * @param onError Callback called on error.
  38227. * @hidden
  38228. */
  38229. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38230. /**
  38231. * Prepares the effect
  38232. * @hidden
  38233. */
  38234. _prepareEffect(): void;
  38235. private _getShaderCodeAndErrorLine;
  38236. private _processCompilationErrors;
  38237. /**
  38238. * Checks if the effect is supported. (Must be called after compilation)
  38239. */
  38240. get isSupported(): boolean;
  38241. /**
  38242. * Binds a texture to the engine to be used as output of the shader.
  38243. * @param channel Name of the output variable.
  38244. * @param texture Texture to bind.
  38245. * @hidden
  38246. */
  38247. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38248. /**
  38249. * Sets a texture on the engine to be used in the shader.
  38250. * @param channel Name of the sampler variable.
  38251. * @param texture Texture to set.
  38252. */
  38253. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38254. /**
  38255. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38256. * @param channel Name of the sampler variable.
  38257. * @param texture Texture to set.
  38258. */
  38259. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38260. /**
  38261. * Sets an array of textures on the engine to be used in the shader.
  38262. * @param channel Name of the variable.
  38263. * @param textures Textures to set.
  38264. */
  38265. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38266. /**
  38267. * 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)
  38268. * @param channel Name of the sampler variable.
  38269. * @param postProcess Post process to get the input texture from.
  38270. */
  38271. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38272. /**
  38273. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38274. * 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)
  38275. * @param channel Name of the sampler variable.
  38276. * @param postProcess Post process to get the output texture from.
  38277. */
  38278. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38279. /** @hidden */
  38280. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38281. /** @hidden */
  38282. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38283. /** @hidden */
  38284. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38285. /** @hidden */
  38286. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38287. /**
  38288. * Binds a buffer to a uniform.
  38289. * @param buffer Buffer to bind.
  38290. * @param name Name of the uniform variable to bind to.
  38291. */
  38292. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38293. /**
  38294. * Binds block to a uniform.
  38295. * @param blockName Name of the block to bind.
  38296. * @param index Index to bind.
  38297. */
  38298. bindUniformBlock(blockName: string, index: number): void;
  38299. /**
  38300. * Sets an interger value on a uniform variable.
  38301. * @param uniformName Name of the variable.
  38302. * @param value Value to be set.
  38303. * @returns this effect.
  38304. */
  38305. setInt(uniformName: string, value: number): Effect;
  38306. /**
  38307. * Sets an int array on a uniform variable.
  38308. * @param uniformName Name of the variable.
  38309. * @param array array to be set.
  38310. * @returns this effect.
  38311. */
  38312. setIntArray(uniformName: string, array: Int32Array): Effect;
  38313. /**
  38314. * 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)
  38315. * @param uniformName Name of the variable.
  38316. * @param array array to be set.
  38317. * @returns this effect.
  38318. */
  38319. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38320. /**
  38321. * 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)
  38322. * @param uniformName Name of the variable.
  38323. * @param array array to be set.
  38324. * @returns this effect.
  38325. */
  38326. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38327. /**
  38328. * 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)
  38329. * @param uniformName Name of the variable.
  38330. * @param array array to be set.
  38331. * @returns this effect.
  38332. */
  38333. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38334. /**
  38335. * Sets an float array on a uniform variable.
  38336. * @param uniformName Name of the variable.
  38337. * @param array array to be set.
  38338. * @returns this effect.
  38339. */
  38340. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38341. /**
  38342. * 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)
  38343. * @param uniformName Name of the variable.
  38344. * @param array array to be set.
  38345. * @returns this effect.
  38346. */
  38347. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38348. /**
  38349. * 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)
  38350. * @param uniformName Name of the variable.
  38351. * @param array array to be set.
  38352. * @returns this effect.
  38353. */
  38354. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38355. /**
  38356. * 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)
  38357. * @param uniformName Name of the variable.
  38358. * @param array array to be set.
  38359. * @returns this effect.
  38360. */
  38361. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38362. /**
  38363. * Sets an array on a uniform variable.
  38364. * @param uniformName Name of the variable.
  38365. * @param array array to be set.
  38366. * @returns this effect.
  38367. */
  38368. setArray(uniformName: string, array: number[]): Effect;
  38369. /**
  38370. * 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)
  38371. * @param uniformName Name of the variable.
  38372. * @param array array to be set.
  38373. * @returns this effect.
  38374. */
  38375. setArray2(uniformName: string, array: number[]): Effect;
  38376. /**
  38377. * 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)
  38378. * @param uniformName Name of the variable.
  38379. * @param array array to be set.
  38380. * @returns this effect.
  38381. */
  38382. setArray3(uniformName: string, array: number[]): Effect;
  38383. /**
  38384. * 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)
  38385. * @param uniformName Name of the variable.
  38386. * @param array array to be set.
  38387. * @returns this effect.
  38388. */
  38389. setArray4(uniformName: string, array: number[]): Effect;
  38390. /**
  38391. * Sets matrices on a uniform variable.
  38392. * @param uniformName Name of the variable.
  38393. * @param matrices matrices to be set.
  38394. * @returns this effect.
  38395. */
  38396. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38397. /**
  38398. * Sets matrix on a uniform variable.
  38399. * @param uniformName Name of the variable.
  38400. * @param matrix matrix to be set.
  38401. * @returns this effect.
  38402. */
  38403. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38404. /**
  38405. * 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)
  38406. * @param uniformName Name of the variable.
  38407. * @param matrix matrix to be set.
  38408. * @returns this effect.
  38409. */
  38410. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38411. /**
  38412. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38413. * @param uniformName Name of the variable.
  38414. * @param matrix matrix to be set.
  38415. * @returns this effect.
  38416. */
  38417. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38418. /**
  38419. * Sets a float on a uniform variable.
  38420. * @param uniformName Name of the variable.
  38421. * @param value value to be set.
  38422. * @returns this effect.
  38423. */
  38424. setFloat(uniformName: string, value: number): Effect;
  38425. /**
  38426. * Sets a boolean on a uniform variable.
  38427. * @param uniformName Name of the variable.
  38428. * @param bool value to be set.
  38429. * @returns this effect.
  38430. */
  38431. setBool(uniformName: string, bool: boolean): Effect;
  38432. /**
  38433. * Sets a Vector2 on a uniform variable.
  38434. * @param uniformName Name of the variable.
  38435. * @param vector2 vector2 to be set.
  38436. * @returns this effect.
  38437. */
  38438. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38439. /**
  38440. * Sets a float2 on a uniform variable.
  38441. * @param uniformName Name of the variable.
  38442. * @param x First float in float2.
  38443. * @param y Second float in float2.
  38444. * @returns this effect.
  38445. */
  38446. setFloat2(uniformName: string, x: number, y: number): Effect;
  38447. /**
  38448. * Sets a Vector3 on a uniform variable.
  38449. * @param uniformName Name of the variable.
  38450. * @param vector3 Value to be set.
  38451. * @returns this effect.
  38452. */
  38453. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38454. /**
  38455. * Sets a float3 on a uniform variable.
  38456. * @param uniformName Name of the variable.
  38457. * @param x First float in float3.
  38458. * @param y Second float in float3.
  38459. * @param z Third float in float3.
  38460. * @returns this effect.
  38461. */
  38462. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38463. /**
  38464. * Sets a Vector4 on a uniform variable.
  38465. * @param uniformName Name of the variable.
  38466. * @param vector4 Value to be set.
  38467. * @returns this effect.
  38468. */
  38469. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38470. /**
  38471. * Sets a float4 on a uniform variable.
  38472. * @param uniformName Name of the variable.
  38473. * @param x First float in float4.
  38474. * @param y Second float in float4.
  38475. * @param z Third float in float4.
  38476. * @param w Fourth float in float4.
  38477. * @returns this effect.
  38478. */
  38479. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38480. /**
  38481. * Sets a Color3 on a uniform variable.
  38482. * @param uniformName Name of the variable.
  38483. * @param color3 Value to be set.
  38484. * @returns this effect.
  38485. */
  38486. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38487. /**
  38488. * Sets a Color4 on a uniform variable.
  38489. * @param uniformName Name of the variable.
  38490. * @param color3 Value to be set.
  38491. * @param alpha Alpha value to be set.
  38492. * @returns this effect.
  38493. */
  38494. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38495. /**
  38496. * Sets a Color4 on a uniform variable
  38497. * @param uniformName defines the name of the variable
  38498. * @param color4 defines the value to be set
  38499. * @returns this effect.
  38500. */
  38501. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38502. /** Release all associated resources */
  38503. dispose(): void;
  38504. /**
  38505. * This function will add a new shader to the shader store
  38506. * @param name the name of the shader
  38507. * @param pixelShader optional pixel shader content
  38508. * @param vertexShader optional vertex shader content
  38509. */
  38510. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38511. /**
  38512. * Store of each shader (The can be looked up using effect.key)
  38513. */
  38514. static ShadersStore: {
  38515. [key: string]: string;
  38516. };
  38517. /**
  38518. * Store of each included file for a shader (The can be looked up using effect.key)
  38519. */
  38520. static IncludesShadersStore: {
  38521. [key: string]: string;
  38522. };
  38523. /**
  38524. * Resets the cache of effects.
  38525. */
  38526. static ResetCache(): void;
  38527. }
  38528. }
  38529. declare module BABYLON {
  38530. /**
  38531. * Interface used to describe the capabilities of the engine relatively to the current browser
  38532. */
  38533. export interface EngineCapabilities {
  38534. /** Maximum textures units per fragment shader */
  38535. maxTexturesImageUnits: number;
  38536. /** Maximum texture units per vertex shader */
  38537. maxVertexTextureImageUnits: number;
  38538. /** Maximum textures units in the entire pipeline */
  38539. maxCombinedTexturesImageUnits: number;
  38540. /** Maximum texture size */
  38541. maxTextureSize: number;
  38542. /** Maximum texture samples */
  38543. maxSamples?: number;
  38544. /** Maximum cube texture size */
  38545. maxCubemapTextureSize: number;
  38546. /** Maximum render texture size */
  38547. maxRenderTextureSize: number;
  38548. /** Maximum number of vertex attributes */
  38549. maxVertexAttribs: number;
  38550. /** Maximum number of varyings */
  38551. maxVaryingVectors: number;
  38552. /** Maximum number of uniforms per vertex shader */
  38553. maxVertexUniformVectors: number;
  38554. /** Maximum number of uniforms per fragment shader */
  38555. maxFragmentUniformVectors: number;
  38556. /** Defines if standard derivates (dx/dy) are supported */
  38557. standardDerivatives: boolean;
  38558. /** Defines if s3tc texture compression is supported */
  38559. s3tc?: WEBGL_compressed_texture_s3tc;
  38560. /** Defines if pvrtc texture compression is supported */
  38561. pvrtc: any;
  38562. /** Defines if etc1 texture compression is supported */
  38563. etc1: any;
  38564. /** Defines if etc2 texture compression is supported */
  38565. etc2: any;
  38566. /** Defines if astc texture compression is supported */
  38567. astc: any;
  38568. /** Defines if bptc texture compression is supported */
  38569. bptc: any;
  38570. /** Defines if float textures are supported */
  38571. textureFloat: boolean;
  38572. /** Defines if vertex array objects are supported */
  38573. vertexArrayObject: boolean;
  38574. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38575. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38576. /** Gets the maximum level of anisotropy supported */
  38577. maxAnisotropy: number;
  38578. /** Defines if instancing is supported */
  38579. instancedArrays: boolean;
  38580. /** Defines if 32 bits indices are supported */
  38581. uintIndices: boolean;
  38582. /** Defines if high precision shaders are supported */
  38583. highPrecisionShaderSupported: boolean;
  38584. /** Defines if depth reading in the fragment shader is supported */
  38585. fragmentDepthSupported: boolean;
  38586. /** Defines if float texture linear filtering is supported*/
  38587. textureFloatLinearFiltering: boolean;
  38588. /** Defines if rendering to float textures is supported */
  38589. textureFloatRender: boolean;
  38590. /** Defines if half float textures are supported*/
  38591. textureHalfFloat: boolean;
  38592. /** Defines if half float texture linear filtering is supported*/
  38593. textureHalfFloatLinearFiltering: boolean;
  38594. /** Defines if rendering to half float textures is supported */
  38595. textureHalfFloatRender: boolean;
  38596. /** Defines if textureLOD shader command is supported */
  38597. textureLOD: boolean;
  38598. /** Defines if draw buffers extension is supported */
  38599. drawBuffersExtension: boolean;
  38600. /** Defines if depth textures are supported */
  38601. depthTextureExtension: boolean;
  38602. /** Defines if float color buffer are supported */
  38603. colorBufferFloat: boolean;
  38604. /** Gets disjoint timer query extension (null if not supported) */
  38605. timerQuery?: EXT_disjoint_timer_query;
  38606. /** Defines if timestamp can be used with timer query */
  38607. canUseTimestampForTimerQuery: boolean;
  38608. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38609. multiview?: any;
  38610. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38611. oculusMultiview?: any;
  38612. /** Function used to let the system compiles shaders in background */
  38613. parallelShaderCompile?: {
  38614. COMPLETION_STATUS_KHR: number;
  38615. };
  38616. /** Max number of texture samples for MSAA */
  38617. maxMSAASamples: number;
  38618. /** Defines if the blend min max extension is supported */
  38619. blendMinMax: boolean;
  38620. }
  38621. }
  38622. declare module BABYLON {
  38623. /**
  38624. * @hidden
  38625. **/
  38626. export class DepthCullingState {
  38627. private _isDepthTestDirty;
  38628. private _isDepthMaskDirty;
  38629. private _isDepthFuncDirty;
  38630. private _isCullFaceDirty;
  38631. private _isCullDirty;
  38632. private _isZOffsetDirty;
  38633. private _isFrontFaceDirty;
  38634. private _depthTest;
  38635. private _depthMask;
  38636. private _depthFunc;
  38637. private _cull;
  38638. private _cullFace;
  38639. private _zOffset;
  38640. private _frontFace;
  38641. /**
  38642. * Initializes the state.
  38643. */
  38644. constructor();
  38645. get isDirty(): boolean;
  38646. get zOffset(): number;
  38647. set zOffset(value: number);
  38648. get cullFace(): Nullable<number>;
  38649. set cullFace(value: Nullable<number>);
  38650. get cull(): Nullable<boolean>;
  38651. set cull(value: Nullable<boolean>);
  38652. get depthFunc(): Nullable<number>;
  38653. set depthFunc(value: Nullable<number>);
  38654. get depthMask(): boolean;
  38655. set depthMask(value: boolean);
  38656. get depthTest(): boolean;
  38657. set depthTest(value: boolean);
  38658. get frontFace(): Nullable<number>;
  38659. set frontFace(value: Nullable<number>);
  38660. reset(): void;
  38661. apply(gl: WebGLRenderingContext): void;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * @hidden
  38667. **/
  38668. export class StencilState {
  38669. /** 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 */
  38670. static readonly ALWAYS: number;
  38671. /** Passed to stencilOperation to specify that stencil value must be kept */
  38672. static readonly KEEP: number;
  38673. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38674. static readonly REPLACE: number;
  38675. private _isStencilTestDirty;
  38676. private _isStencilMaskDirty;
  38677. private _isStencilFuncDirty;
  38678. private _isStencilOpDirty;
  38679. private _stencilTest;
  38680. private _stencilMask;
  38681. private _stencilFunc;
  38682. private _stencilFuncRef;
  38683. private _stencilFuncMask;
  38684. private _stencilOpStencilFail;
  38685. private _stencilOpDepthFail;
  38686. private _stencilOpStencilDepthPass;
  38687. get isDirty(): boolean;
  38688. get stencilFunc(): number;
  38689. set stencilFunc(value: number);
  38690. get stencilFuncRef(): number;
  38691. set stencilFuncRef(value: number);
  38692. get stencilFuncMask(): number;
  38693. set stencilFuncMask(value: number);
  38694. get stencilOpStencilFail(): number;
  38695. set stencilOpStencilFail(value: number);
  38696. get stencilOpDepthFail(): number;
  38697. set stencilOpDepthFail(value: number);
  38698. get stencilOpStencilDepthPass(): number;
  38699. set stencilOpStencilDepthPass(value: number);
  38700. get stencilMask(): number;
  38701. set stencilMask(value: number);
  38702. get stencilTest(): boolean;
  38703. set stencilTest(value: boolean);
  38704. constructor();
  38705. reset(): void;
  38706. apply(gl: WebGLRenderingContext): void;
  38707. }
  38708. }
  38709. declare module BABYLON {
  38710. /**
  38711. * @hidden
  38712. **/
  38713. export class AlphaState {
  38714. private _isAlphaBlendDirty;
  38715. private _isBlendFunctionParametersDirty;
  38716. private _isBlendEquationParametersDirty;
  38717. private _isBlendConstantsDirty;
  38718. private _alphaBlend;
  38719. private _blendFunctionParameters;
  38720. private _blendEquationParameters;
  38721. private _blendConstants;
  38722. /**
  38723. * Initializes the state.
  38724. */
  38725. constructor();
  38726. get isDirty(): boolean;
  38727. get alphaBlend(): boolean;
  38728. set alphaBlend(value: boolean);
  38729. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38730. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38731. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38732. reset(): void;
  38733. apply(gl: WebGLRenderingContext): void;
  38734. }
  38735. }
  38736. declare module BABYLON {
  38737. /** @hidden */
  38738. export class WebGLShaderProcessor implements IShaderProcessor {
  38739. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38740. }
  38741. }
  38742. declare module BABYLON {
  38743. /** @hidden */
  38744. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38745. attributeProcessor(attribute: string): string;
  38746. varyingProcessor(varying: string, isFragment: boolean): string;
  38747. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38748. }
  38749. }
  38750. declare module BABYLON {
  38751. /**
  38752. * Interface for attribute information associated with buffer instanciation
  38753. */
  38754. export interface InstancingAttributeInfo {
  38755. /**
  38756. * Name of the GLSL attribute
  38757. * if attribute index is not specified, this is used to retrieve the index from the effect
  38758. */
  38759. attributeName: string;
  38760. /**
  38761. * Index/offset of the attribute in the vertex shader
  38762. * if not specified, this will be computes from the name.
  38763. */
  38764. index?: number;
  38765. /**
  38766. * size of the attribute, 1, 2, 3 or 4
  38767. */
  38768. attributeSize: number;
  38769. /**
  38770. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38771. */
  38772. offset: number;
  38773. /**
  38774. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38775. * default to 1
  38776. */
  38777. divisor?: number;
  38778. /**
  38779. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38780. * default is FLOAT
  38781. */
  38782. attributeType?: number;
  38783. /**
  38784. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38785. */
  38786. normalized?: boolean;
  38787. }
  38788. }
  38789. declare module BABYLON {
  38790. interface ThinEngine {
  38791. /**
  38792. * Update a video texture
  38793. * @param texture defines the texture to update
  38794. * @param video defines the video element to use
  38795. * @param invertY defines if data must be stored with Y axis inverted
  38796. */
  38797. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38798. }
  38799. }
  38800. declare module BABYLON {
  38801. interface ThinEngine {
  38802. /**
  38803. * Creates a dynamic texture
  38804. * @param width defines the width of the texture
  38805. * @param height defines the height of the texture
  38806. * @param generateMipMaps defines if the engine should generate the mip levels
  38807. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38808. * @returns the dynamic texture inside an InternalTexture
  38809. */
  38810. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38811. /**
  38812. * Update the content of a dynamic texture
  38813. * @param texture defines the texture to update
  38814. * @param source defines the source containing the data
  38815. * @param invertY defines if data must be stored with Y axis inverted
  38816. * @param premulAlpha defines if alpha is stored as premultiplied
  38817. * @param format defines the format of the data
  38818. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38819. */
  38820. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38821. }
  38822. }
  38823. declare module BABYLON {
  38824. /**
  38825. * Settings for finer control over video usage
  38826. */
  38827. export interface VideoTextureSettings {
  38828. /**
  38829. * Applies `autoplay` to video, if specified
  38830. */
  38831. autoPlay?: boolean;
  38832. /**
  38833. * Applies `muted` to video, if specified
  38834. */
  38835. muted?: boolean;
  38836. /**
  38837. * Applies `loop` to video, if specified
  38838. */
  38839. loop?: boolean;
  38840. /**
  38841. * Automatically updates internal texture from video at every frame in the render loop
  38842. */
  38843. autoUpdateTexture: boolean;
  38844. /**
  38845. * Image src displayed during the video loading or until the user interacts with the video.
  38846. */
  38847. poster?: string;
  38848. }
  38849. /**
  38850. * If you want to display a video in your scene, this is the special texture for that.
  38851. * This special texture works similar to other textures, with the exception of a few parameters.
  38852. * @see https://doc.babylonjs.com/how_to/video_texture
  38853. */
  38854. export class VideoTexture extends Texture {
  38855. /**
  38856. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38857. */
  38858. readonly autoUpdateTexture: boolean;
  38859. /**
  38860. * The video instance used by the texture internally
  38861. */
  38862. readonly video: HTMLVideoElement;
  38863. private _onUserActionRequestedObservable;
  38864. /**
  38865. * Event triggerd when a dom action is required by the user to play the video.
  38866. * This happens due to recent changes in browser policies preventing video to auto start.
  38867. */
  38868. get onUserActionRequestedObservable(): Observable<Texture>;
  38869. private _generateMipMaps;
  38870. private _stillImageCaptured;
  38871. private _displayingPosterTexture;
  38872. private _settings;
  38873. private _createInternalTextureOnEvent;
  38874. private _frameId;
  38875. private _currentSrc;
  38876. /**
  38877. * Creates a video texture.
  38878. * If you want to display a video in your scene, this is the special texture for that.
  38879. * This special texture works similar to other textures, with the exception of a few parameters.
  38880. * @see https://doc.babylonjs.com/how_to/video_texture
  38881. * @param name optional name, will detect from video source, if not defined
  38882. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38883. * @param scene is obviously the current scene.
  38884. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38885. * @param invertY is false by default but can be used to invert video on Y axis
  38886. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38887. * @param settings allows finer control over video usage
  38888. */
  38889. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38890. private _getName;
  38891. private _getVideo;
  38892. private _createInternalTexture;
  38893. private reset;
  38894. /**
  38895. * @hidden Internal method to initiate `update`.
  38896. */
  38897. _rebuild(): void;
  38898. /**
  38899. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38900. */
  38901. update(): void;
  38902. /**
  38903. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38904. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38905. */
  38906. updateTexture(isVisible: boolean): void;
  38907. protected _updateInternalTexture: () => void;
  38908. /**
  38909. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38910. * @param url New url.
  38911. */
  38912. updateURL(url: string): void;
  38913. /**
  38914. * Clones the texture.
  38915. * @returns the cloned texture
  38916. */
  38917. clone(): VideoTexture;
  38918. /**
  38919. * Dispose the texture and release its associated resources.
  38920. */
  38921. dispose(): void;
  38922. /**
  38923. * Creates a video texture straight from a stream.
  38924. * @param scene Define the scene the texture should be created in
  38925. * @param stream Define the stream the texture should be created from
  38926. * @returns The created video texture as a promise
  38927. */
  38928. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38929. /**
  38930. * Creates a video texture straight from your WebCam video feed.
  38931. * @param scene Define the scene the texture should be created in
  38932. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38933. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38934. * @returns The created video texture as a promise
  38935. */
  38936. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38937. minWidth: number;
  38938. maxWidth: number;
  38939. minHeight: number;
  38940. maxHeight: number;
  38941. deviceId: string;
  38942. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38943. /**
  38944. * Creates a video texture straight from your WebCam video feed.
  38945. * @param scene Define the scene the texture should be created in
  38946. * @param onReady Define a callback to triggered once the texture will be ready
  38947. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38948. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38949. */
  38950. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38951. minWidth: number;
  38952. maxWidth: number;
  38953. minHeight: number;
  38954. maxHeight: number;
  38955. deviceId: string;
  38956. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38957. }
  38958. }
  38959. declare module BABYLON {
  38960. /**
  38961. * Defines the interface used by objects working like Scene
  38962. * @hidden
  38963. */
  38964. export interface ISceneLike {
  38965. _addPendingData(data: any): void;
  38966. _removePendingData(data: any): void;
  38967. offlineProvider: IOfflineProvider;
  38968. }
  38969. /**
  38970. * Information about the current host
  38971. */
  38972. export interface HostInformation {
  38973. /**
  38974. * Defines if the current host is a mobile
  38975. */
  38976. isMobile: boolean;
  38977. }
  38978. /** Interface defining initialization parameters for Engine class */
  38979. export interface EngineOptions extends WebGLContextAttributes {
  38980. /**
  38981. * Defines if the engine should no exceed a specified device ratio
  38982. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38983. */
  38984. limitDeviceRatio?: number;
  38985. /**
  38986. * Defines if webvr should be enabled automatically
  38987. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38988. */
  38989. autoEnableWebVR?: boolean;
  38990. /**
  38991. * Defines if webgl2 should be turned off even if supported
  38992. * @see https://doc.babylonjs.com/features/webgl2
  38993. */
  38994. disableWebGL2Support?: boolean;
  38995. /**
  38996. * Defines if webaudio should be initialized as well
  38997. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38998. */
  38999. audioEngine?: boolean;
  39000. /**
  39001. * Defines if animations should run using a deterministic lock step
  39002. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39003. */
  39004. deterministicLockstep?: boolean;
  39005. /** Defines the maximum steps to use with deterministic lock step mode */
  39006. lockstepMaxSteps?: number;
  39007. /** Defines the seconds between each deterministic lock step */
  39008. timeStep?: number;
  39009. /**
  39010. * Defines that engine should ignore context lost events
  39011. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39012. */
  39013. doNotHandleContextLost?: boolean;
  39014. /**
  39015. * Defines that engine should ignore modifying touch action attribute and style
  39016. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39017. */
  39018. doNotHandleTouchAction?: boolean;
  39019. /**
  39020. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39021. */
  39022. useHighPrecisionFloats?: boolean;
  39023. /**
  39024. * Make the canvas XR Compatible for XR sessions
  39025. */
  39026. xrCompatible?: boolean;
  39027. /**
  39028. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39029. */
  39030. useHighPrecisionMatrix?: boolean;
  39031. /**
  39032. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39033. */
  39034. failIfMajorPerformanceCaveat?: boolean;
  39035. }
  39036. /**
  39037. * The base engine class (root of all engines)
  39038. */
  39039. export class ThinEngine {
  39040. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39041. static ExceptionList: ({
  39042. key: string;
  39043. capture: string;
  39044. captureConstraint: number;
  39045. targets: string[];
  39046. } | {
  39047. key: string;
  39048. capture: null;
  39049. captureConstraint: null;
  39050. targets: string[];
  39051. })[];
  39052. /** @hidden */
  39053. static _TextureLoaders: IInternalTextureLoader[];
  39054. /**
  39055. * Returns the current npm package of the sdk
  39056. */
  39057. static get NpmPackage(): string;
  39058. /**
  39059. * Returns the current version of the framework
  39060. */
  39061. static get Version(): string;
  39062. /**
  39063. * Returns a string describing the current engine
  39064. */
  39065. get description(): string;
  39066. /**
  39067. * Gets or sets the epsilon value used by collision engine
  39068. */
  39069. static CollisionsEpsilon: number;
  39070. /**
  39071. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39072. */
  39073. static get ShadersRepository(): string;
  39074. static set ShadersRepository(value: string);
  39075. /** @hidden */
  39076. _shaderProcessor: IShaderProcessor;
  39077. /**
  39078. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39079. */
  39080. forcePOTTextures: boolean;
  39081. /**
  39082. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39083. */
  39084. isFullscreen: boolean;
  39085. /**
  39086. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39087. */
  39088. cullBackFaces: boolean;
  39089. /**
  39090. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39091. */
  39092. renderEvenInBackground: boolean;
  39093. /**
  39094. * Gets or sets a boolean indicating that cache can be kept between frames
  39095. */
  39096. preventCacheWipeBetweenFrames: boolean;
  39097. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39098. validateShaderPrograms: boolean;
  39099. /**
  39100. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39101. * This can provide greater z depth for distant objects.
  39102. */
  39103. useReverseDepthBuffer: boolean;
  39104. /**
  39105. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39106. */
  39107. disableUniformBuffers: boolean;
  39108. /** @hidden */
  39109. _uniformBuffers: UniformBuffer[];
  39110. /**
  39111. * Gets a boolean indicating that the engine supports uniform buffers
  39112. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39113. */
  39114. get supportsUniformBuffers(): boolean;
  39115. /** @hidden */
  39116. _gl: WebGLRenderingContext;
  39117. /** @hidden */
  39118. _webGLVersion: number;
  39119. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39120. protected _windowIsBackground: boolean;
  39121. protected _creationOptions: EngineOptions;
  39122. protected _highPrecisionShadersAllowed: boolean;
  39123. /** @hidden */
  39124. get _shouldUseHighPrecisionShader(): boolean;
  39125. /**
  39126. * Gets a boolean indicating that only power of 2 textures are supported
  39127. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39128. */
  39129. get needPOTTextures(): boolean;
  39130. /** @hidden */
  39131. _badOS: boolean;
  39132. /** @hidden */
  39133. _badDesktopOS: boolean;
  39134. private _hardwareScalingLevel;
  39135. /** @hidden */
  39136. _caps: EngineCapabilities;
  39137. private _isStencilEnable;
  39138. private _glVersion;
  39139. private _glRenderer;
  39140. private _glVendor;
  39141. /** @hidden */
  39142. _videoTextureSupported: boolean;
  39143. protected _renderingQueueLaunched: boolean;
  39144. protected _activeRenderLoops: (() => void)[];
  39145. /**
  39146. * Observable signaled when a context lost event is raised
  39147. */
  39148. onContextLostObservable: Observable<ThinEngine>;
  39149. /**
  39150. * Observable signaled when a context restored event is raised
  39151. */
  39152. onContextRestoredObservable: Observable<ThinEngine>;
  39153. private _onContextLost;
  39154. private _onContextRestored;
  39155. protected _contextWasLost: boolean;
  39156. /** @hidden */
  39157. _doNotHandleContextLost: boolean;
  39158. /**
  39159. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39160. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39161. */
  39162. get doNotHandleContextLost(): boolean;
  39163. set doNotHandleContextLost(value: boolean);
  39164. /**
  39165. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39166. */
  39167. disableVertexArrayObjects: boolean;
  39168. /** @hidden */
  39169. protected _colorWrite: boolean;
  39170. /** @hidden */
  39171. protected _colorWriteChanged: boolean;
  39172. /** @hidden */
  39173. protected _depthCullingState: DepthCullingState;
  39174. /** @hidden */
  39175. protected _stencilState: StencilState;
  39176. /** @hidden */
  39177. _alphaState: AlphaState;
  39178. /** @hidden */
  39179. _alphaMode: number;
  39180. /** @hidden */
  39181. _alphaEquation: number;
  39182. /** @hidden */
  39183. _internalTexturesCache: InternalTexture[];
  39184. /** @hidden */
  39185. protected _activeChannel: number;
  39186. private _currentTextureChannel;
  39187. /** @hidden */
  39188. protected _boundTexturesCache: {
  39189. [key: string]: Nullable<InternalTexture>;
  39190. };
  39191. /** @hidden */
  39192. protected _currentEffect: Nullable<Effect>;
  39193. /** @hidden */
  39194. protected _currentProgram: Nullable<WebGLProgram>;
  39195. private _compiledEffects;
  39196. private _vertexAttribArraysEnabled;
  39197. /** @hidden */
  39198. protected _cachedViewport: Nullable<IViewportLike>;
  39199. private _cachedVertexArrayObject;
  39200. /** @hidden */
  39201. protected _cachedVertexBuffers: any;
  39202. /** @hidden */
  39203. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39204. /** @hidden */
  39205. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39206. /** @hidden */
  39207. _currentRenderTarget: Nullable<InternalTexture>;
  39208. private _uintIndicesCurrentlySet;
  39209. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39210. /** @hidden */
  39211. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39212. /** @hidden */
  39213. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39214. private _currentBufferPointers;
  39215. private _currentInstanceLocations;
  39216. private _currentInstanceBuffers;
  39217. private _textureUnits;
  39218. /** @hidden */
  39219. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39220. /** @hidden */
  39221. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39222. /** @hidden */
  39223. _boundRenderFunction: any;
  39224. private _vaoRecordInProgress;
  39225. private _mustWipeVertexAttributes;
  39226. private _emptyTexture;
  39227. private _emptyCubeTexture;
  39228. private _emptyTexture3D;
  39229. private _emptyTexture2DArray;
  39230. /** @hidden */
  39231. _frameHandler: number;
  39232. private _nextFreeTextureSlots;
  39233. private _maxSimultaneousTextures;
  39234. private _activeRequests;
  39235. /** @hidden */
  39236. _transformTextureUrl: Nullable<(url: string) => string>;
  39237. /**
  39238. * Gets information about the current host
  39239. */
  39240. hostInformation: HostInformation;
  39241. protected get _supportsHardwareTextureRescaling(): boolean;
  39242. private _framebufferDimensionsObject;
  39243. /**
  39244. * sets the object from which width and height will be taken from when getting render width and height
  39245. * Will fallback to the gl object
  39246. * @param dimensions the framebuffer width and height that will be used.
  39247. */
  39248. set framebufferDimensionsObject(dimensions: Nullable<{
  39249. framebufferWidth: number;
  39250. framebufferHeight: number;
  39251. }>);
  39252. /**
  39253. * Gets the current viewport
  39254. */
  39255. get currentViewport(): Nullable<IViewportLike>;
  39256. /**
  39257. * Gets the default empty texture
  39258. */
  39259. get emptyTexture(): InternalTexture;
  39260. /**
  39261. * Gets the default empty 3D texture
  39262. */
  39263. get emptyTexture3D(): InternalTexture;
  39264. /**
  39265. * Gets the default empty 2D array texture
  39266. */
  39267. get emptyTexture2DArray(): InternalTexture;
  39268. /**
  39269. * Gets the default empty cube texture
  39270. */
  39271. get emptyCubeTexture(): InternalTexture;
  39272. /**
  39273. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39274. */
  39275. readonly premultipliedAlpha: boolean;
  39276. /**
  39277. * Observable event triggered before each texture is initialized
  39278. */
  39279. onBeforeTextureInitObservable: Observable<Texture>;
  39280. /**
  39281. * Creates a new engine
  39282. * @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
  39283. * @param antialias defines enable antialiasing (default: false)
  39284. * @param options defines further options to be sent to the getContext() function
  39285. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39286. */
  39287. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39288. private _rebuildInternalTextures;
  39289. private _rebuildEffects;
  39290. /**
  39291. * Gets a boolean indicating if all created effects are ready
  39292. * @returns true if all effects are ready
  39293. */
  39294. areAllEffectsReady(): boolean;
  39295. protected _rebuildBuffers(): void;
  39296. protected _initGLContext(): void;
  39297. /**
  39298. * Gets version of the current webGL context
  39299. */
  39300. get webGLVersion(): number;
  39301. /**
  39302. * Gets a string identifying the name of the class
  39303. * @returns "Engine" string
  39304. */
  39305. getClassName(): string;
  39306. /**
  39307. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39308. */
  39309. get isStencilEnable(): boolean;
  39310. /** @hidden */
  39311. _prepareWorkingCanvas(): void;
  39312. /**
  39313. * Reset the texture cache to empty state
  39314. */
  39315. resetTextureCache(): void;
  39316. /**
  39317. * Gets an object containing information about the current webGL context
  39318. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39319. */
  39320. getGlInfo(): {
  39321. vendor: string;
  39322. renderer: string;
  39323. version: string;
  39324. };
  39325. /**
  39326. * Defines the hardware scaling level.
  39327. * By default the hardware scaling level is computed from the window device ratio.
  39328. * 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.
  39329. * @param level defines the level to use
  39330. */
  39331. setHardwareScalingLevel(level: number): void;
  39332. /**
  39333. * Gets the current hardware scaling level.
  39334. * By default the hardware scaling level is computed from the window device ratio.
  39335. * 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.
  39336. * @returns a number indicating the current hardware scaling level
  39337. */
  39338. getHardwareScalingLevel(): number;
  39339. /**
  39340. * Gets the list of loaded textures
  39341. * @returns an array containing all loaded textures
  39342. */
  39343. getLoadedTexturesCache(): InternalTexture[];
  39344. /**
  39345. * Gets the object containing all engine capabilities
  39346. * @returns the EngineCapabilities object
  39347. */
  39348. getCaps(): EngineCapabilities;
  39349. /**
  39350. * stop executing a render loop function and remove it from the execution array
  39351. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39352. */
  39353. stopRenderLoop(renderFunction?: () => void): void;
  39354. /** @hidden */
  39355. _renderLoop(): void;
  39356. /**
  39357. * Gets the HTML canvas attached with the current webGL context
  39358. * @returns a HTML canvas
  39359. */
  39360. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39361. /**
  39362. * Gets host window
  39363. * @returns the host window object
  39364. */
  39365. getHostWindow(): Nullable<Window>;
  39366. /**
  39367. * Gets the current render width
  39368. * @param useScreen defines if screen size must be used (or the current render target if any)
  39369. * @returns a number defining the current render width
  39370. */
  39371. getRenderWidth(useScreen?: boolean): number;
  39372. /**
  39373. * Gets the current render height
  39374. * @param useScreen defines if screen size must be used (or the current render target if any)
  39375. * @returns a number defining the current render height
  39376. */
  39377. getRenderHeight(useScreen?: boolean): number;
  39378. /**
  39379. * Can be used to override the current requestAnimationFrame requester.
  39380. * @hidden
  39381. */
  39382. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39383. /**
  39384. * Register and execute a render loop. The engine can have more than one render function
  39385. * @param renderFunction defines the function to continuously execute
  39386. */
  39387. runRenderLoop(renderFunction: () => void): void;
  39388. /**
  39389. * Clear the current render buffer or the current render target (if any is set up)
  39390. * @param color defines the color to use
  39391. * @param backBuffer defines if the back buffer must be cleared
  39392. * @param depth defines if the depth buffer must be cleared
  39393. * @param stencil defines if the stencil buffer must be cleared
  39394. */
  39395. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39396. private _viewportCached;
  39397. /** @hidden */
  39398. _viewport(x: number, y: number, width: number, height: number): void;
  39399. /**
  39400. * Set the WebGL's viewport
  39401. * @param viewport defines the viewport element to be used
  39402. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39403. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39404. */
  39405. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39406. /**
  39407. * Begin a new frame
  39408. */
  39409. beginFrame(): void;
  39410. /**
  39411. * Enf the current frame
  39412. */
  39413. endFrame(): void;
  39414. /**
  39415. * Resize the view according to the canvas' size
  39416. */
  39417. resize(): void;
  39418. /**
  39419. * Force a specific size of the canvas
  39420. * @param width defines the new canvas' width
  39421. * @param height defines the new canvas' height
  39422. * @returns true if the size was changed
  39423. */
  39424. setSize(width: number, height: number): boolean;
  39425. /**
  39426. * Binds the frame buffer to the specified texture.
  39427. * @param texture The texture to render to or null for the default canvas
  39428. * @param faceIndex The face of the texture to render to in case of cube texture
  39429. * @param requiredWidth The width of the target to render to
  39430. * @param requiredHeight The height of the target to render to
  39431. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39432. * @param lodLevel defines the lod level to bind to the frame buffer
  39433. * @param layer defines the 2d array index to bind to frame buffer to
  39434. */
  39435. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39436. /** @hidden */
  39437. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39438. /**
  39439. * Unbind the current render target texture from the webGL context
  39440. * @param texture defines the render target texture to unbind
  39441. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39442. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39443. */
  39444. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39445. /**
  39446. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39447. */
  39448. flushFramebuffer(): void;
  39449. /**
  39450. * Unbind the current render target and bind the default framebuffer
  39451. */
  39452. restoreDefaultFramebuffer(): void;
  39453. /** @hidden */
  39454. protected _resetVertexBufferBinding(): void;
  39455. /**
  39456. * Creates a vertex buffer
  39457. * @param data the data for the vertex buffer
  39458. * @returns the new WebGL static buffer
  39459. */
  39460. createVertexBuffer(data: DataArray): DataBuffer;
  39461. private _createVertexBuffer;
  39462. /**
  39463. * Creates a dynamic vertex buffer
  39464. * @param data the data for the dynamic vertex buffer
  39465. * @returns the new WebGL dynamic buffer
  39466. */
  39467. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39468. protected _resetIndexBufferBinding(): void;
  39469. /**
  39470. * Creates a new index buffer
  39471. * @param indices defines the content of the index buffer
  39472. * @param updatable defines if the index buffer must be updatable
  39473. * @returns a new webGL buffer
  39474. */
  39475. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39476. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39477. /**
  39478. * Bind a webGL buffer to the webGL context
  39479. * @param buffer defines the buffer to bind
  39480. */
  39481. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39482. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39483. private bindBuffer;
  39484. /**
  39485. * update the bound buffer with the given data
  39486. * @param data defines the data to update
  39487. */
  39488. updateArrayBuffer(data: Float32Array): void;
  39489. private _vertexAttribPointer;
  39490. /** @hidden */
  39491. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39492. private _bindVertexBuffersAttributes;
  39493. /**
  39494. * Records a vertex array object
  39495. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39496. * @param vertexBuffers defines the list of vertex buffers to store
  39497. * @param indexBuffer defines the index buffer to store
  39498. * @param effect defines the effect to store
  39499. * @returns the new vertex array object
  39500. */
  39501. recordVertexArrayObject(vertexBuffers: {
  39502. [key: string]: VertexBuffer;
  39503. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39504. /**
  39505. * Bind a specific vertex array object
  39506. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39507. * @param vertexArrayObject defines the vertex array object to bind
  39508. * @param indexBuffer defines the index buffer to bind
  39509. */
  39510. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39511. /**
  39512. * Bind webGl buffers directly to the webGL context
  39513. * @param vertexBuffer defines the vertex buffer to bind
  39514. * @param indexBuffer defines the index buffer to bind
  39515. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39516. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39517. * @param effect defines the effect associated with the vertex buffer
  39518. */
  39519. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39520. private _unbindVertexArrayObject;
  39521. /**
  39522. * Bind a list of vertex buffers to the webGL context
  39523. * @param vertexBuffers defines the list of vertex buffers to bind
  39524. * @param indexBuffer defines the index buffer to bind
  39525. * @param effect defines the effect associated with the vertex buffers
  39526. */
  39527. bindBuffers(vertexBuffers: {
  39528. [key: string]: Nullable<VertexBuffer>;
  39529. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39530. /**
  39531. * Unbind all instance attributes
  39532. */
  39533. unbindInstanceAttributes(): void;
  39534. /**
  39535. * Release and free the memory of a vertex array object
  39536. * @param vao defines the vertex array object to delete
  39537. */
  39538. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39539. /** @hidden */
  39540. _releaseBuffer(buffer: DataBuffer): boolean;
  39541. protected _deleteBuffer(buffer: DataBuffer): void;
  39542. /**
  39543. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39544. * @param instancesBuffer defines the webGL buffer to update and bind
  39545. * @param data defines the data to store in the buffer
  39546. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39547. */
  39548. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39549. /**
  39550. * Bind the content of a webGL buffer used with instantiation
  39551. * @param instancesBuffer defines the webGL buffer to bind
  39552. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39553. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39554. */
  39555. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39556. /**
  39557. * Disable the instance attribute corresponding to the name in parameter
  39558. * @param name defines the name of the attribute to disable
  39559. */
  39560. disableInstanceAttributeByName(name: string): void;
  39561. /**
  39562. * Disable the instance attribute corresponding to the location in parameter
  39563. * @param attributeLocation defines the attribute location of the attribute to disable
  39564. */
  39565. disableInstanceAttribute(attributeLocation: number): void;
  39566. /**
  39567. * Disable the attribute corresponding to the location in parameter
  39568. * @param attributeLocation defines the attribute location of the attribute to disable
  39569. */
  39570. disableAttributeByIndex(attributeLocation: number): void;
  39571. /**
  39572. * Send a draw order
  39573. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39574. * @param indexStart defines the starting index
  39575. * @param indexCount defines the number of index to draw
  39576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39577. */
  39578. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39579. /**
  39580. * Draw a list of points
  39581. * @param verticesStart defines the index of first vertex to draw
  39582. * @param verticesCount defines the count of vertices to draw
  39583. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39584. */
  39585. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39586. /**
  39587. * Draw a list of unindexed primitives
  39588. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39589. * @param verticesStart defines the index of first vertex to draw
  39590. * @param verticesCount defines the count of vertices to draw
  39591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39592. */
  39593. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39594. /**
  39595. * Draw a list of indexed primitives
  39596. * @param fillMode defines the primitive to use
  39597. * @param indexStart defines the starting index
  39598. * @param indexCount defines the number of index to draw
  39599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39600. */
  39601. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39602. /**
  39603. * Draw a list of unindexed primitives
  39604. * @param fillMode defines the primitive to use
  39605. * @param verticesStart defines the index of first vertex to draw
  39606. * @param verticesCount defines the count of vertices to draw
  39607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39608. */
  39609. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39610. private _drawMode;
  39611. /** @hidden */
  39612. protected _reportDrawCall(): void;
  39613. /** @hidden */
  39614. _releaseEffect(effect: Effect): void;
  39615. /** @hidden */
  39616. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39617. /**
  39618. * Create a new effect (used to store vertex/fragment shaders)
  39619. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39620. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39621. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39622. * @param samplers defines an array of string used to represent textures
  39623. * @param defines defines the string containing the defines to use to compile the shaders
  39624. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39625. * @param onCompiled defines a function to call when the effect creation is successful
  39626. * @param onError defines a function to call when the effect creation has failed
  39627. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39628. * @returns the new Effect
  39629. */
  39630. 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;
  39631. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39632. private _compileShader;
  39633. private _compileRawShader;
  39634. /** @hidden */
  39635. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39636. /**
  39637. * Directly creates a webGL program
  39638. * @param pipelineContext defines the pipeline context to attach to
  39639. * @param vertexCode defines the vertex shader code to use
  39640. * @param fragmentCode defines the fragment shader code to use
  39641. * @param context defines the webGL context to use (if not set, the current one will be used)
  39642. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39643. * @returns the new webGL program
  39644. */
  39645. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39646. /**
  39647. * Creates a webGL program
  39648. * @param pipelineContext defines the pipeline context to attach to
  39649. * @param vertexCode defines the vertex shader code to use
  39650. * @param fragmentCode defines the fragment shader code to use
  39651. * @param defines defines the string containing the defines to use to compile the shaders
  39652. * @param context defines the webGL context to use (if not set, the current one will be used)
  39653. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39654. * @returns the new webGL program
  39655. */
  39656. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39657. /**
  39658. * Creates a new pipeline context
  39659. * @returns the new pipeline
  39660. */
  39661. createPipelineContext(): IPipelineContext;
  39662. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39663. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39664. /** @hidden */
  39665. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39666. /** @hidden */
  39667. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39668. /** @hidden */
  39669. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39670. /**
  39671. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39672. * @param pipelineContext defines the pipeline context to use
  39673. * @param uniformsNames defines the list of uniform names
  39674. * @returns an array of webGL uniform locations
  39675. */
  39676. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39677. /**
  39678. * Gets the lsit of active attributes for a given webGL program
  39679. * @param pipelineContext defines the pipeline context to use
  39680. * @param attributesNames defines the list of attribute names to get
  39681. * @returns an array of indices indicating the offset of each attribute
  39682. */
  39683. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39684. /**
  39685. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39686. * @param effect defines the effect to activate
  39687. */
  39688. enableEffect(effect: Nullable<Effect>): void;
  39689. /**
  39690. * Set the value of an uniform to a number (int)
  39691. * @param uniform defines the webGL uniform location where to store the value
  39692. * @param value defines the int number to store
  39693. * @returns true if the value was set
  39694. */
  39695. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39696. /**
  39697. * Set the value of an uniform to an array of int32
  39698. * @param uniform defines the webGL uniform location where to store the value
  39699. * @param array defines the array of int32 to store
  39700. * @returns true if the value was set
  39701. */
  39702. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39703. /**
  39704. * Set the value of an uniform to an array of int32 (stored as vec2)
  39705. * @param uniform defines the webGL uniform location where to store the value
  39706. * @param array defines the array of int32 to store
  39707. * @returns true if the value was set
  39708. */
  39709. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39710. /**
  39711. * Set the value of an uniform to an array of int32 (stored as vec3)
  39712. * @param uniform defines the webGL uniform location where to store the value
  39713. * @param array defines the array of int32 to store
  39714. * @returns true if the value was set
  39715. */
  39716. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39717. /**
  39718. * Set the value of an uniform to an array of int32 (stored as vec4)
  39719. * @param uniform defines the webGL uniform location where to store the value
  39720. * @param array defines the array of int32 to store
  39721. * @returns true if the value was set
  39722. */
  39723. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39724. /**
  39725. * Set the value of an uniform to an array of number
  39726. * @param uniform defines the webGL uniform location where to store the value
  39727. * @param array defines the array of number to store
  39728. * @returns true if the value was set
  39729. */
  39730. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39731. /**
  39732. * Set the value of an uniform to an array of number (stored as vec2)
  39733. * @param uniform defines the webGL uniform location where to store the value
  39734. * @param array defines the array of number to store
  39735. * @returns true if the value was set
  39736. */
  39737. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39738. /**
  39739. * Set the value of an uniform to an array of number (stored as vec3)
  39740. * @param uniform defines the webGL uniform location where to store the value
  39741. * @param array defines the array of number to store
  39742. * @returns true if the value was set
  39743. */
  39744. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39745. /**
  39746. * Set the value of an uniform to an array of number (stored as vec4)
  39747. * @param uniform defines the webGL uniform location where to store the value
  39748. * @param array defines the array of number to store
  39749. * @returns true if the value was set
  39750. */
  39751. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39752. /**
  39753. * Set the value of an uniform to an array of float32 (stored as matrices)
  39754. * @param uniform defines the webGL uniform location where to store the value
  39755. * @param matrices defines the array of float32 to store
  39756. * @returns true if the value was set
  39757. */
  39758. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39759. /**
  39760. * Set the value of an uniform to a matrix (3x3)
  39761. * @param uniform defines the webGL uniform location where to store the value
  39762. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39763. * @returns true if the value was set
  39764. */
  39765. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39766. /**
  39767. * Set the value of an uniform to a matrix (2x2)
  39768. * @param uniform defines the webGL uniform location where to store the value
  39769. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39770. * @returns true if the value was set
  39771. */
  39772. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39773. /**
  39774. * Set the value of an uniform to a number (float)
  39775. * @param uniform defines the webGL uniform location where to store the value
  39776. * @param value defines the float number to store
  39777. * @returns true if the value was transfered
  39778. */
  39779. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39780. /**
  39781. * Set the value of an uniform to a vec2
  39782. * @param uniform defines the webGL uniform location where to store the value
  39783. * @param x defines the 1st component of the value
  39784. * @param y defines the 2nd component of the value
  39785. * @returns true if the value was set
  39786. */
  39787. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39788. /**
  39789. * Set the value of an uniform to a vec3
  39790. * @param uniform defines the webGL uniform location where to store the value
  39791. * @param x defines the 1st component of the value
  39792. * @param y defines the 2nd component of the value
  39793. * @param z defines the 3rd component of the value
  39794. * @returns true if the value was set
  39795. */
  39796. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39797. /**
  39798. * Set the value of an uniform to a vec4
  39799. * @param uniform defines the webGL uniform location where to store the value
  39800. * @param x defines the 1st component of the value
  39801. * @param y defines the 2nd component of the value
  39802. * @param z defines the 3rd component of the value
  39803. * @param w defines the 4th component of the value
  39804. * @returns true if the value was set
  39805. */
  39806. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39807. /**
  39808. * Apply all cached states (depth, culling, stencil and alpha)
  39809. */
  39810. applyStates(): void;
  39811. /**
  39812. * Enable or disable color writing
  39813. * @param enable defines the state to set
  39814. */
  39815. setColorWrite(enable: boolean): void;
  39816. /**
  39817. * Gets a boolean indicating if color writing is enabled
  39818. * @returns the current color writing state
  39819. */
  39820. getColorWrite(): boolean;
  39821. /**
  39822. * Gets the depth culling state manager
  39823. */
  39824. get depthCullingState(): DepthCullingState;
  39825. /**
  39826. * Gets the alpha state manager
  39827. */
  39828. get alphaState(): AlphaState;
  39829. /**
  39830. * Gets the stencil state manager
  39831. */
  39832. get stencilState(): StencilState;
  39833. /**
  39834. * Clears the list of texture accessible through engine.
  39835. * This can help preventing texture load conflict due to name collision.
  39836. */
  39837. clearInternalTexturesCache(): void;
  39838. /**
  39839. * Force the entire cache to be cleared
  39840. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39841. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39842. */
  39843. wipeCaches(bruteForce?: boolean): void;
  39844. /** @hidden */
  39845. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39846. min: number;
  39847. mag: number;
  39848. };
  39849. /** @hidden */
  39850. _createTexture(): WebGLTexture;
  39851. /**
  39852. * Usually called from Texture.ts.
  39853. * Passed information to create a WebGLTexture
  39854. * @param url defines a value which contains one of the following:
  39855. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39856. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39857. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39859. * @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)
  39860. * @param scene needed for loading to the correct scene
  39861. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39862. * @param onLoad optional callback to be called upon successful completion
  39863. * @param onError optional callback to be called upon failure
  39864. * @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
  39865. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39866. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39867. * @param forcedExtension defines the extension to use to pick the right loader
  39868. * @param mimeType defines an optional mime type
  39869. * @param loaderOptions options to be passed to the loader
  39870. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39871. */
  39872. 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, loaderOptions?: any): InternalTexture;
  39873. /**
  39874. * Loads an image as an HTMLImageElement.
  39875. * @param input url string, ArrayBuffer, or Blob to load
  39876. * @param onLoad callback called when the image successfully loads
  39877. * @param onError callback called when the image fails to load
  39878. * @param offlineProvider offline provider for caching
  39879. * @param mimeType optional mime type
  39880. * @returns the HTMLImageElement of the loaded image
  39881. * @hidden
  39882. */
  39883. 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>;
  39884. /**
  39885. * @hidden
  39886. */
  39887. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39888. private _unpackFlipYCached;
  39889. /**
  39890. * In case you are sharing the context with other applications, it might
  39891. * be interested to not cache the unpack flip y state to ensure a consistent
  39892. * value would be set.
  39893. */
  39894. enableUnpackFlipYCached: boolean;
  39895. /** @hidden */
  39896. _unpackFlipY(value: boolean): void;
  39897. /** @hidden */
  39898. _getUnpackAlignement(): number;
  39899. private _getTextureTarget;
  39900. /**
  39901. * Update the sampling mode of a given texture
  39902. * @param samplingMode defines the required sampling mode
  39903. * @param texture defines the texture to update
  39904. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39905. */
  39906. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39907. /**
  39908. * Update the sampling mode of a given texture
  39909. * @param texture defines the texture to update
  39910. * @param wrapU defines the texture wrap mode of the u coordinates
  39911. * @param wrapV defines the texture wrap mode of the v coordinates
  39912. * @param wrapR defines the texture wrap mode of the r coordinates
  39913. */
  39914. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39915. /** @hidden */
  39916. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39917. width: number;
  39918. height: number;
  39919. layers?: number;
  39920. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39921. /** @hidden */
  39922. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39923. /** @hidden */
  39924. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39925. /**
  39926. * Update a portion of an internal texture
  39927. * @param texture defines the texture to update
  39928. * @param imageData defines the data to store into the texture
  39929. * @param xOffset defines the x coordinates of the update rectangle
  39930. * @param yOffset defines the y coordinates of the update rectangle
  39931. * @param width defines the width of the update rectangle
  39932. * @param height defines the height of the update rectangle
  39933. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39934. * @param lod defines the lod level to update (0 by default)
  39935. */
  39936. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39937. /** @hidden */
  39938. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39939. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39940. private _prepareWebGLTexture;
  39941. /** @hidden */
  39942. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39943. private _getDepthStencilBuffer;
  39944. /** @hidden */
  39945. _releaseFramebufferObjects(texture: InternalTexture): void;
  39946. /** @hidden */
  39947. _releaseTexture(texture: InternalTexture): void;
  39948. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39949. protected _setProgram(program: WebGLProgram): void;
  39950. protected _boundUniforms: {
  39951. [key: number]: WebGLUniformLocation;
  39952. };
  39953. /**
  39954. * Binds an effect to the webGL context
  39955. * @param effect defines the effect to bind
  39956. */
  39957. bindSamplers(effect: Effect): void;
  39958. private _activateCurrentTexture;
  39959. /** @hidden */
  39960. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39961. /** @hidden */
  39962. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39963. /**
  39964. * Unbind all textures from the webGL context
  39965. */
  39966. unbindAllTextures(): void;
  39967. /**
  39968. * Sets a texture to the according uniform.
  39969. * @param channel The texture channel
  39970. * @param uniform The uniform to set
  39971. * @param texture The texture to apply
  39972. */
  39973. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39974. private _bindSamplerUniformToChannel;
  39975. private _getTextureWrapMode;
  39976. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39977. /**
  39978. * Sets an array of texture to the webGL context
  39979. * @param channel defines the channel where the texture array must be set
  39980. * @param uniform defines the associated uniform location
  39981. * @param textures defines the array of textures to bind
  39982. */
  39983. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39984. /** @hidden */
  39985. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39986. private _setTextureParameterFloat;
  39987. private _setTextureParameterInteger;
  39988. /**
  39989. * Unbind all vertex attributes from the webGL context
  39990. */
  39991. unbindAllAttributes(): void;
  39992. /**
  39993. * 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
  39994. */
  39995. releaseEffects(): void;
  39996. /**
  39997. * Dispose and release all associated resources
  39998. */
  39999. dispose(): void;
  40000. /**
  40001. * Attach a new callback raised when context lost event is fired
  40002. * @param callback defines the callback to call
  40003. */
  40004. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40005. /**
  40006. * Attach a new callback raised when context restored event is fired
  40007. * @param callback defines the callback to call
  40008. */
  40009. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40010. /**
  40011. * Get the current error code of the webGL context
  40012. * @returns the error code
  40013. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40014. */
  40015. getError(): number;
  40016. private _canRenderToFloatFramebuffer;
  40017. private _canRenderToHalfFloatFramebuffer;
  40018. private _canRenderToFramebuffer;
  40019. /** @hidden */
  40020. _getWebGLTextureType(type: number): number;
  40021. /** @hidden */
  40022. _getInternalFormat(format: number): number;
  40023. /** @hidden */
  40024. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40025. /** @hidden */
  40026. _getRGBAMultiSampleBufferFormat(type: number): number;
  40027. /** @hidden */
  40028. _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;
  40029. /**
  40030. * Loads a file from a url
  40031. * @param url url to load
  40032. * @param onSuccess callback called when the file successfully loads
  40033. * @param onProgress callback called while file is loading (if the server supports this mode)
  40034. * @param offlineProvider defines the offline provider for caching
  40035. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40036. * @param onError callback called when the file fails to load
  40037. * @returns a file request object
  40038. * @hidden
  40039. */
  40040. 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;
  40041. /**
  40042. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40043. * @param x defines the x coordinate of the rectangle where pixels must be read
  40044. * @param y defines the y coordinate of the rectangle where pixels must be read
  40045. * @param width defines the width of the rectangle where pixels must be read
  40046. * @param height defines the height of the rectangle where pixels must be read
  40047. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40048. * @returns a Uint8Array containing RGBA colors
  40049. */
  40050. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40051. private static _IsSupported;
  40052. private static _HasMajorPerformanceCaveat;
  40053. /**
  40054. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40055. */
  40056. static get IsSupported(): boolean;
  40057. /**
  40058. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40059. * @returns true if the engine can be created
  40060. * @ignorenaming
  40061. */
  40062. static isSupported(): boolean;
  40063. /**
  40064. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40065. */
  40066. static get HasMajorPerformanceCaveat(): boolean;
  40067. /**
  40068. * Find the next highest power of two.
  40069. * @param x Number to start search from.
  40070. * @return Next highest power of two.
  40071. */
  40072. static CeilingPOT(x: number): number;
  40073. /**
  40074. * Find the next lowest power of two.
  40075. * @param x Number to start search from.
  40076. * @return Next lowest power of two.
  40077. */
  40078. static FloorPOT(x: number): number;
  40079. /**
  40080. * Find the nearest power of two.
  40081. * @param x Number to start search from.
  40082. * @return Next nearest power of two.
  40083. */
  40084. static NearestPOT(x: number): number;
  40085. /**
  40086. * Get the closest exponent of two
  40087. * @param value defines the value to approximate
  40088. * @param max defines the maximum value to return
  40089. * @param mode defines how to define the closest value
  40090. * @returns closest exponent of two of the given value
  40091. */
  40092. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40093. /**
  40094. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40095. * @param func - the function to be called
  40096. * @param requester - the object that will request the next frame. Falls back to window.
  40097. * @returns frame number
  40098. */
  40099. static QueueNewFrame(func: () => void, requester?: any): number;
  40100. /**
  40101. * Gets host document
  40102. * @returns the host document object
  40103. */
  40104. getHostDocument(): Nullable<Document>;
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /**
  40109. * Defines the source of the internal texture
  40110. */
  40111. export enum InternalTextureSource {
  40112. /**
  40113. * The source of the texture data is unknown
  40114. */
  40115. Unknown = 0,
  40116. /**
  40117. * Texture data comes from an URL
  40118. */
  40119. Url = 1,
  40120. /**
  40121. * Texture data is only used for temporary storage
  40122. */
  40123. Temp = 2,
  40124. /**
  40125. * Texture data comes from raw data (ArrayBuffer)
  40126. */
  40127. Raw = 3,
  40128. /**
  40129. * Texture content is dynamic (video or dynamic texture)
  40130. */
  40131. Dynamic = 4,
  40132. /**
  40133. * Texture content is generated by rendering to it
  40134. */
  40135. RenderTarget = 5,
  40136. /**
  40137. * Texture content is part of a multi render target process
  40138. */
  40139. MultiRenderTarget = 6,
  40140. /**
  40141. * Texture data comes from a cube data file
  40142. */
  40143. Cube = 7,
  40144. /**
  40145. * Texture data comes from a raw cube data
  40146. */
  40147. CubeRaw = 8,
  40148. /**
  40149. * Texture data come from a prefiltered cube data file
  40150. */
  40151. CubePrefiltered = 9,
  40152. /**
  40153. * Texture content is raw 3D data
  40154. */
  40155. Raw3D = 10,
  40156. /**
  40157. * Texture content is raw 2D array data
  40158. */
  40159. Raw2DArray = 11,
  40160. /**
  40161. * Texture content is a depth texture
  40162. */
  40163. Depth = 12,
  40164. /**
  40165. * Texture data comes from a raw cube data encoded with RGBD
  40166. */
  40167. CubeRawRGBD = 13
  40168. }
  40169. /**
  40170. * Class used to store data associated with WebGL texture data for the engine
  40171. * This class should not be used directly
  40172. */
  40173. export class InternalTexture {
  40174. /** @hidden */
  40175. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40176. /**
  40177. * Defines if the texture is ready
  40178. */
  40179. isReady: boolean;
  40180. /**
  40181. * Defines if the texture is a cube texture
  40182. */
  40183. isCube: boolean;
  40184. /**
  40185. * Defines if the texture contains 3D data
  40186. */
  40187. is3D: boolean;
  40188. /**
  40189. * Defines if the texture contains 2D array data
  40190. */
  40191. is2DArray: boolean;
  40192. /**
  40193. * Defines if the texture contains multiview data
  40194. */
  40195. isMultiview: boolean;
  40196. /**
  40197. * Gets the URL used to load this texture
  40198. */
  40199. url: string;
  40200. /** @hidden */
  40201. _originalUrl: string;
  40202. /**
  40203. * Gets the sampling mode of the texture
  40204. */
  40205. samplingMode: number;
  40206. /**
  40207. * Gets a boolean indicating if the texture needs mipmaps generation
  40208. */
  40209. generateMipMaps: boolean;
  40210. /**
  40211. * Gets the number of samples used by the texture (WebGL2+ only)
  40212. */
  40213. samples: number;
  40214. /**
  40215. * Gets the type of the texture (int, float...)
  40216. */
  40217. type: number;
  40218. /**
  40219. * Gets the format of the texture (RGB, RGBA...)
  40220. */
  40221. format: number;
  40222. /**
  40223. * Observable called when the texture is loaded
  40224. */
  40225. onLoadedObservable: Observable<InternalTexture>;
  40226. /**
  40227. * Gets the width of the texture
  40228. */
  40229. width: number;
  40230. /**
  40231. * Gets the height of the texture
  40232. */
  40233. height: number;
  40234. /**
  40235. * Gets the depth of the texture
  40236. */
  40237. depth: number;
  40238. /**
  40239. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40240. */
  40241. baseWidth: number;
  40242. /**
  40243. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40244. */
  40245. baseHeight: number;
  40246. /**
  40247. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40248. */
  40249. baseDepth: number;
  40250. /**
  40251. * Gets a boolean indicating if the texture is inverted on Y axis
  40252. */
  40253. invertY: boolean;
  40254. /** @hidden */
  40255. _invertVScale: boolean;
  40256. /** @hidden */
  40257. _associatedChannel: number;
  40258. /** @hidden */
  40259. _source: InternalTextureSource;
  40260. /** @hidden */
  40261. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40262. /** @hidden */
  40263. _bufferView: Nullable<ArrayBufferView>;
  40264. /** @hidden */
  40265. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40266. /** @hidden */
  40267. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40268. /** @hidden */
  40269. _size: number;
  40270. /** @hidden */
  40271. _extension: string;
  40272. /** @hidden */
  40273. _files: Nullable<string[]>;
  40274. /** @hidden */
  40275. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40276. /** @hidden */
  40277. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40278. /** @hidden */
  40279. _framebuffer: Nullable<WebGLFramebuffer>;
  40280. /** @hidden */
  40281. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40282. /** @hidden */
  40283. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40284. /** @hidden */
  40285. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40286. /** @hidden */
  40287. _attachments: Nullable<number[]>;
  40288. /** @hidden */
  40289. _textureArray: Nullable<InternalTexture[]>;
  40290. /** @hidden */
  40291. _cachedCoordinatesMode: Nullable<number>;
  40292. /** @hidden */
  40293. _cachedWrapU: Nullable<number>;
  40294. /** @hidden */
  40295. _cachedWrapV: Nullable<number>;
  40296. /** @hidden */
  40297. _cachedWrapR: Nullable<number>;
  40298. /** @hidden */
  40299. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40300. /** @hidden */
  40301. _isDisabled: boolean;
  40302. /** @hidden */
  40303. _compression: Nullable<string>;
  40304. /** @hidden */
  40305. _generateStencilBuffer: boolean;
  40306. /** @hidden */
  40307. _generateDepthBuffer: boolean;
  40308. /** @hidden */
  40309. _comparisonFunction: number;
  40310. /** @hidden */
  40311. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40312. /** @hidden */
  40313. _lodGenerationScale: number;
  40314. /** @hidden */
  40315. _lodGenerationOffset: number;
  40316. /** @hidden */
  40317. _depthStencilTexture: Nullable<InternalTexture>;
  40318. /** @hidden */
  40319. _colorTextureArray: Nullable<WebGLTexture>;
  40320. /** @hidden */
  40321. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40322. /** @hidden */
  40323. _lodTextureHigh: Nullable<BaseTexture>;
  40324. /** @hidden */
  40325. _lodTextureMid: Nullable<BaseTexture>;
  40326. /** @hidden */
  40327. _lodTextureLow: Nullable<BaseTexture>;
  40328. /** @hidden */
  40329. _isRGBD: boolean;
  40330. /** @hidden */
  40331. _linearSpecularLOD: boolean;
  40332. /** @hidden */
  40333. _irradianceTexture: Nullable<BaseTexture>;
  40334. /** @hidden */
  40335. _webGLTexture: Nullable<WebGLTexture>;
  40336. /** @hidden */
  40337. _references: number;
  40338. /** @hidden */
  40339. _gammaSpace: Nullable<boolean>;
  40340. private _engine;
  40341. /**
  40342. * Gets the Engine the texture belongs to.
  40343. * @returns The babylon engine
  40344. */
  40345. getEngine(): ThinEngine;
  40346. /**
  40347. * Gets the data source type of the texture
  40348. */
  40349. get source(): InternalTextureSource;
  40350. /**
  40351. * Creates a new InternalTexture
  40352. * @param engine defines the engine to use
  40353. * @param source defines the type of data that will be used
  40354. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40355. */
  40356. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40357. /**
  40358. * Increments the number of references (ie. the number of Texture that point to it)
  40359. */
  40360. incrementReferences(): void;
  40361. /**
  40362. * Change the size of the texture (not the size of the content)
  40363. * @param width defines the new width
  40364. * @param height defines the new height
  40365. * @param depth defines the new depth (1 by default)
  40366. */
  40367. updateSize(width: int, height: int, depth?: int): void;
  40368. /** @hidden */
  40369. _rebuild(): void;
  40370. /** @hidden */
  40371. _swapAndDie(target: InternalTexture): void;
  40372. /**
  40373. * Dispose the current allocated resources
  40374. */
  40375. dispose(): void;
  40376. }
  40377. }
  40378. declare module BABYLON {
  40379. /**
  40380. * Interface used to present a loading screen while loading a scene
  40381. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40382. */
  40383. export interface ILoadingScreen {
  40384. /**
  40385. * Function called to display the loading screen
  40386. */
  40387. displayLoadingUI: () => void;
  40388. /**
  40389. * Function called to hide the loading screen
  40390. */
  40391. hideLoadingUI: () => void;
  40392. /**
  40393. * Gets or sets the color to use for the background
  40394. */
  40395. loadingUIBackgroundColor: string;
  40396. /**
  40397. * Gets or sets the text to display while loading
  40398. */
  40399. loadingUIText: string;
  40400. }
  40401. /**
  40402. * Class used for the default loading screen
  40403. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40404. */
  40405. export class DefaultLoadingScreen implements ILoadingScreen {
  40406. private _renderingCanvas;
  40407. private _loadingText;
  40408. private _loadingDivBackgroundColor;
  40409. private _loadingDiv;
  40410. private _loadingTextDiv;
  40411. /** Gets or sets the logo url to use for the default loading screen */
  40412. static DefaultLogoUrl: string;
  40413. /** Gets or sets the spinner url to use for the default loading screen */
  40414. static DefaultSpinnerUrl: string;
  40415. /**
  40416. * Creates a new default loading screen
  40417. * @param _renderingCanvas defines the canvas used to render the scene
  40418. * @param _loadingText defines the default text to display
  40419. * @param _loadingDivBackgroundColor defines the default background color
  40420. */
  40421. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40422. /**
  40423. * Function called to display the loading screen
  40424. */
  40425. displayLoadingUI(): void;
  40426. /**
  40427. * Function called to hide the loading screen
  40428. */
  40429. hideLoadingUI(): void;
  40430. /**
  40431. * Gets or sets the text to display while loading
  40432. */
  40433. set loadingUIText(text: string);
  40434. get loadingUIText(): string;
  40435. /**
  40436. * Gets or sets the color to use for the background
  40437. */
  40438. get loadingUIBackgroundColor(): string;
  40439. set loadingUIBackgroundColor(color: string);
  40440. private _resizeLoadingUI;
  40441. }
  40442. }
  40443. declare module BABYLON {
  40444. /**
  40445. * Interface for any object that can request an animation frame
  40446. */
  40447. export interface ICustomAnimationFrameRequester {
  40448. /**
  40449. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40450. */
  40451. renderFunction?: Function;
  40452. /**
  40453. * Called to request the next frame to render to
  40454. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40455. */
  40456. requestAnimationFrame: Function;
  40457. /**
  40458. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40459. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40460. */
  40461. requestID?: number;
  40462. }
  40463. }
  40464. declare module BABYLON {
  40465. /**
  40466. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40467. */
  40468. export class PerformanceMonitor {
  40469. private _enabled;
  40470. private _rollingFrameTime;
  40471. private _lastFrameTimeMs;
  40472. /**
  40473. * constructor
  40474. * @param frameSampleSize The number of samples required to saturate the sliding window
  40475. */
  40476. constructor(frameSampleSize?: number);
  40477. /**
  40478. * Samples current frame
  40479. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40480. */
  40481. sampleFrame(timeMs?: number): void;
  40482. /**
  40483. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40484. */
  40485. get averageFrameTime(): number;
  40486. /**
  40487. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40488. */
  40489. get averageFrameTimeVariance(): number;
  40490. /**
  40491. * Returns the frame time of the most recent frame
  40492. */
  40493. get instantaneousFrameTime(): number;
  40494. /**
  40495. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40496. */
  40497. get averageFPS(): number;
  40498. /**
  40499. * Returns the average framerate in frames per second using the most recent frame time
  40500. */
  40501. get instantaneousFPS(): number;
  40502. /**
  40503. * Returns true if enough samples have been taken to completely fill the sliding window
  40504. */
  40505. get isSaturated(): boolean;
  40506. /**
  40507. * Enables contributions to the sliding window sample set
  40508. */
  40509. enable(): void;
  40510. /**
  40511. * Disables contributions to the sliding window sample set
  40512. * Samples will not be interpolated over the disabled period
  40513. */
  40514. disable(): void;
  40515. /**
  40516. * Returns true if sampling is enabled
  40517. */
  40518. get isEnabled(): boolean;
  40519. /**
  40520. * Resets performance monitor
  40521. */
  40522. reset(): void;
  40523. }
  40524. /**
  40525. * RollingAverage
  40526. *
  40527. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40528. */
  40529. export class RollingAverage {
  40530. /**
  40531. * Current average
  40532. */
  40533. average: number;
  40534. /**
  40535. * Current variance
  40536. */
  40537. variance: number;
  40538. protected _samples: Array<number>;
  40539. protected _sampleCount: number;
  40540. protected _pos: number;
  40541. protected _m2: number;
  40542. /**
  40543. * constructor
  40544. * @param length The number of samples required to saturate the sliding window
  40545. */
  40546. constructor(length: number);
  40547. /**
  40548. * Adds a sample to the sample set
  40549. * @param v The sample value
  40550. */
  40551. add(v: number): void;
  40552. /**
  40553. * Returns previously added values or null if outside of history or outside the sliding window domain
  40554. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40555. * @return Value previously recorded with add() or null if outside of range
  40556. */
  40557. history(i: number): number;
  40558. /**
  40559. * Returns true if enough samples have been taken to completely fill the sliding window
  40560. * @return true if sample-set saturated
  40561. */
  40562. isSaturated(): boolean;
  40563. /**
  40564. * Resets the rolling average (equivalent to 0 samples taken so far)
  40565. */
  40566. reset(): void;
  40567. /**
  40568. * Wraps a value around the sample range boundaries
  40569. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40570. * @return Wrapped position in sample range
  40571. */
  40572. protected _wrapPosition(i: number): number;
  40573. }
  40574. }
  40575. declare module BABYLON {
  40576. /**
  40577. * This class is used to track a performance counter which is number based.
  40578. * The user has access to many properties which give statistics of different nature.
  40579. *
  40580. * The implementer can track two kinds of Performance Counter: time and count.
  40581. * 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.
  40582. * 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.
  40583. */
  40584. export class PerfCounter {
  40585. /**
  40586. * Gets or sets a global boolean to turn on and off all the counters
  40587. */
  40588. static Enabled: boolean;
  40589. /**
  40590. * Returns the smallest value ever
  40591. */
  40592. get min(): number;
  40593. /**
  40594. * Returns the biggest value ever
  40595. */
  40596. get max(): number;
  40597. /**
  40598. * Returns the average value since the performance counter is running
  40599. */
  40600. get average(): number;
  40601. /**
  40602. * Returns the average value of the last second the counter was monitored
  40603. */
  40604. get lastSecAverage(): number;
  40605. /**
  40606. * Returns the current value
  40607. */
  40608. get current(): number;
  40609. /**
  40610. * Gets the accumulated total
  40611. */
  40612. get total(): number;
  40613. /**
  40614. * Gets the total value count
  40615. */
  40616. get count(): number;
  40617. /**
  40618. * Creates a new counter
  40619. */
  40620. constructor();
  40621. /**
  40622. * Call this method to start monitoring a new frame.
  40623. * 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.
  40624. */
  40625. fetchNewFrame(): void;
  40626. /**
  40627. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40628. * @param newCount the count value to add to the monitored count
  40629. * @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.
  40630. */
  40631. addCount(newCount: number, fetchResult: boolean): void;
  40632. /**
  40633. * Start monitoring this performance counter
  40634. */
  40635. beginMonitoring(): void;
  40636. /**
  40637. * Compute the time lapsed since the previous beginMonitoring() call.
  40638. * @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
  40639. */
  40640. endMonitoring(newFrame?: boolean): void;
  40641. private _fetchResult;
  40642. private _startMonitoringTime;
  40643. private _min;
  40644. private _max;
  40645. private _average;
  40646. private _current;
  40647. private _totalValueCount;
  40648. private _totalAccumulated;
  40649. private _lastSecAverage;
  40650. private _lastSecAccumulated;
  40651. private _lastSecTime;
  40652. private _lastSecValueCount;
  40653. }
  40654. }
  40655. declare module BABYLON {
  40656. interface ThinEngine {
  40657. /** @hidden */
  40658. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40659. }
  40660. }
  40661. declare module BABYLON {
  40662. /**
  40663. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40664. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40665. */
  40666. export class Analyser {
  40667. /**
  40668. * Gets or sets the smoothing
  40669. * @ignorenaming
  40670. */
  40671. SMOOTHING: number;
  40672. /**
  40673. * Gets or sets the FFT table size
  40674. * @ignorenaming
  40675. */
  40676. FFT_SIZE: number;
  40677. /**
  40678. * Gets or sets the bar graph amplitude
  40679. * @ignorenaming
  40680. */
  40681. BARGRAPHAMPLITUDE: number;
  40682. /**
  40683. * Gets or sets the position of the debug canvas
  40684. * @ignorenaming
  40685. */
  40686. DEBUGCANVASPOS: {
  40687. x: number;
  40688. y: number;
  40689. };
  40690. /**
  40691. * Gets or sets the debug canvas size
  40692. * @ignorenaming
  40693. */
  40694. DEBUGCANVASSIZE: {
  40695. width: number;
  40696. height: number;
  40697. };
  40698. private _byteFreqs;
  40699. private _byteTime;
  40700. private _floatFreqs;
  40701. private _webAudioAnalyser;
  40702. private _debugCanvas;
  40703. private _debugCanvasContext;
  40704. private _scene;
  40705. private _registerFunc;
  40706. private _audioEngine;
  40707. /**
  40708. * Creates a new analyser
  40709. * @param scene defines hosting scene
  40710. */
  40711. constructor(scene: Scene);
  40712. /**
  40713. * Get the number of data values you will have to play with for the visualization
  40714. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40715. * @returns a number
  40716. */
  40717. getFrequencyBinCount(): number;
  40718. /**
  40719. * Gets the current frequency data as a byte array
  40720. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40721. * @returns a Uint8Array
  40722. */
  40723. getByteFrequencyData(): Uint8Array;
  40724. /**
  40725. * Gets the current waveform as a byte array
  40726. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40727. * @returns a Uint8Array
  40728. */
  40729. getByteTimeDomainData(): Uint8Array;
  40730. /**
  40731. * Gets the current frequency data as a float array
  40732. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40733. * @returns a Float32Array
  40734. */
  40735. getFloatFrequencyData(): Float32Array;
  40736. /**
  40737. * Renders the debug canvas
  40738. */
  40739. drawDebugCanvas(): void;
  40740. /**
  40741. * Stops rendering the debug canvas and removes it
  40742. */
  40743. stopDebugCanvas(): void;
  40744. /**
  40745. * Connects two audio nodes
  40746. * @param inputAudioNode defines first node to connect
  40747. * @param outputAudioNode defines second node to connect
  40748. */
  40749. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40750. /**
  40751. * Releases all associated resources
  40752. */
  40753. dispose(): void;
  40754. }
  40755. }
  40756. declare module BABYLON {
  40757. /**
  40758. * This represents an audio engine and it is responsible
  40759. * to play, synchronize and analyse sounds throughout the application.
  40760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40761. */
  40762. export interface IAudioEngine extends IDisposable {
  40763. /**
  40764. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40765. */
  40766. readonly canUseWebAudio: boolean;
  40767. /**
  40768. * Gets the current AudioContext if available.
  40769. */
  40770. readonly audioContext: Nullable<AudioContext>;
  40771. /**
  40772. * The master gain node defines the global audio volume of your audio engine.
  40773. */
  40774. readonly masterGain: GainNode;
  40775. /**
  40776. * Gets whether or not mp3 are supported by your browser.
  40777. */
  40778. readonly isMP3supported: boolean;
  40779. /**
  40780. * Gets whether or not ogg are supported by your browser.
  40781. */
  40782. readonly isOGGsupported: boolean;
  40783. /**
  40784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40785. * @ignoreNaming
  40786. */
  40787. WarnedWebAudioUnsupported: boolean;
  40788. /**
  40789. * Defines if the audio engine relies on a custom unlocked button.
  40790. * In this case, the embedded button will not be displayed.
  40791. */
  40792. useCustomUnlockedButton: boolean;
  40793. /**
  40794. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40795. */
  40796. readonly unlocked: boolean;
  40797. /**
  40798. * Event raised when audio has been unlocked on the browser.
  40799. */
  40800. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40801. /**
  40802. * Event raised when audio has been locked on the browser.
  40803. */
  40804. onAudioLockedObservable: Observable<IAudioEngine>;
  40805. /**
  40806. * Flags the audio engine in Locked state.
  40807. * This happens due to new browser policies preventing audio to autoplay.
  40808. */
  40809. lock(): void;
  40810. /**
  40811. * Unlocks the audio engine once a user action has been done on the dom.
  40812. * This is helpful to resume play once browser policies have been satisfied.
  40813. */
  40814. unlock(): void;
  40815. /**
  40816. * Gets the global volume sets on the master gain.
  40817. * @returns the global volume if set or -1 otherwise
  40818. */
  40819. getGlobalVolume(): number;
  40820. /**
  40821. * Sets the global volume of your experience (sets on the master gain).
  40822. * @param newVolume Defines the new global volume of the application
  40823. */
  40824. setGlobalVolume(newVolume: number): void;
  40825. /**
  40826. * Connect the audio engine to an audio analyser allowing some amazing
  40827. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40829. * @param analyser The analyser to connect to the engine
  40830. */
  40831. connectToAnalyser(analyser: Analyser): void;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * Defines the interface used by display changed events
  40837. */
  40838. export interface IDisplayChangedEventArgs {
  40839. /** Gets the vrDisplay object (if any) */
  40840. vrDisplay: Nullable<any>;
  40841. /** Gets a boolean indicating if webVR is supported */
  40842. vrSupported: boolean;
  40843. }
  40844. /**
  40845. * Defines the interface used by objects containing a viewport (like a camera)
  40846. */
  40847. interface IViewportOwnerLike {
  40848. /**
  40849. * Gets or sets the viewport
  40850. */
  40851. viewport: IViewportLike;
  40852. }
  40853. /**
  40854. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40855. */
  40856. export class Engine extends ThinEngine {
  40857. /** Defines that alpha blending is disabled */
  40858. static readonly ALPHA_DISABLE: number;
  40859. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40860. static readonly ALPHA_ADD: number;
  40861. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40862. static readonly ALPHA_COMBINE: number;
  40863. /** Defines that alpha blending to DEST - SRC * DEST */
  40864. static readonly ALPHA_SUBTRACT: number;
  40865. /** Defines that alpha blending to SRC * DEST */
  40866. static readonly ALPHA_MULTIPLY: number;
  40867. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40868. static readonly ALPHA_MAXIMIZED: number;
  40869. /** Defines that alpha blending to SRC + DEST */
  40870. static readonly ALPHA_ONEONE: number;
  40871. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40872. static readonly ALPHA_PREMULTIPLIED: number;
  40873. /**
  40874. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40875. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40876. */
  40877. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40878. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40879. static readonly ALPHA_INTERPOLATE: number;
  40880. /**
  40881. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40882. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40883. */
  40884. static readonly ALPHA_SCREENMODE: number;
  40885. /** Defines that the ressource is not delayed*/
  40886. static readonly DELAYLOADSTATE_NONE: number;
  40887. /** Defines that the ressource was successfully delay loaded */
  40888. static readonly DELAYLOADSTATE_LOADED: number;
  40889. /** Defines that the ressource is currently delay loading */
  40890. static readonly DELAYLOADSTATE_LOADING: number;
  40891. /** Defines that the ressource is delayed and has not started loading */
  40892. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40893. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40894. static readonly NEVER: number;
  40895. /** 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 */
  40896. static readonly ALWAYS: number;
  40897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40898. static readonly LESS: number;
  40899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40900. static readonly EQUAL: number;
  40901. /** 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 */
  40902. static readonly LEQUAL: number;
  40903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40904. static readonly GREATER: number;
  40905. /** 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 */
  40906. static readonly GEQUAL: number;
  40907. /** 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 */
  40908. static readonly NOTEQUAL: number;
  40909. /** Passed to stencilOperation to specify that stencil value must be kept */
  40910. static readonly KEEP: number;
  40911. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40912. static readonly REPLACE: number;
  40913. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40914. static readonly INCR: number;
  40915. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40916. static readonly DECR: number;
  40917. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40918. static readonly INVERT: number;
  40919. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40920. static readonly INCR_WRAP: number;
  40921. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40922. static readonly DECR_WRAP: number;
  40923. /** Texture is not repeating outside of 0..1 UVs */
  40924. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40925. /** Texture is repeating outside of 0..1 UVs */
  40926. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40927. /** Texture is repeating and mirrored */
  40928. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40929. /** ALPHA */
  40930. static readonly TEXTUREFORMAT_ALPHA: number;
  40931. /** LUMINANCE */
  40932. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40933. /** LUMINANCE_ALPHA */
  40934. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40935. /** RGB */
  40936. static readonly TEXTUREFORMAT_RGB: number;
  40937. /** RGBA */
  40938. static readonly TEXTUREFORMAT_RGBA: number;
  40939. /** RED */
  40940. static readonly TEXTUREFORMAT_RED: number;
  40941. /** RED (2nd reference) */
  40942. static readonly TEXTUREFORMAT_R: number;
  40943. /** RG */
  40944. static readonly TEXTUREFORMAT_RG: number;
  40945. /** RED_INTEGER */
  40946. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40947. /** RED_INTEGER (2nd reference) */
  40948. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40949. /** RG_INTEGER */
  40950. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40951. /** RGB_INTEGER */
  40952. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40953. /** RGBA_INTEGER */
  40954. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40955. /** UNSIGNED_BYTE */
  40956. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40957. /** UNSIGNED_BYTE (2nd reference) */
  40958. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40959. /** FLOAT */
  40960. static readonly TEXTURETYPE_FLOAT: number;
  40961. /** HALF_FLOAT */
  40962. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40963. /** BYTE */
  40964. static readonly TEXTURETYPE_BYTE: number;
  40965. /** SHORT */
  40966. static readonly TEXTURETYPE_SHORT: number;
  40967. /** UNSIGNED_SHORT */
  40968. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40969. /** INT */
  40970. static readonly TEXTURETYPE_INT: number;
  40971. /** UNSIGNED_INT */
  40972. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40973. /** UNSIGNED_SHORT_4_4_4_4 */
  40974. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40975. /** UNSIGNED_SHORT_5_5_5_1 */
  40976. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40977. /** UNSIGNED_SHORT_5_6_5 */
  40978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40979. /** UNSIGNED_INT_2_10_10_10_REV */
  40980. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40981. /** UNSIGNED_INT_24_8 */
  40982. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40983. /** UNSIGNED_INT_10F_11F_11F_REV */
  40984. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40985. /** UNSIGNED_INT_5_9_9_9_REV */
  40986. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40987. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40988. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40989. /** nearest is mag = nearest and min = nearest and mip = linear */
  40990. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40991. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40992. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40993. /** Trilinear is mag = linear and min = linear and mip = linear */
  40994. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40995. /** nearest is mag = nearest and min = nearest and mip = linear */
  40996. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40997. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40998. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40999. /** Trilinear is mag = linear and min = linear and mip = linear */
  41000. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41001. /** mag = nearest and min = nearest and mip = nearest */
  41002. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41003. /** mag = nearest and min = linear and mip = nearest */
  41004. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41005. /** mag = nearest and min = linear and mip = linear */
  41006. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41007. /** mag = nearest and min = linear and mip = none */
  41008. static readonly TEXTURE_NEAREST_LINEAR: number;
  41009. /** mag = nearest and min = nearest and mip = none */
  41010. static readonly TEXTURE_NEAREST_NEAREST: number;
  41011. /** mag = linear and min = nearest and mip = nearest */
  41012. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41013. /** mag = linear and min = nearest and mip = linear */
  41014. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41015. /** mag = linear and min = linear and mip = none */
  41016. static readonly TEXTURE_LINEAR_LINEAR: number;
  41017. /** mag = linear and min = nearest and mip = none */
  41018. static readonly TEXTURE_LINEAR_NEAREST: number;
  41019. /** Explicit coordinates mode */
  41020. static readonly TEXTURE_EXPLICIT_MODE: number;
  41021. /** Spherical coordinates mode */
  41022. static readonly TEXTURE_SPHERICAL_MODE: number;
  41023. /** Planar coordinates mode */
  41024. static readonly TEXTURE_PLANAR_MODE: number;
  41025. /** Cubic coordinates mode */
  41026. static readonly TEXTURE_CUBIC_MODE: number;
  41027. /** Projection coordinates mode */
  41028. static readonly TEXTURE_PROJECTION_MODE: number;
  41029. /** Skybox coordinates mode */
  41030. static readonly TEXTURE_SKYBOX_MODE: number;
  41031. /** Inverse Cubic coordinates mode */
  41032. static readonly TEXTURE_INVCUBIC_MODE: number;
  41033. /** Equirectangular coordinates mode */
  41034. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41035. /** Equirectangular Fixed coordinates mode */
  41036. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41037. /** Equirectangular Fixed Mirrored coordinates mode */
  41038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41039. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41040. static readonly SCALEMODE_FLOOR: number;
  41041. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41042. static readonly SCALEMODE_NEAREST: number;
  41043. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41044. static readonly SCALEMODE_CEILING: number;
  41045. /**
  41046. * Returns the current npm package of the sdk
  41047. */
  41048. static get NpmPackage(): string;
  41049. /**
  41050. * Returns the current version of the framework
  41051. */
  41052. static get Version(): string;
  41053. /** Gets the list of created engines */
  41054. static get Instances(): Engine[];
  41055. /**
  41056. * Gets the latest created engine
  41057. */
  41058. static get LastCreatedEngine(): Nullable<Engine>;
  41059. /**
  41060. * Gets the latest created scene
  41061. */
  41062. static get LastCreatedScene(): Nullable<Scene>;
  41063. /**
  41064. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41065. * @param flag defines which part of the materials must be marked as dirty
  41066. * @param predicate defines a predicate used to filter which materials should be affected
  41067. */
  41068. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41069. /**
  41070. * Method called to create the default loading screen.
  41071. * This can be overriden in your own app.
  41072. * @param canvas The rendering canvas element
  41073. * @returns The loading screen
  41074. */
  41075. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41076. /**
  41077. * Method called to create the default rescale post process on each engine.
  41078. */
  41079. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41080. /**
  41081. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41082. **/
  41083. enableOfflineSupport: boolean;
  41084. /**
  41085. * 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)
  41086. **/
  41087. disableManifestCheck: boolean;
  41088. /**
  41089. * Gets the list of created scenes
  41090. */
  41091. scenes: Scene[];
  41092. /**
  41093. * Event raised when a new scene is created
  41094. */
  41095. onNewSceneAddedObservable: Observable<Scene>;
  41096. /**
  41097. * Gets the list of created postprocesses
  41098. */
  41099. postProcesses: PostProcess[];
  41100. /**
  41101. * Gets a boolean indicating if the pointer is currently locked
  41102. */
  41103. isPointerLock: boolean;
  41104. /**
  41105. * Observable event triggered each time the rendering canvas is resized
  41106. */
  41107. onResizeObservable: Observable<Engine>;
  41108. /**
  41109. * Observable event triggered each time the canvas loses focus
  41110. */
  41111. onCanvasBlurObservable: Observable<Engine>;
  41112. /**
  41113. * Observable event triggered each time the canvas gains focus
  41114. */
  41115. onCanvasFocusObservable: Observable<Engine>;
  41116. /**
  41117. * Observable event triggered each time the canvas receives pointerout event
  41118. */
  41119. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41120. /**
  41121. * Observable raised when the engine begins a new frame
  41122. */
  41123. onBeginFrameObservable: Observable<Engine>;
  41124. /**
  41125. * If set, will be used to request the next animation frame for the render loop
  41126. */
  41127. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41128. /**
  41129. * Observable raised when the engine ends the current frame
  41130. */
  41131. onEndFrameObservable: Observable<Engine>;
  41132. /**
  41133. * Observable raised when the engine is about to compile a shader
  41134. */
  41135. onBeforeShaderCompilationObservable: Observable<Engine>;
  41136. /**
  41137. * Observable raised when the engine has jsut compiled a shader
  41138. */
  41139. onAfterShaderCompilationObservable: Observable<Engine>;
  41140. /**
  41141. * Gets the audio engine
  41142. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41143. * @ignorenaming
  41144. */
  41145. static audioEngine: IAudioEngine;
  41146. /**
  41147. * Default AudioEngine factory responsible of creating the Audio Engine.
  41148. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41149. */
  41150. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41151. /**
  41152. * Default offline support factory responsible of creating a tool used to store data locally.
  41153. * By default, this will create a Database object if the workload has been embedded.
  41154. */
  41155. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41156. private _loadingScreen;
  41157. private _pointerLockRequested;
  41158. private _rescalePostProcess;
  41159. private _deterministicLockstep;
  41160. private _lockstepMaxSteps;
  41161. private _timeStep;
  41162. protected get _supportsHardwareTextureRescaling(): boolean;
  41163. private _fps;
  41164. private _deltaTime;
  41165. /** @hidden */
  41166. _drawCalls: PerfCounter;
  41167. /** 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 */
  41168. canvasTabIndex: number;
  41169. /**
  41170. * Turn this value on if you want to pause FPS computation when in background
  41171. */
  41172. disablePerformanceMonitorInBackground: boolean;
  41173. private _performanceMonitor;
  41174. /**
  41175. * Gets the performance monitor attached to this engine
  41176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41177. */
  41178. get performanceMonitor(): PerformanceMonitor;
  41179. private _onFocus;
  41180. private _onBlur;
  41181. private _onCanvasPointerOut;
  41182. private _onCanvasBlur;
  41183. private _onCanvasFocus;
  41184. private _onFullscreenChange;
  41185. private _onPointerLockChange;
  41186. /**
  41187. * Gets the HTML element used to attach event listeners
  41188. * @returns a HTML element
  41189. */
  41190. getInputElement(): Nullable<HTMLElement>;
  41191. /**
  41192. * Creates a new engine
  41193. * @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
  41194. * @param antialias defines enable antialiasing (default: false)
  41195. * @param options defines further options to be sent to the getContext() function
  41196. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41197. */
  41198. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41199. /**
  41200. * Gets current aspect ratio
  41201. * @param viewportOwner defines the camera to use to get the aspect ratio
  41202. * @param useScreen defines if screen size must be used (or the current render target if any)
  41203. * @returns a number defining the aspect ratio
  41204. */
  41205. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41206. /**
  41207. * Gets current screen aspect ratio
  41208. * @returns a number defining the aspect ratio
  41209. */
  41210. getScreenAspectRatio(): number;
  41211. /**
  41212. * Gets the client rect of the HTML canvas attached with the current webGL context
  41213. * @returns a client rectanglee
  41214. */
  41215. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41216. /**
  41217. * Gets the client rect of the HTML element used for events
  41218. * @returns a client rectanglee
  41219. */
  41220. getInputElementClientRect(): Nullable<ClientRect>;
  41221. /**
  41222. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41223. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41224. * @returns true if engine is in deterministic lock step mode
  41225. */
  41226. isDeterministicLockStep(): boolean;
  41227. /**
  41228. * Gets the max steps when engine is running in deterministic lock step
  41229. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41230. * @returns the max steps
  41231. */
  41232. getLockstepMaxSteps(): number;
  41233. /**
  41234. * Returns the time in ms between steps when using deterministic lock step.
  41235. * @returns time step in (ms)
  41236. */
  41237. getTimeStep(): number;
  41238. /**
  41239. * Force the mipmap generation for the given render target texture
  41240. * @param texture defines the render target texture to use
  41241. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41242. */
  41243. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41244. /** States */
  41245. /**
  41246. * Set various states to the webGL context
  41247. * @param culling defines backface culling state
  41248. * @param zOffset defines the value to apply to zOffset (0 by default)
  41249. * @param force defines if states must be applied even if cache is up to date
  41250. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41251. */
  41252. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41253. /**
  41254. * Set the z offset to apply to current rendering
  41255. * @param value defines the offset to apply
  41256. */
  41257. setZOffset(value: number): void;
  41258. /**
  41259. * Gets the current value of the zOffset
  41260. * @returns the current zOffset state
  41261. */
  41262. getZOffset(): number;
  41263. /**
  41264. * Enable or disable depth buffering
  41265. * @param enable defines the state to set
  41266. */
  41267. setDepthBuffer(enable: boolean): void;
  41268. /**
  41269. * Gets a boolean indicating if depth writing is enabled
  41270. * @returns the current depth writing state
  41271. */
  41272. getDepthWrite(): boolean;
  41273. /**
  41274. * Enable or disable depth writing
  41275. * @param enable defines the state to set
  41276. */
  41277. setDepthWrite(enable: boolean): void;
  41278. /**
  41279. * Gets a boolean indicating if stencil buffer is enabled
  41280. * @returns the current stencil buffer state
  41281. */
  41282. getStencilBuffer(): boolean;
  41283. /**
  41284. * Enable or disable the stencil buffer
  41285. * @param enable defines if the stencil buffer must be enabled or disabled
  41286. */
  41287. setStencilBuffer(enable: boolean): void;
  41288. /**
  41289. * Gets the current stencil mask
  41290. * @returns a number defining the new stencil mask to use
  41291. */
  41292. getStencilMask(): number;
  41293. /**
  41294. * Sets the current stencil mask
  41295. * @param mask defines the new stencil mask to use
  41296. */
  41297. setStencilMask(mask: number): void;
  41298. /**
  41299. * Gets the current stencil function
  41300. * @returns a number defining the stencil function to use
  41301. */
  41302. getStencilFunction(): number;
  41303. /**
  41304. * Gets the current stencil reference value
  41305. * @returns a number defining the stencil reference value to use
  41306. */
  41307. getStencilFunctionReference(): number;
  41308. /**
  41309. * Gets the current stencil mask
  41310. * @returns a number defining the stencil mask to use
  41311. */
  41312. getStencilFunctionMask(): number;
  41313. /**
  41314. * Sets the current stencil function
  41315. * @param stencilFunc defines the new stencil function to use
  41316. */
  41317. setStencilFunction(stencilFunc: number): void;
  41318. /**
  41319. * Sets the current stencil reference
  41320. * @param reference defines the new stencil reference to use
  41321. */
  41322. setStencilFunctionReference(reference: number): void;
  41323. /**
  41324. * Sets the current stencil mask
  41325. * @param mask defines the new stencil mask to use
  41326. */
  41327. setStencilFunctionMask(mask: number): void;
  41328. /**
  41329. * Gets the current stencil operation when stencil fails
  41330. * @returns a number defining stencil operation to use when stencil fails
  41331. */
  41332. getStencilOperationFail(): number;
  41333. /**
  41334. * Gets the current stencil operation when depth fails
  41335. * @returns a number defining stencil operation to use when depth fails
  41336. */
  41337. getStencilOperationDepthFail(): number;
  41338. /**
  41339. * Gets the current stencil operation when stencil passes
  41340. * @returns a number defining stencil operation to use when stencil passes
  41341. */
  41342. getStencilOperationPass(): number;
  41343. /**
  41344. * Sets the stencil operation to use when stencil fails
  41345. * @param operation defines the stencil operation to use when stencil fails
  41346. */
  41347. setStencilOperationFail(operation: number): void;
  41348. /**
  41349. * Sets the stencil operation to use when depth fails
  41350. * @param operation defines the stencil operation to use when depth fails
  41351. */
  41352. setStencilOperationDepthFail(operation: number): void;
  41353. /**
  41354. * Sets the stencil operation to use when stencil passes
  41355. * @param operation defines the stencil operation to use when stencil passes
  41356. */
  41357. setStencilOperationPass(operation: number): void;
  41358. /**
  41359. * Sets a boolean indicating if the dithering state is enabled or disabled
  41360. * @param value defines the dithering state
  41361. */
  41362. setDitheringState(value: boolean): void;
  41363. /**
  41364. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41365. * @param value defines the rasterizer state
  41366. */
  41367. setRasterizerState(value: boolean): void;
  41368. /**
  41369. * Gets the current depth function
  41370. * @returns a number defining the depth function
  41371. */
  41372. getDepthFunction(): Nullable<number>;
  41373. /**
  41374. * Sets the current depth function
  41375. * @param depthFunc defines the function to use
  41376. */
  41377. setDepthFunction(depthFunc: number): void;
  41378. /**
  41379. * Sets the current depth function to GREATER
  41380. */
  41381. setDepthFunctionToGreater(): void;
  41382. /**
  41383. * Sets the current depth function to GEQUAL
  41384. */
  41385. setDepthFunctionToGreaterOrEqual(): void;
  41386. /**
  41387. * Sets the current depth function to LESS
  41388. */
  41389. setDepthFunctionToLess(): void;
  41390. /**
  41391. * Sets the current depth function to LEQUAL
  41392. */
  41393. setDepthFunctionToLessOrEqual(): void;
  41394. private _cachedStencilBuffer;
  41395. private _cachedStencilFunction;
  41396. private _cachedStencilMask;
  41397. private _cachedStencilOperationPass;
  41398. private _cachedStencilOperationFail;
  41399. private _cachedStencilOperationDepthFail;
  41400. private _cachedStencilReference;
  41401. /**
  41402. * Caches the the state of the stencil buffer
  41403. */
  41404. cacheStencilState(): void;
  41405. /**
  41406. * Restores the state of the stencil buffer
  41407. */
  41408. restoreStencilState(): void;
  41409. /**
  41410. * Directly set the WebGL Viewport
  41411. * @param x defines the x coordinate of the viewport (in screen space)
  41412. * @param y defines the y coordinate of the viewport (in screen space)
  41413. * @param width defines the width of the viewport (in screen space)
  41414. * @param height defines the height of the viewport (in screen space)
  41415. * @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
  41416. */
  41417. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41418. /**
  41419. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41421. * @param y defines the y-coordinate of the corner of the clear rectangle
  41422. * @param width defines the width of the clear rectangle
  41423. * @param height defines the height of the clear rectangle
  41424. * @param clearColor defines the clear color
  41425. */
  41426. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41427. /**
  41428. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41430. * @param y defines the y-coordinate of the corner of the clear rectangle
  41431. * @param width defines the width of the clear rectangle
  41432. * @param height defines the height of the clear rectangle
  41433. */
  41434. enableScissor(x: number, y: number, width: number, height: number): void;
  41435. /**
  41436. * Disable previously set scissor test rectangle
  41437. */
  41438. disableScissor(): void;
  41439. protected _reportDrawCall(): void;
  41440. /**
  41441. * Initializes a webVR display and starts listening to display change events
  41442. * The onVRDisplayChangedObservable will be notified upon these changes
  41443. * @returns The onVRDisplayChangedObservable
  41444. */
  41445. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41446. /** @hidden */
  41447. _prepareVRComponent(): void;
  41448. /** @hidden */
  41449. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41450. /** @hidden */
  41451. _submitVRFrame(): void;
  41452. /**
  41453. * Call this function to leave webVR mode
  41454. * Will do nothing if webVR is not supported or if there is no webVR device
  41455. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41456. */
  41457. disableVR(): void;
  41458. /**
  41459. * Gets a boolean indicating that the system is in VR mode and is presenting
  41460. * @returns true if VR mode is engaged
  41461. */
  41462. isVRPresenting(): boolean;
  41463. /** @hidden */
  41464. _requestVRFrame(): void;
  41465. /** @hidden */
  41466. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41467. /**
  41468. * Gets the source code of the vertex shader associated with a specific webGL program
  41469. * @param program defines the program to use
  41470. * @returns a string containing the source code of the vertex shader associated with the program
  41471. */
  41472. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41473. /**
  41474. * Gets the source code of the fragment shader associated with a specific webGL program
  41475. * @param program defines the program to use
  41476. * @returns a string containing the source code of the fragment shader associated with the program
  41477. */
  41478. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41479. /**
  41480. * Sets a depth stencil texture from a render target to the according uniform.
  41481. * @param channel The texture channel
  41482. * @param uniform The uniform to set
  41483. * @param texture The render target texture containing the depth stencil texture to apply
  41484. */
  41485. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41486. /**
  41487. * Sets a texture to the webGL context from a postprocess
  41488. * @param channel defines the channel to use
  41489. * @param postProcess defines the source postprocess
  41490. */
  41491. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41492. /**
  41493. * Binds the output of the passed in post process to the texture channel specified
  41494. * @param channel The channel the texture should be bound to
  41495. * @param postProcess The post process which's output should be bound
  41496. */
  41497. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41498. protected _rebuildBuffers(): void;
  41499. /** @hidden */
  41500. _renderFrame(): void;
  41501. _renderLoop(): void;
  41502. /** @hidden */
  41503. _renderViews(): boolean;
  41504. /**
  41505. * Toggle full screen mode
  41506. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41507. */
  41508. switchFullscreen(requestPointerLock: boolean): void;
  41509. /**
  41510. * Enters full screen mode
  41511. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41512. */
  41513. enterFullscreen(requestPointerLock: boolean): void;
  41514. /**
  41515. * Exits full screen mode
  41516. */
  41517. exitFullscreen(): void;
  41518. /**
  41519. * Enters Pointerlock mode
  41520. */
  41521. enterPointerlock(): void;
  41522. /**
  41523. * Exits Pointerlock mode
  41524. */
  41525. exitPointerlock(): void;
  41526. /**
  41527. * Begin a new frame
  41528. */
  41529. beginFrame(): void;
  41530. /**
  41531. * Enf the current frame
  41532. */
  41533. endFrame(): void;
  41534. resize(): void;
  41535. /**
  41536. * Force a specific size of the canvas
  41537. * @param width defines the new canvas' width
  41538. * @param height defines the new canvas' height
  41539. * @returns true if the size was changed
  41540. */
  41541. setSize(width: number, height: number): boolean;
  41542. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41543. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41544. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41545. _releaseTexture(texture: InternalTexture): void;
  41546. /**
  41547. * @hidden
  41548. * Rescales a texture
  41549. * @param source input texutre
  41550. * @param destination destination texture
  41551. * @param scene scene to use to render the resize
  41552. * @param internalFormat format to use when resizing
  41553. * @param onComplete callback to be called when resize has completed
  41554. */
  41555. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41556. /**
  41557. * Gets the current framerate
  41558. * @returns a number representing the framerate
  41559. */
  41560. getFps(): number;
  41561. /**
  41562. * Gets the time spent between current and previous frame
  41563. * @returns a number representing the delta time in ms
  41564. */
  41565. getDeltaTime(): number;
  41566. private _measureFps;
  41567. /** @hidden */
  41568. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41569. /**
  41570. * Updates the sample count of a render target texture
  41571. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41572. * @param texture defines the texture to update
  41573. * @param samples defines the sample count to set
  41574. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41575. */
  41576. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41577. /**
  41578. * Updates a depth texture Comparison Mode and Function.
  41579. * If the comparison Function is equal to 0, the mode will be set to none.
  41580. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41581. * @param texture The texture to set the comparison function for
  41582. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41583. */
  41584. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41585. /**
  41586. * Creates a webGL buffer to use with instanciation
  41587. * @param capacity defines the size of the buffer
  41588. * @returns the webGL buffer
  41589. */
  41590. createInstancesBuffer(capacity: number): DataBuffer;
  41591. /**
  41592. * Delete a webGL buffer used with instanciation
  41593. * @param buffer defines the webGL buffer to delete
  41594. */
  41595. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41596. private _clientWaitAsync;
  41597. /** @hidden */
  41598. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41599. dispose(): void;
  41600. private _disableTouchAction;
  41601. /**
  41602. * Display the loading screen
  41603. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41604. */
  41605. displayLoadingUI(): void;
  41606. /**
  41607. * Hide the loading screen
  41608. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41609. */
  41610. hideLoadingUI(): void;
  41611. /**
  41612. * Gets the current loading screen object
  41613. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41614. */
  41615. get loadingScreen(): ILoadingScreen;
  41616. /**
  41617. * Sets the current loading screen object
  41618. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41619. */
  41620. set loadingScreen(loadingScreen: ILoadingScreen);
  41621. /**
  41622. * Sets the current loading screen text
  41623. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41624. */
  41625. set loadingUIText(text: string);
  41626. /**
  41627. * Sets the current loading screen background color
  41628. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41629. */
  41630. set loadingUIBackgroundColor(color: string);
  41631. /** Pointerlock and fullscreen */
  41632. /**
  41633. * Ask the browser to promote the current element to pointerlock mode
  41634. * @param element defines the DOM element to promote
  41635. */
  41636. static _RequestPointerlock(element: HTMLElement): void;
  41637. /**
  41638. * Asks the browser to exit pointerlock mode
  41639. */
  41640. static _ExitPointerlock(): void;
  41641. /**
  41642. * Ask the browser to promote the current element to fullscreen rendering mode
  41643. * @param element defines the DOM element to promote
  41644. */
  41645. static _RequestFullscreen(element: HTMLElement): void;
  41646. /**
  41647. * Asks the browser to exit fullscreen mode
  41648. */
  41649. static _ExitFullscreen(): void;
  41650. }
  41651. }
  41652. declare module BABYLON {
  41653. /**
  41654. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41655. * during the life time of the application.
  41656. */
  41657. export class EngineStore {
  41658. /** Gets the list of created engines */
  41659. static Instances: Engine[];
  41660. /** @hidden */
  41661. static _LastCreatedScene: Nullable<Scene>;
  41662. /**
  41663. * Gets the latest created engine
  41664. */
  41665. static get LastCreatedEngine(): Nullable<Engine>;
  41666. /**
  41667. * Gets the latest created scene
  41668. */
  41669. static get LastCreatedScene(): Nullable<Scene>;
  41670. /**
  41671. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41672. * @ignorenaming
  41673. */
  41674. static UseFallbackTexture: boolean;
  41675. /**
  41676. * Texture content used if a texture cannot loaded
  41677. * @ignorenaming
  41678. */
  41679. static FallbackTexture: string;
  41680. }
  41681. }
  41682. declare module BABYLON {
  41683. /**
  41684. * Helper class that provides a small promise polyfill
  41685. */
  41686. export class PromisePolyfill {
  41687. /**
  41688. * Static function used to check if the polyfill is required
  41689. * If this is the case then the function will inject the polyfill to window.Promise
  41690. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41691. */
  41692. static Apply(force?: boolean): void;
  41693. }
  41694. }
  41695. declare module BABYLON {
  41696. /**
  41697. * Interface for screenshot methods with describe argument called `size` as object with options
  41698. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41699. */
  41700. export interface IScreenshotSize {
  41701. /**
  41702. * number in pixels for canvas height
  41703. */
  41704. height?: number;
  41705. /**
  41706. * multiplier allowing render at a higher or lower resolution
  41707. * If value is defined then height and width will be ignored and taken from camera
  41708. */
  41709. precision?: number;
  41710. /**
  41711. * number in pixels for canvas width
  41712. */
  41713. width?: number;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. interface IColor4Like {
  41718. r: float;
  41719. g: float;
  41720. b: float;
  41721. a: float;
  41722. }
  41723. /**
  41724. * Class containing a set of static utilities functions
  41725. */
  41726. export class Tools {
  41727. /**
  41728. * Gets or sets the base URL to use to load assets
  41729. */
  41730. static get BaseUrl(): string;
  41731. static set BaseUrl(value: string);
  41732. /**
  41733. * Enable/Disable Custom HTTP Request Headers globally.
  41734. * default = false
  41735. * @see CustomRequestHeaders
  41736. */
  41737. static UseCustomRequestHeaders: boolean;
  41738. /**
  41739. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41740. * i.e. when loading files, where the server/service expects an Authorization header
  41741. */
  41742. static CustomRequestHeaders: {
  41743. [key: string]: string;
  41744. };
  41745. /**
  41746. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41747. */
  41748. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41749. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41750. /**
  41751. * Default behaviour for cors in the application.
  41752. * It can be a string if the expected behavior is identical in the entire app.
  41753. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41754. */
  41755. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41756. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41757. /**
  41758. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41759. * @ignorenaming
  41760. */
  41761. static get UseFallbackTexture(): boolean;
  41762. static set UseFallbackTexture(value: boolean);
  41763. /**
  41764. * Use this object to register external classes like custom textures or material
  41765. * to allow the laoders to instantiate them
  41766. */
  41767. static get RegisteredExternalClasses(): {
  41768. [key: string]: Object;
  41769. };
  41770. static set RegisteredExternalClasses(classes: {
  41771. [key: string]: Object;
  41772. });
  41773. /**
  41774. * Texture content used if a texture cannot loaded
  41775. * @ignorenaming
  41776. */
  41777. static get fallbackTexture(): string;
  41778. static set fallbackTexture(value: string);
  41779. /**
  41780. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41781. * @param u defines the coordinate on X axis
  41782. * @param v defines the coordinate on Y axis
  41783. * @param width defines the width of the source data
  41784. * @param height defines the height of the source data
  41785. * @param pixels defines the source byte array
  41786. * @param color defines the output color
  41787. */
  41788. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41789. /**
  41790. * Interpolates between a and b via alpha
  41791. * @param a The lower value (returned when alpha = 0)
  41792. * @param b The upper value (returned when alpha = 1)
  41793. * @param alpha The interpolation-factor
  41794. * @return The mixed value
  41795. */
  41796. static Mix(a: number, b: number, alpha: number): number;
  41797. /**
  41798. * Tries to instantiate a new object from a given class name
  41799. * @param className defines the class name to instantiate
  41800. * @returns the new object or null if the system was not able to do the instantiation
  41801. */
  41802. static Instantiate(className: string): any;
  41803. /**
  41804. * Provides a slice function that will work even on IE
  41805. * @param data defines the array to slice
  41806. * @param start defines the start of the data (optional)
  41807. * @param end defines the end of the data (optional)
  41808. * @returns the new sliced array
  41809. */
  41810. static Slice<T>(data: T, start?: number, end?: number): T;
  41811. /**
  41812. * Provides a slice function that will work even on IE
  41813. * The difference between this and Slice is that this will force-convert to array
  41814. * @param data defines the array to slice
  41815. * @param start defines the start of the data (optional)
  41816. * @param end defines the end of the data (optional)
  41817. * @returns the new sliced array
  41818. */
  41819. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41820. /**
  41821. * Polyfill for setImmediate
  41822. * @param action defines the action to execute after the current execution block
  41823. */
  41824. static SetImmediate(action: () => void): void;
  41825. /**
  41826. * Function indicating if a number is an exponent of 2
  41827. * @param value defines the value to test
  41828. * @returns true if the value is an exponent of 2
  41829. */
  41830. static IsExponentOfTwo(value: number): boolean;
  41831. private static _tmpFloatArray;
  41832. /**
  41833. * Returns the nearest 32-bit single precision float representation of a Number
  41834. * @param value A Number. If the parameter is of a different type, it will get converted
  41835. * to a number or to NaN if it cannot be converted
  41836. * @returns number
  41837. */
  41838. static FloatRound(value: number): number;
  41839. /**
  41840. * Extracts the filename from a path
  41841. * @param path defines the path to use
  41842. * @returns the filename
  41843. */
  41844. static GetFilename(path: string): string;
  41845. /**
  41846. * Extracts the "folder" part of a path (everything before the filename).
  41847. * @param uri The URI to extract the info from
  41848. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41849. * @returns The "folder" part of the path
  41850. */
  41851. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41852. /**
  41853. * Extracts text content from a DOM element hierarchy
  41854. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41855. */
  41856. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41857. /**
  41858. * Convert an angle in radians to degrees
  41859. * @param angle defines the angle to convert
  41860. * @returns the angle in degrees
  41861. */
  41862. static ToDegrees(angle: number): number;
  41863. /**
  41864. * Convert an angle in degrees to radians
  41865. * @param angle defines the angle to convert
  41866. * @returns the angle in radians
  41867. */
  41868. static ToRadians(angle: number): number;
  41869. /**
  41870. * Returns an array if obj is not an array
  41871. * @param obj defines the object to evaluate as an array
  41872. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41873. * @returns either obj directly if obj is an array or a new array containing obj
  41874. */
  41875. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41876. /**
  41877. * Gets the pointer prefix to use
  41878. * @param engine defines the engine we are finding the prefix for
  41879. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41880. */
  41881. static GetPointerPrefix(engine: Engine): string;
  41882. /**
  41883. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41884. * @param url define the url we are trying
  41885. * @param element define the dom element where to configure the cors policy
  41886. */
  41887. static SetCorsBehavior(url: string | string[], element: {
  41888. crossOrigin: string | null;
  41889. }): void;
  41890. /**
  41891. * Removes unwanted characters from an url
  41892. * @param url defines the url to clean
  41893. * @returns the cleaned url
  41894. */
  41895. static CleanUrl(url: string): string;
  41896. /**
  41897. * Gets or sets a function used to pre-process url before using them to load assets
  41898. */
  41899. static get PreprocessUrl(): (url: string) => string;
  41900. static set PreprocessUrl(processor: (url: string) => string);
  41901. /**
  41902. * Loads an image as an HTMLImageElement.
  41903. * @param input url string, ArrayBuffer, or Blob to load
  41904. * @param onLoad callback called when the image successfully loads
  41905. * @param onError callback called when the image fails to load
  41906. * @param offlineProvider offline provider for caching
  41907. * @param mimeType optional mime type
  41908. * @returns the HTMLImageElement of the loaded image
  41909. */
  41910. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41911. /**
  41912. * Loads a file from a url
  41913. * @param url url string, ArrayBuffer, or Blob to load
  41914. * @param onSuccess callback called when the file successfully loads
  41915. * @param onProgress callback called while file is loading (if the server supports this mode)
  41916. * @param offlineProvider defines the offline provider for caching
  41917. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41918. * @param onError callback called when the file fails to load
  41919. * @returns a file request object
  41920. */
  41921. 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;
  41922. /**
  41923. * Loads a file from a url
  41924. * @param url the file url to load
  41925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41926. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41927. */
  41928. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41929. /**
  41930. * Load a script (identified by an url). When the url returns, the
  41931. * content of this file is added into a new script element, attached to the DOM (body element)
  41932. * @param scriptUrl defines the url of the script to laod
  41933. * @param onSuccess defines the callback called when the script is loaded
  41934. * @param onError defines the callback to call if an error occurs
  41935. * @param scriptId defines the id of the script element
  41936. */
  41937. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41938. /**
  41939. * Load an asynchronous script (identified by an url). When the url returns, the
  41940. * content of this file is added into a new script element, attached to the DOM (body element)
  41941. * @param scriptUrl defines the url of the script to laod
  41942. * @param scriptId defines the id of the script element
  41943. * @returns a promise request object
  41944. */
  41945. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41946. /**
  41947. * Loads a file from a blob
  41948. * @param fileToLoad defines the blob to use
  41949. * @param callback defines the callback to call when data is loaded
  41950. * @param progressCallback defines the callback to call during loading process
  41951. * @returns a file request object
  41952. */
  41953. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41954. /**
  41955. * Reads a file from a File object
  41956. * @param file defines the file to load
  41957. * @param onSuccess defines the callback to call when data is loaded
  41958. * @param onProgress defines the callback to call during loading process
  41959. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41960. * @param onError defines the callback to call when an error occurs
  41961. * @returns a file request object
  41962. */
  41963. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41964. /**
  41965. * Creates a data url from a given string content
  41966. * @param content defines the content to convert
  41967. * @returns the new data url link
  41968. */
  41969. static FileAsURL(content: string): string;
  41970. /**
  41971. * Format the given number to a specific decimal format
  41972. * @param value defines the number to format
  41973. * @param decimals defines the number of decimals to use
  41974. * @returns the formatted string
  41975. */
  41976. static Format(value: number, decimals?: number): string;
  41977. /**
  41978. * Tries to copy an object by duplicating every property
  41979. * @param source defines the source object
  41980. * @param destination defines the target object
  41981. * @param doNotCopyList defines a list of properties to avoid
  41982. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41983. */
  41984. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41985. /**
  41986. * Gets a boolean indicating if the given object has no own property
  41987. * @param obj defines the object to test
  41988. * @returns true if object has no own property
  41989. */
  41990. static IsEmpty(obj: any): boolean;
  41991. /**
  41992. * Function used to register events at window level
  41993. * @param windowElement defines the Window object to use
  41994. * @param events defines the events to register
  41995. */
  41996. static RegisterTopRootEvents(windowElement: Window, events: {
  41997. name: string;
  41998. handler: Nullable<(e: FocusEvent) => any>;
  41999. }[]): void;
  42000. /**
  42001. * Function used to unregister events from window level
  42002. * @param windowElement defines the Window object to use
  42003. * @param events defines the events to unregister
  42004. */
  42005. static UnregisterTopRootEvents(windowElement: Window, events: {
  42006. name: string;
  42007. handler: Nullable<(e: FocusEvent) => any>;
  42008. }[]): void;
  42009. /**
  42010. * @ignore
  42011. */
  42012. static _ScreenshotCanvas: HTMLCanvasElement;
  42013. /**
  42014. * Dumps the current bound framebuffer
  42015. * @param width defines the rendering width
  42016. * @param height defines the rendering height
  42017. * @param engine defines the hosting engine
  42018. * @param successCallback defines the callback triggered once the data are available
  42019. * @param mimeType defines the mime type of the result
  42020. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42021. */
  42022. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42023. /**
  42024. * Converts the canvas data to blob.
  42025. * This acts as a polyfill for browsers not supporting the to blob function.
  42026. * @param canvas Defines the canvas to extract the data from
  42027. * @param successCallback Defines the callback triggered once the data are available
  42028. * @param mimeType Defines the mime type of the result
  42029. */
  42030. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42031. /**
  42032. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42033. * @param successCallback defines the callback triggered once the data are available
  42034. * @param mimeType defines the mime type of the result
  42035. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42036. */
  42037. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42038. /**
  42039. * Downloads a blob in the browser
  42040. * @param blob defines the blob to download
  42041. * @param fileName defines the name of the downloaded file
  42042. */
  42043. static Download(blob: Blob, fileName: string): void;
  42044. /**
  42045. * Will return the right value of the noPreventDefault variable
  42046. * Needed to keep backwards compatibility to the old API.
  42047. *
  42048. * @param args arguments passed to the attachControl function
  42049. * @returns the correct value for noPreventDefault
  42050. */
  42051. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42052. /**
  42053. * Captures a screenshot of the current rendering
  42054. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42055. * @param engine defines the rendering engine
  42056. * @param camera defines the source camera
  42057. * @param size This parameter can be set to a single number or to an object with the
  42058. * following (optional) properties: precision, width, height. If a single number is passed,
  42059. * it will be used for both width and height. If an object is passed, the screenshot size
  42060. * will be derived from the parameters. The precision property is a multiplier allowing
  42061. * rendering at a higher or lower resolution
  42062. * @param successCallback defines the callback receives a single parameter which contains the
  42063. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42064. * src parameter of an <img> to display it
  42065. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42066. * Check your browser for supported MIME types
  42067. */
  42068. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42069. /**
  42070. * Captures a screenshot of the current rendering
  42071. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42072. * @param engine defines the rendering engine
  42073. * @param camera defines the source camera
  42074. * @param size This parameter can be set to a single number or to an object with the
  42075. * following (optional) properties: precision, width, height. If a single number is passed,
  42076. * it will be used for both width and height. If an object is passed, the screenshot size
  42077. * will be derived from the parameters. The precision property is a multiplier allowing
  42078. * rendering at a higher or lower resolution
  42079. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42080. * Check your browser for supported MIME types
  42081. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42082. * to the src parameter of an <img> to display it
  42083. */
  42084. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42085. /**
  42086. * Generates an image screenshot from the specified camera.
  42087. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42088. * @param engine The engine to use for rendering
  42089. * @param camera The camera to use for rendering
  42090. * @param size This parameter can be set to a single number or to an object with the
  42091. * following (optional) properties: precision, width, height. If a single number is passed,
  42092. * it will be used for both width and height. If an object is passed, the screenshot size
  42093. * will be derived from the parameters. The precision property is a multiplier allowing
  42094. * rendering at a higher or lower resolution
  42095. * @param successCallback The callback receives a single parameter which contains the
  42096. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42097. * src parameter of an <img> to display it
  42098. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42099. * Check your browser for supported MIME types
  42100. * @param samples Texture samples (default: 1)
  42101. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42102. * @param fileName A name for for the downloaded file.
  42103. */
  42104. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42105. /**
  42106. * Generates an image screenshot from the specified camera.
  42107. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42108. * @param engine The engine to use for rendering
  42109. * @param camera The camera to use for rendering
  42110. * @param size This parameter can be set to a single number or to an object with the
  42111. * following (optional) properties: precision, width, height. If a single number is passed,
  42112. * it will be used for both width and height. If an object is passed, the screenshot size
  42113. * will be derived from the parameters. The precision property is a multiplier allowing
  42114. * rendering at a higher or lower resolution
  42115. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42116. * Check your browser for supported MIME types
  42117. * @param samples Texture samples (default: 1)
  42118. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42119. * @param fileName A name for for the downloaded file.
  42120. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42121. * to the src parameter of an <img> to display it
  42122. */
  42123. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42124. /**
  42125. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42126. * Be aware Math.random() could cause collisions, but:
  42127. * "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"
  42128. * @returns a pseudo random id
  42129. */
  42130. static RandomId(): string;
  42131. /**
  42132. * Test if the given uri is a base64 string
  42133. * @param uri The uri to test
  42134. * @return True if the uri is a base64 string or false otherwise
  42135. */
  42136. static IsBase64(uri: string): boolean;
  42137. /**
  42138. * Decode the given base64 uri.
  42139. * @param uri The uri to decode
  42140. * @return The decoded base64 data.
  42141. */
  42142. static DecodeBase64(uri: string): ArrayBuffer;
  42143. /**
  42144. * Gets the absolute url.
  42145. * @param url the input url
  42146. * @return the absolute url
  42147. */
  42148. static GetAbsoluteUrl(url: string): string;
  42149. /**
  42150. * No log
  42151. */
  42152. static readonly NoneLogLevel: number;
  42153. /**
  42154. * Only message logs
  42155. */
  42156. static readonly MessageLogLevel: number;
  42157. /**
  42158. * Only warning logs
  42159. */
  42160. static readonly WarningLogLevel: number;
  42161. /**
  42162. * Only error logs
  42163. */
  42164. static readonly ErrorLogLevel: number;
  42165. /**
  42166. * All logs
  42167. */
  42168. static readonly AllLogLevel: number;
  42169. /**
  42170. * Gets a value indicating the number of loading errors
  42171. * @ignorenaming
  42172. */
  42173. static get errorsCount(): number;
  42174. /**
  42175. * Callback called when a new log is added
  42176. */
  42177. static OnNewCacheEntry: (entry: string) => void;
  42178. /**
  42179. * Log a message to the console
  42180. * @param message defines the message to log
  42181. */
  42182. static Log(message: string): void;
  42183. /**
  42184. * Write a warning message to the console
  42185. * @param message defines the message to log
  42186. */
  42187. static Warn(message: string): void;
  42188. /**
  42189. * Write an error message to the console
  42190. * @param message defines the message to log
  42191. */
  42192. static Error(message: string): void;
  42193. /**
  42194. * Gets current log cache (list of logs)
  42195. */
  42196. static get LogCache(): string;
  42197. /**
  42198. * Clears the log cache
  42199. */
  42200. static ClearLogCache(): void;
  42201. /**
  42202. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42203. */
  42204. static set LogLevels(level: number);
  42205. /**
  42206. * Checks if the window object exists
  42207. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42208. */
  42209. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42210. /**
  42211. * No performance log
  42212. */
  42213. static readonly PerformanceNoneLogLevel: number;
  42214. /**
  42215. * Use user marks to log performance
  42216. */
  42217. static readonly PerformanceUserMarkLogLevel: number;
  42218. /**
  42219. * Log performance to the console
  42220. */
  42221. static readonly PerformanceConsoleLogLevel: number;
  42222. private static _performance;
  42223. /**
  42224. * Sets the current performance log level
  42225. */
  42226. static set PerformanceLogLevel(level: number);
  42227. private static _StartPerformanceCounterDisabled;
  42228. private static _EndPerformanceCounterDisabled;
  42229. private static _StartUserMark;
  42230. private static _EndUserMark;
  42231. private static _StartPerformanceConsole;
  42232. private static _EndPerformanceConsole;
  42233. /**
  42234. * Starts a performance counter
  42235. */
  42236. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42237. /**
  42238. * Ends a specific performance coutner
  42239. */
  42240. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42241. /**
  42242. * Gets either window.performance.now() if supported or Date.now() else
  42243. */
  42244. static get Now(): number;
  42245. /**
  42246. * This method will return the name of the class used to create the instance of the given object.
  42247. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42248. * @param object the object to get the class name from
  42249. * @param isType defines if the object is actually a type
  42250. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42251. */
  42252. static GetClassName(object: any, isType?: boolean): string;
  42253. /**
  42254. * Gets the first element of an array satisfying a given predicate
  42255. * @param array defines the array to browse
  42256. * @param predicate defines the predicate to use
  42257. * @returns null if not found or the element
  42258. */
  42259. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42260. /**
  42261. * This method will return the name of the full name of the class, including its owning module (if any).
  42262. * 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).
  42263. * @param object the object to get the class name from
  42264. * @param isType defines if the object is actually a type
  42265. * @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.
  42266. * @ignorenaming
  42267. */
  42268. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42269. /**
  42270. * Returns a promise that resolves after the given amount of time.
  42271. * @param delay Number of milliseconds to delay
  42272. * @returns Promise that resolves after the given amount of time
  42273. */
  42274. static DelayAsync(delay: number): Promise<void>;
  42275. /**
  42276. * Utility function to detect if the current user agent is Safari
  42277. * @returns whether or not the current user agent is safari
  42278. */
  42279. static IsSafari(): boolean;
  42280. }
  42281. /**
  42282. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42283. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42284. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42285. * @param name The name of the class, case should be preserved
  42286. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42287. */
  42288. export function className(name: string, module?: string): (target: Object) => void;
  42289. /**
  42290. * An implementation of a loop for asynchronous functions.
  42291. */
  42292. export class AsyncLoop {
  42293. /**
  42294. * Defines the number of iterations for the loop
  42295. */
  42296. iterations: number;
  42297. /**
  42298. * Defines the current index of the loop.
  42299. */
  42300. index: number;
  42301. private _done;
  42302. private _fn;
  42303. private _successCallback;
  42304. /**
  42305. * Constructor.
  42306. * @param iterations the number of iterations.
  42307. * @param func the function to run each iteration
  42308. * @param successCallback the callback that will be called upon succesful execution
  42309. * @param offset starting offset.
  42310. */
  42311. constructor(
  42312. /**
  42313. * Defines the number of iterations for the loop
  42314. */
  42315. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42316. /**
  42317. * Execute the next iteration. Must be called after the last iteration was finished.
  42318. */
  42319. executeNext(): void;
  42320. /**
  42321. * Break the loop and run the success callback.
  42322. */
  42323. breakLoop(): void;
  42324. /**
  42325. * Create and run an async loop.
  42326. * @param iterations the number of iterations.
  42327. * @param fn the function to run each iteration
  42328. * @param successCallback the callback that will be called upon succesful execution
  42329. * @param offset starting offset.
  42330. * @returns the created async loop object
  42331. */
  42332. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42333. /**
  42334. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42335. * @param iterations total number of iterations
  42336. * @param syncedIterations number of synchronous iterations in each async iteration.
  42337. * @param fn the function to call each iteration.
  42338. * @param callback a success call back that will be called when iterating stops.
  42339. * @param breakFunction a break condition (optional)
  42340. * @param timeout timeout settings for the setTimeout function. default - 0.
  42341. * @returns the created async loop object
  42342. */
  42343. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42344. }
  42345. }
  42346. declare module BABYLON {
  42347. /**
  42348. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42349. * The underlying implementation relies on an associative array to ensure the best performances.
  42350. * The value can be anything including 'null' but except 'undefined'
  42351. */
  42352. export class StringDictionary<T> {
  42353. /**
  42354. * This will clear this dictionary and copy the content from the 'source' one.
  42355. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42356. * @param source the dictionary to take the content from and copy to this dictionary
  42357. */
  42358. copyFrom(source: StringDictionary<T>): void;
  42359. /**
  42360. * Get a value based from its key
  42361. * @param key the given key to get the matching value from
  42362. * @return the value if found, otherwise undefined is returned
  42363. */
  42364. get(key: string): T | undefined;
  42365. /**
  42366. * Get a value from its key or add it if it doesn't exist.
  42367. * This method will ensure you that a given key/data will be present in the dictionary.
  42368. * @param key the given key to get the matching value from
  42369. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42370. * The factory will only be invoked if there's no data for the given key.
  42371. * @return the value corresponding to the key.
  42372. */
  42373. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42374. /**
  42375. * Get a value from its key if present in the dictionary otherwise add it
  42376. * @param key the key to get the value from
  42377. * @param val if there's no such key/value pair in the dictionary add it with this value
  42378. * @return the value corresponding to the key
  42379. */
  42380. getOrAdd(key: string, val: T): T;
  42381. /**
  42382. * Check if there's a given key in the dictionary
  42383. * @param key the key to check for
  42384. * @return true if the key is present, false otherwise
  42385. */
  42386. contains(key: string): boolean;
  42387. /**
  42388. * Add a new key and its corresponding value
  42389. * @param key the key to add
  42390. * @param value the value corresponding to the key
  42391. * @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
  42392. */
  42393. add(key: string, value: T): boolean;
  42394. /**
  42395. * Update a specific value associated to a key
  42396. * @param key defines the key to use
  42397. * @param value defines the value to store
  42398. * @returns true if the value was updated (or false if the key was not found)
  42399. */
  42400. set(key: string, value: T): boolean;
  42401. /**
  42402. * Get the element of the given key and remove it from the dictionary
  42403. * @param key defines the key to search
  42404. * @returns the value associated with the key or null if not found
  42405. */
  42406. getAndRemove(key: string): Nullable<T>;
  42407. /**
  42408. * Remove a key/value from the dictionary.
  42409. * @param key the key to remove
  42410. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42411. */
  42412. remove(key: string): boolean;
  42413. /**
  42414. * Clear the whole content of the dictionary
  42415. */
  42416. clear(): void;
  42417. /**
  42418. * Gets the current count
  42419. */
  42420. get count(): number;
  42421. /**
  42422. * Execute a callback on each key/val of the dictionary.
  42423. * Note that you can remove any element in this dictionary in the callback implementation
  42424. * @param callback the callback to execute on a given key/value pair
  42425. */
  42426. forEach(callback: (key: string, val: T) => void): void;
  42427. /**
  42428. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42429. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42430. * Note that you can remove any element in this dictionary in the callback implementation
  42431. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42432. * @returns the first item
  42433. */
  42434. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42435. private _count;
  42436. private _data;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. /** @hidden */
  42441. export interface ICollisionCoordinator {
  42442. createCollider(): Collider;
  42443. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42444. init(scene: Scene): void;
  42445. }
  42446. /** @hidden */
  42447. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42448. private _scene;
  42449. private _scaledPosition;
  42450. private _scaledVelocity;
  42451. private _finalPosition;
  42452. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42453. createCollider(): Collider;
  42454. init(scene: Scene): void;
  42455. private _collideWithWorld;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Class used to manage all inputs for the scene.
  42461. */
  42462. export class InputManager {
  42463. /** The distance in pixel that you have to move to prevent some events */
  42464. static DragMovementThreshold: number;
  42465. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42466. static LongPressDelay: number;
  42467. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42468. static DoubleClickDelay: number;
  42469. /** If you need to check double click without raising a single click at first click, enable this flag */
  42470. static ExclusiveDoubleClickMode: boolean;
  42471. /** 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. */
  42472. private _alreadyAttached;
  42473. private _alreadyAttachedTo;
  42474. private _wheelEventName;
  42475. private _onPointerMove;
  42476. private _onPointerDown;
  42477. private _onPointerUp;
  42478. private _initClickEvent;
  42479. private _initActionManager;
  42480. private _delayedSimpleClick;
  42481. private _delayedSimpleClickTimeout;
  42482. private _previousDelayedSimpleClickTimeout;
  42483. private _meshPickProceed;
  42484. private _previousButtonPressed;
  42485. private _currentPickResult;
  42486. private _previousPickResult;
  42487. private _totalPointersPressed;
  42488. private _doubleClickOccured;
  42489. private _pointerOverMesh;
  42490. private _pickedDownMesh;
  42491. private _pickedUpMesh;
  42492. private _pointerX;
  42493. private _pointerY;
  42494. private _unTranslatedPointerX;
  42495. private _unTranslatedPointerY;
  42496. private _startingPointerPosition;
  42497. private _previousStartingPointerPosition;
  42498. private _startingPointerTime;
  42499. private _previousStartingPointerTime;
  42500. private _pointerCaptures;
  42501. private _meshUnderPointerId;
  42502. private _onKeyDown;
  42503. private _onKeyUp;
  42504. private _keyboardIsAttached;
  42505. private _onCanvasFocusObserver;
  42506. private _onCanvasBlurObserver;
  42507. private _scene;
  42508. /**
  42509. * Creates a new InputManager
  42510. * @param scene defines the hosting scene
  42511. */
  42512. constructor(scene: Scene);
  42513. /**
  42514. * Gets the mesh that is currently under the pointer
  42515. */
  42516. get meshUnderPointer(): Nullable<AbstractMesh>;
  42517. /**
  42518. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42519. * @param pointerId the pointer id to use
  42520. * @returns The mesh under this pointer id or null if not found
  42521. */
  42522. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42523. /**
  42524. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42525. */
  42526. get unTranslatedPointer(): Vector2;
  42527. /**
  42528. * Gets or sets the current on-screen X position of the pointer
  42529. */
  42530. get pointerX(): number;
  42531. set pointerX(value: number);
  42532. /**
  42533. * Gets or sets the current on-screen Y position of the pointer
  42534. */
  42535. get pointerY(): number;
  42536. set pointerY(value: number);
  42537. private _updatePointerPosition;
  42538. private _processPointerMove;
  42539. private _setRayOnPointerInfo;
  42540. private _checkPrePointerObservable;
  42541. /**
  42542. * Use this method to simulate a pointer move on a mesh
  42543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42546. */
  42547. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42548. /**
  42549. * Use this method to simulate a pointer down on a mesh
  42550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42553. */
  42554. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42555. private _processPointerDown;
  42556. /** @hidden */
  42557. _isPointerSwiping(): boolean;
  42558. /**
  42559. * Use this method to simulate a pointer up on a mesh
  42560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42563. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42564. */
  42565. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42566. private _processPointerUp;
  42567. /**
  42568. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42569. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42570. * @returns true if the pointer was captured
  42571. */
  42572. isPointerCaptured(pointerId?: number): boolean;
  42573. /**
  42574. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42575. * @param attachUp defines if you want to attach events to pointerup
  42576. * @param attachDown defines if you want to attach events to pointerdown
  42577. * @param attachMove defines if you want to attach events to pointermove
  42578. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42579. */
  42580. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42581. /**
  42582. * Detaches all event handlers
  42583. */
  42584. detachControl(): void;
  42585. /**
  42586. * Force the value of meshUnderPointer
  42587. * @param mesh defines the mesh to use
  42588. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42589. */
  42590. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42591. /**
  42592. * Gets the mesh under the pointer
  42593. * @returns a Mesh or null if no mesh is under the pointer
  42594. */
  42595. getPointerOverMesh(): Nullable<AbstractMesh>;
  42596. }
  42597. }
  42598. declare module BABYLON {
  42599. /**
  42600. * This class defines the direct association between an animation and a target
  42601. */
  42602. export class TargetedAnimation {
  42603. /**
  42604. * Animation to perform
  42605. */
  42606. animation: Animation;
  42607. /**
  42608. * Target to animate
  42609. */
  42610. target: any;
  42611. /**
  42612. * Returns the string "TargetedAnimation"
  42613. * @returns "TargetedAnimation"
  42614. */
  42615. getClassName(): string;
  42616. /**
  42617. * Serialize the object
  42618. * @returns the JSON object representing the current entity
  42619. */
  42620. serialize(): any;
  42621. }
  42622. /**
  42623. * Use this class to create coordinated animations on multiple targets
  42624. */
  42625. export class AnimationGroup implements IDisposable {
  42626. /** The name of the animation group */
  42627. name: string;
  42628. private _scene;
  42629. private _targetedAnimations;
  42630. private _animatables;
  42631. private _from;
  42632. private _to;
  42633. private _isStarted;
  42634. private _isPaused;
  42635. private _speedRatio;
  42636. private _loopAnimation;
  42637. private _isAdditive;
  42638. /**
  42639. * Gets or sets the unique id of the node
  42640. */
  42641. uniqueId: number;
  42642. /**
  42643. * This observable will notify when one animation have ended
  42644. */
  42645. onAnimationEndObservable: Observable<TargetedAnimation>;
  42646. /**
  42647. * Observer raised when one animation loops
  42648. */
  42649. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42650. /**
  42651. * Observer raised when all animations have looped
  42652. */
  42653. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42654. /**
  42655. * This observable will notify when all animations have ended.
  42656. */
  42657. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42658. /**
  42659. * This observable will notify when all animations have paused.
  42660. */
  42661. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42662. /**
  42663. * This observable will notify when all animations are playing.
  42664. */
  42665. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42666. /**
  42667. * Gets the first frame
  42668. */
  42669. get from(): number;
  42670. /**
  42671. * Gets the last frame
  42672. */
  42673. get to(): number;
  42674. /**
  42675. * Define if the animations are started
  42676. */
  42677. get isStarted(): boolean;
  42678. /**
  42679. * Gets a value indicating that the current group is playing
  42680. */
  42681. get isPlaying(): boolean;
  42682. /**
  42683. * Gets or sets the speed ratio to use for all animations
  42684. */
  42685. get speedRatio(): number;
  42686. /**
  42687. * Gets or sets the speed ratio to use for all animations
  42688. */
  42689. set speedRatio(value: number);
  42690. /**
  42691. * Gets or sets if all animations should loop or not
  42692. */
  42693. get loopAnimation(): boolean;
  42694. set loopAnimation(value: boolean);
  42695. /**
  42696. * Gets or sets if all animations should be evaluated additively
  42697. */
  42698. get isAdditive(): boolean;
  42699. set isAdditive(value: boolean);
  42700. /**
  42701. * Gets the targeted animations for this animation group
  42702. */
  42703. get targetedAnimations(): Array<TargetedAnimation>;
  42704. /**
  42705. * returning the list of animatables controlled by this animation group.
  42706. */
  42707. get animatables(): Array<Animatable>;
  42708. /**
  42709. * Gets the list of target animations
  42710. */
  42711. get children(): TargetedAnimation[];
  42712. /**
  42713. * Instantiates a new Animation Group.
  42714. * This helps managing several animations at once.
  42715. * @see https://doc.babylonjs.com/how_to/group
  42716. * @param name Defines the name of the group
  42717. * @param scene Defines the scene the group belongs to
  42718. */
  42719. constructor(
  42720. /** The name of the animation group */
  42721. name: string, scene?: Nullable<Scene>);
  42722. /**
  42723. * Add an animation (with its target) in the group
  42724. * @param animation defines the animation we want to add
  42725. * @param target defines the target of the animation
  42726. * @returns the TargetedAnimation object
  42727. */
  42728. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42729. /**
  42730. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42731. * It can add constant keys at begin or end
  42732. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42733. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42734. * @returns the animation group
  42735. */
  42736. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42737. private _animationLoopCount;
  42738. private _animationLoopFlags;
  42739. private _processLoop;
  42740. /**
  42741. * Start all animations on given targets
  42742. * @param loop defines if animations must loop
  42743. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42744. * @param from defines the from key (optional)
  42745. * @param to defines the to key (optional)
  42746. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42747. * @returns the current animation group
  42748. */
  42749. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42750. /**
  42751. * Pause all animations
  42752. * @returns the animation group
  42753. */
  42754. pause(): AnimationGroup;
  42755. /**
  42756. * Play all animations to initial state
  42757. * This function will start() the animations if they were not started or will restart() them if they were paused
  42758. * @param loop defines if animations must loop
  42759. * @returns the animation group
  42760. */
  42761. play(loop?: boolean): AnimationGroup;
  42762. /**
  42763. * Reset all animations to initial state
  42764. * @returns the animation group
  42765. */
  42766. reset(): AnimationGroup;
  42767. /**
  42768. * Restart animations from key 0
  42769. * @returns the animation group
  42770. */
  42771. restart(): AnimationGroup;
  42772. /**
  42773. * Stop all animations
  42774. * @returns the animation group
  42775. */
  42776. stop(): AnimationGroup;
  42777. /**
  42778. * Set animation weight for all animatables
  42779. * @param weight defines the weight to use
  42780. * @return the animationGroup
  42781. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42782. */
  42783. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42784. /**
  42785. * Synchronize and normalize all animatables with a source animatable
  42786. * @param root defines the root animatable to synchronize with
  42787. * @return the animationGroup
  42788. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42789. */
  42790. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42791. /**
  42792. * Goes to a specific frame in this animation group
  42793. * @param frame the frame number to go to
  42794. * @return the animationGroup
  42795. */
  42796. goToFrame(frame: number): AnimationGroup;
  42797. /**
  42798. * Dispose all associated resources
  42799. */
  42800. dispose(): void;
  42801. private _checkAnimationGroupEnded;
  42802. /**
  42803. * Clone the current animation group and returns a copy
  42804. * @param newName defines the name of the new group
  42805. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42806. * @returns the new aniamtion group
  42807. */
  42808. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42809. /**
  42810. * Serializes the animationGroup to an object
  42811. * @returns Serialized object
  42812. */
  42813. serialize(): any;
  42814. /**
  42815. * Returns a new AnimationGroup object parsed from the source provided.
  42816. * @param parsedAnimationGroup defines the source
  42817. * @param scene defines the scene that will receive the animationGroup
  42818. * @returns a new AnimationGroup
  42819. */
  42820. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42821. /**
  42822. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42823. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42824. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42825. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42826. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42827. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42828. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42829. */
  42830. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42831. /**
  42832. * Returns the string "AnimationGroup"
  42833. * @returns "AnimationGroup"
  42834. */
  42835. getClassName(): string;
  42836. /**
  42837. * Creates a detailled string about the object
  42838. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42839. * @returns a string representing the object
  42840. */
  42841. toString(fullDetails?: boolean): string;
  42842. }
  42843. }
  42844. declare module BABYLON {
  42845. /**
  42846. * Define an interface for all classes that will hold resources
  42847. */
  42848. export interface IDisposable {
  42849. /**
  42850. * Releases all held resources
  42851. */
  42852. dispose(): void;
  42853. }
  42854. /** Interface defining initialization parameters for Scene class */
  42855. export interface SceneOptions {
  42856. /**
  42857. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42858. * It will improve performance when the number of geometries becomes important.
  42859. */
  42860. useGeometryUniqueIdsMap?: boolean;
  42861. /**
  42862. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42863. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42864. */
  42865. useMaterialMeshMap?: boolean;
  42866. /**
  42867. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42868. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42869. */
  42870. useClonedMeshMap?: boolean;
  42871. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42872. virtual?: boolean;
  42873. }
  42874. /**
  42875. * Represents a scene to be rendered by the engine.
  42876. * @see https://doc.babylonjs.com/features/scene
  42877. */
  42878. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42879. /** The fog is deactivated */
  42880. static readonly FOGMODE_NONE: number;
  42881. /** The fog density is following an exponential function */
  42882. static readonly FOGMODE_EXP: number;
  42883. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42884. static readonly FOGMODE_EXP2: number;
  42885. /** The fog density is following a linear function. */
  42886. static readonly FOGMODE_LINEAR: number;
  42887. /**
  42888. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42890. */
  42891. static MinDeltaTime: number;
  42892. /**
  42893. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42894. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42895. */
  42896. static MaxDeltaTime: number;
  42897. /**
  42898. * Factory used to create the default material.
  42899. * @param name The name of the material to create
  42900. * @param scene The scene to create the material for
  42901. * @returns The default material
  42902. */
  42903. static DefaultMaterialFactory(scene: Scene): Material;
  42904. /**
  42905. * Factory used to create the a collision coordinator.
  42906. * @returns The collision coordinator
  42907. */
  42908. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42909. /** @hidden */
  42910. _inputManager: InputManager;
  42911. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42912. cameraToUseForPointers: Nullable<Camera>;
  42913. /** @hidden */
  42914. readonly _isScene: boolean;
  42915. /** @hidden */
  42916. _blockEntityCollection: boolean;
  42917. /**
  42918. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42919. */
  42920. autoClear: boolean;
  42921. /**
  42922. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42923. */
  42924. autoClearDepthAndStencil: boolean;
  42925. /**
  42926. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42927. */
  42928. clearColor: Color4;
  42929. /**
  42930. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42931. */
  42932. ambientColor: Color3;
  42933. /**
  42934. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42935. * It should only be one of the following (if not the default embedded one):
  42936. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42937. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42938. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42939. * The material properties need to be setup according to the type of texture in use.
  42940. */
  42941. environmentBRDFTexture: BaseTexture;
  42942. /**
  42943. * Texture used in all pbr material as the reflection texture.
  42944. * As in the majority of the scene they are the same (exception for multi room and so on),
  42945. * this is easier to reference from here than from all the materials.
  42946. */
  42947. get environmentTexture(): Nullable<BaseTexture>;
  42948. /**
  42949. * Texture used in all pbr material as the reflection texture.
  42950. * As in the majority of the scene they are the same (exception for multi room and so on),
  42951. * this is easier to set here than in all the materials.
  42952. */
  42953. set environmentTexture(value: Nullable<BaseTexture>);
  42954. /** @hidden */
  42955. protected _environmentIntensity: number;
  42956. /**
  42957. * Intensity of the environment in all pbr material.
  42958. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42959. * As in the majority of the scene they are the same (exception for multi room and so on),
  42960. * this is easier to reference from here than from all the materials.
  42961. */
  42962. get environmentIntensity(): number;
  42963. /**
  42964. * Intensity of the environment in all pbr material.
  42965. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42966. * As in the majority of the scene they are the same (exception for multi room and so on),
  42967. * this is easier to set here than in all the materials.
  42968. */
  42969. set environmentIntensity(value: number);
  42970. /** @hidden */
  42971. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42972. /**
  42973. * Default image processing configuration used either in the rendering
  42974. * Forward main pass or through the imageProcessingPostProcess if present.
  42975. * As in the majority of the scene they are the same (exception for multi camera),
  42976. * this is easier to reference from here than from all the materials and post process.
  42977. *
  42978. * No setter as we it is a shared configuration, you can set the values instead.
  42979. */
  42980. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42981. private _forceWireframe;
  42982. /**
  42983. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42984. */
  42985. set forceWireframe(value: boolean);
  42986. get forceWireframe(): boolean;
  42987. private _skipFrustumClipping;
  42988. /**
  42989. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42990. */
  42991. set skipFrustumClipping(value: boolean);
  42992. get skipFrustumClipping(): boolean;
  42993. private _forcePointsCloud;
  42994. /**
  42995. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42996. */
  42997. set forcePointsCloud(value: boolean);
  42998. get forcePointsCloud(): boolean;
  42999. /**
  43000. * Gets or sets the active clipplane 1
  43001. */
  43002. clipPlane: Nullable<Plane>;
  43003. /**
  43004. * Gets or sets the active clipplane 2
  43005. */
  43006. clipPlane2: Nullable<Plane>;
  43007. /**
  43008. * Gets or sets the active clipplane 3
  43009. */
  43010. clipPlane3: Nullable<Plane>;
  43011. /**
  43012. * Gets or sets the active clipplane 4
  43013. */
  43014. clipPlane4: Nullable<Plane>;
  43015. /**
  43016. * Gets or sets the active clipplane 5
  43017. */
  43018. clipPlane5: Nullable<Plane>;
  43019. /**
  43020. * Gets or sets the active clipplane 6
  43021. */
  43022. clipPlane6: Nullable<Plane>;
  43023. /**
  43024. * Gets or sets a boolean indicating if animations are enabled
  43025. */
  43026. animationsEnabled: boolean;
  43027. private _animationPropertiesOverride;
  43028. /**
  43029. * Gets or sets the animation properties override
  43030. */
  43031. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43032. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43033. /**
  43034. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43035. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43036. */
  43037. useConstantAnimationDeltaTime: boolean;
  43038. /**
  43039. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43040. * Please note that it requires to run a ray cast through the scene on every frame
  43041. */
  43042. constantlyUpdateMeshUnderPointer: boolean;
  43043. /**
  43044. * Defines the HTML cursor to use when hovering over interactive elements
  43045. */
  43046. hoverCursor: string;
  43047. /**
  43048. * Defines the HTML default cursor to use (empty by default)
  43049. */
  43050. defaultCursor: string;
  43051. /**
  43052. * Defines whether cursors are handled by the scene.
  43053. */
  43054. doNotHandleCursors: boolean;
  43055. /**
  43056. * This is used to call preventDefault() on pointer down
  43057. * in order to block unwanted artifacts like system double clicks
  43058. */
  43059. preventDefaultOnPointerDown: boolean;
  43060. /**
  43061. * This is used to call preventDefault() on pointer up
  43062. * in order to block unwanted artifacts like system double clicks
  43063. */
  43064. preventDefaultOnPointerUp: boolean;
  43065. /**
  43066. * Gets or sets user defined metadata
  43067. */
  43068. metadata: any;
  43069. /**
  43070. * For internal use only. Please do not use.
  43071. */
  43072. reservedDataStore: any;
  43073. /**
  43074. * Gets the name of the plugin used to load this scene (null by default)
  43075. */
  43076. loadingPluginName: string;
  43077. /**
  43078. * Use this array to add regular expressions used to disable offline support for specific urls
  43079. */
  43080. disableOfflineSupportExceptionRules: RegExp[];
  43081. /**
  43082. * An event triggered when the scene is disposed.
  43083. */
  43084. onDisposeObservable: Observable<Scene>;
  43085. private _onDisposeObserver;
  43086. /** Sets a function to be executed when this scene is disposed. */
  43087. set onDispose(callback: () => void);
  43088. /**
  43089. * An event triggered before rendering the scene (right after animations and physics)
  43090. */
  43091. onBeforeRenderObservable: Observable<Scene>;
  43092. private _onBeforeRenderObserver;
  43093. /** Sets a function to be executed before rendering this scene */
  43094. set beforeRender(callback: Nullable<() => void>);
  43095. /**
  43096. * An event triggered after rendering the scene
  43097. */
  43098. onAfterRenderObservable: Observable<Scene>;
  43099. /**
  43100. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43101. */
  43102. onAfterRenderCameraObservable: Observable<Camera>;
  43103. private _onAfterRenderObserver;
  43104. /** Sets a function to be executed after rendering this scene */
  43105. set afterRender(callback: Nullable<() => void>);
  43106. /**
  43107. * An event triggered before animating the scene
  43108. */
  43109. onBeforeAnimationsObservable: Observable<Scene>;
  43110. /**
  43111. * An event triggered after animations processing
  43112. */
  43113. onAfterAnimationsObservable: Observable<Scene>;
  43114. /**
  43115. * An event triggered before draw calls are ready to be sent
  43116. */
  43117. onBeforeDrawPhaseObservable: Observable<Scene>;
  43118. /**
  43119. * An event triggered after draw calls have been sent
  43120. */
  43121. onAfterDrawPhaseObservable: Observable<Scene>;
  43122. /**
  43123. * An event triggered when the scene is ready
  43124. */
  43125. onReadyObservable: Observable<Scene>;
  43126. /**
  43127. * An event triggered before rendering a camera
  43128. */
  43129. onBeforeCameraRenderObservable: Observable<Camera>;
  43130. private _onBeforeCameraRenderObserver;
  43131. /** Sets a function to be executed before rendering a camera*/
  43132. set beforeCameraRender(callback: () => void);
  43133. /**
  43134. * An event triggered after rendering a camera
  43135. */
  43136. onAfterCameraRenderObservable: Observable<Camera>;
  43137. private _onAfterCameraRenderObserver;
  43138. /** Sets a function to be executed after rendering a camera*/
  43139. set afterCameraRender(callback: () => void);
  43140. /**
  43141. * An event triggered when active meshes evaluation is about to start
  43142. */
  43143. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43144. /**
  43145. * An event triggered when active meshes evaluation is done
  43146. */
  43147. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43148. /**
  43149. * An event triggered when particles rendering is about to start
  43150. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43151. */
  43152. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43153. /**
  43154. * An event triggered when particles rendering is done
  43155. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43156. */
  43157. onAfterParticlesRenderingObservable: Observable<Scene>;
  43158. /**
  43159. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43160. */
  43161. onDataLoadedObservable: Observable<Scene>;
  43162. /**
  43163. * An event triggered when a camera is created
  43164. */
  43165. onNewCameraAddedObservable: Observable<Camera>;
  43166. /**
  43167. * An event triggered when a camera is removed
  43168. */
  43169. onCameraRemovedObservable: Observable<Camera>;
  43170. /**
  43171. * An event triggered when a light is created
  43172. */
  43173. onNewLightAddedObservable: Observable<Light>;
  43174. /**
  43175. * An event triggered when a light is removed
  43176. */
  43177. onLightRemovedObservable: Observable<Light>;
  43178. /**
  43179. * An event triggered when a geometry is created
  43180. */
  43181. onNewGeometryAddedObservable: Observable<Geometry>;
  43182. /**
  43183. * An event triggered when a geometry is removed
  43184. */
  43185. onGeometryRemovedObservable: Observable<Geometry>;
  43186. /**
  43187. * An event triggered when a transform node is created
  43188. */
  43189. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43190. /**
  43191. * An event triggered when a transform node is removed
  43192. */
  43193. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43194. /**
  43195. * An event triggered when a mesh is created
  43196. */
  43197. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43198. /**
  43199. * An event triggered when a mesh is removed
  43200. */
  43201. onMeshRemovedObservable: Observable<AbstractMesh>;
  43202. /**
  43203. * An event triggered when a skeleton is created
  43204. */
  43205. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43206. /**
  43207. * An event triggered when a skeleton is removed
  43208. */
  43209. onSkeletonRemovedObservable: Observable<Skeleton>;
  43210. /**
  43211. * An event triggered when a material is created
  43212. */
  43213. onNewMaterialAddedObservable: Observable<Material>;
  43214. /**
  43215. * An event triggered when a multi material is created
  43216. */
  43217. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43218. /**
  43219. * An event triggered when a material is removed
  43220. */
  43221. onMaterialRemovedObservable: Observable<Material>;
  43222. /**
  43223. * An event triggered when a multi material is removed
  43224. */
  43225. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43226. /**
  43227. * An event triggered when a texture is created
  43228. */
  43229. onNewTextureAddedObservable: Observable<BaseTexture>;
  43230. /**
  43231. * An event triggered when a texture is removed
  43232. */
  43233. onTextureRemovedObservable: Observable<BaseTexture>;
  43234. /**
  43235. * An event triggered when render targets are about to be rendered
  43236. * Can happen multiple times per frame.
  43237. */
  43238. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43239. /**
  43240. * An event triggered when render targets were rendered.
  43241. * Can happen multiple times per frame.
  43242. */
  43243. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43244. /**
  43245. * An event triggered before calculating deterministic simulation step
  43246. */
  43247. onBeforeStepObservable: Observable<Scene>;
  43248. /**
  43249. * An event triggered after calculating deterministic simulation step
  43250. */
  43251. onAfterStepObservable: Observable<Scene>;
  43252. /**
  43253. * An event triggered when the activeCamera property is updated
  43254. */
  43255. onActiveCameraChanged: Observable<Scene>;
  43256. /**
  43257. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43258. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43259. * 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)
  43260. */
  43261. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43262. /**
  43263. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43264. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43265. * 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)
  43266. */
  43267. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43268. /**
  43269. * This Observable will when a mesh has been imported into the scene.
  43270. */
  43271. onMeshImportedObservable: Observable<AbstractMesh>;
  43272. /**
  43273. * This Observable will when an animation file has been imported into the scene.
  43274. */
  43275. onAnimationFileImportedObservable: Observable<Scene>;
  43276. /**
  43277. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43278. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43279. */
  43280. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43281. /** @hidden */
  43282. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43283. /**
  43284. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43285. */
  43286. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43287. /**
  43288. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43289. */
  43290. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43291. /**
  43292. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43293. */
  43294. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43295. /** Callback called when a pointer move is detected */
  43296. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43297. /** Callback called when a pointer down is detected */
  43298. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43299. /** Callback called when a pointer up is detected */
  43300. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43301. /** Callback called when a pointer pick is detected */
  43302. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43303. /**
  43304. * 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).
  43305. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43306. */
  43307. onPrePointerObservable: Observable<PointerInfoPre>;
  43308. /**
  43309. * Observable event triggered each time an input event is received from the rendering canvas
  43310. */
  43311. onPointerObservable: Observable<PointerInfo>;
  43312. /**
  43313. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43314. */
  43315. get unTranslatedPointer(): Vector2;
  43316. /**
  43317. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43318. */
  43319. static get DragMovementThreshold(): number;
  43320. static set DragMovementThreshold(value: number);
  43321. /**
  43322. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43323. */
  43324. static get LongPressDelay(): number;
  43325. static set LongPressDelay(value: number);
  43326. /**
  43327. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43328. */
  43329. static get DoubleClickDelay(): number;
  43330. static set DoubleClickDelay(value: number);
  43331. /** If you need to check double click without raising a single click at first click, enable this flag */
  43332. static get ExclusiveDoubleClickMode(): boolean;
  43333. static set ExclusiveDoubleClickMode(value: boolean);
  43334. /** @hidden */
  43335. _mirroredCameraPosition: Nullable<Vector3>;
  43336. /**
  43337. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43338. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43339. */
  43340. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43341. /**
  43342. * Observable event triggered each time an keyboard event is received from the hosting window
  43343. */
  43344. onKeyboardObservable: Observable<KeyboardInfo>;
  43345. private _useRightHandedSystem;
  43346. /**
  43347. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43348. */
  43349. set useRightHandedSystem(value: boolean);
  43350. get useRightHandedSystem(): boolean;
  43351. private _timeAccumulator;
  43352. private _currentStepId;
  43353. private _currentInternalStep;
  43354. /**
  43355. * Sets the step Id used by deterministic lock step
  43356. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43357. * @param newStepId defines the step Id
  43358. */
  43359. setStepId(newStepId: number): void;
  43360. /**
  43361. * Gets the step Id used by deterministic lock step
  43362. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43363. * @returns the step Id
  43364. */
  43365. getStepId(): number;
  43366. /**
  43367. * Gets the internal step used by deterministic lock step
  43368. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43369. * @returns the internal step
  43370. */
  43371. getInternalStep(): number;
  43372. private _fogEnabled;
  43373. /**
  43374. * Gets or sets a boolean indicating if fog is enabled on this scene
  43375. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43376. * (Default is true)
  43377. */
  43378. set fogEnabled(value: boolean);
  43379. get fogEnabled(): boolean;
  43380. private _fogMode;
  43381. /**
  43382. * Gets or sets the fog mode to use
  43383. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43384. * | mode | value |
  43385. * | --- | --- |
  43386. * | FOGMODE_NONE | 0 |
  43387. * | FOGMODE_EXP | 1 |
  43388. * | FOGMODE_EXP2 | 2 |
  43389. * | FOGMODE_LINEAR | 3 |
  43390. */
  43391. set fogMode(value: number);
  43392. get fogMode(): number;
  43393. /**
  43394. * Gets or sets the fog color to use
  43395. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43396. * (Default is Color3(0.2, 0.2, 0.3))
  43397. */
  43398. fogColor: Color3;
  43399. /**
  43400. * Gets or sets the fog density to use
  43401. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43402. * (Default is 0.1)
  43403. */
  43404. fogDensity: number;
  43405. /**
  43406. * Gets or sets the fog start distance to use
  43407. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43408. * (Default is 0)
  43409. */
  43410. fogStart: number;
  43411. /**
  43412. * Gets or sets the fog end distance to use
  43413. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43414. * (Default is 1000)
  43415. */
  43416. fogEnd: number;
  43417. /**
  43418. * Flag indicating that the frame buffer binding is handled by another component
  43419. */
  43420. prePass: boolean;
  43421. private _shadowsEnabled;
  43422. /**
  43423. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43424. */
  43425. set shadowsEnabled(value: boolean);
  43426. get shadowsEnabled(): boolean;
  43427. private _lightsEnabled;
  43428. /**
  43429. * Gets or sets a boolean indicating if lights are enabled on this scene
  43430. */
  43431. set lightsEnabled(value: boolean);
  43432. get lightsEnabled(): boolean;
  43433. /** All of the active cameras added to this scene. */
  43434. activeCameras: Nullable<Camera[]>;
  43435. /** @hidden */
  43436. _activeCamera: Nullable<Camera>;
  43437. /** Gets or sets the current active camera */
  43438. get activeCamera(): Nullable<Camera>;
  43439. set activeCamera(value: Nullable<Camera>);
  43440. private _defaultMaterial;
  43441. /** The default material used on meshes when no material is affected */
  43442. get defaultMaterial(): Material;
  43443. /** The default material used on meshes when no material is affected */
  43444. set defaultMaterial(value: Material);
  43445. private _texturesEnabled;
  43446. /**
  43447. * Gets or sets a boolean indicating if textures are enabled on this scene
  43448. */
  43449. set texturesEnabled(value: boolean);
  43450. get texturesEnabled(): boolean;
  43451. /**
  43452. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43453. */
  43454. physicsEnabled: boolean;
  43455. /**
  43456. * Gets or sets a boolean indicating if particles are enabled on this scene
  43457. */
  43458. particlesEnabled: boolean;
  43459. /**
  43460. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43461. */
  43462. spritesEnabled: boolean;
  43463. private _skeletonsEnabled;
  43464. /**
  43465. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43466. */
  43467. set skeletonsEnabled(value: boolean);
  43468. get skeletonsEnabled(): boolean;
  43469. /**
  43470. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43471. */
  43472. lensFlaresEnabled: boolean;
  43473. /**
  43474. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43475. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43476. */
  43477. collisionsEnabled: boolean;
  43478. private _collisionCoordinator;
  43479. /** @hidden */
  43480. get collisionCoordinator(): ICollisionCoordinator;
  43481. /**
  43482. * Defines the gravity applied to this scene (used only for collisions)
  43483. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43484. */
  43485. gravity: Vector3;
  43486. /**
  43487. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43488. */
  43489. postProcessesEnabled: boolean;
  43490. /**
  43491. * Gets the current postprocess manager
  43492. */
  43493. postProcessManager: PostProcessManager;
  43494. /**
  43495. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43496. */
  43497. renderTargetsEnabled: boolean;
  43498. /**
  43499. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43500. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43501. */
  43502. dumpNextRenderTargets: boolean;
  43503. /**
  43504. * The list of user defined render targets added to the scene
  43505. */
  43506. customRenderTargets: RenderTargetTexture[];
  43507. /**
  43508. * Defines if texture loading must be delayed
  43509. * If true, textures will only be loaded when they need to be rendered
  43510. */
  43511. useDelayedTextureLoading: boolean;
  43512. /**
  43513. * Gets the list of meshes imported to the scene through SceneLoader
  43514. */
  43515. importedMeshesFiles: String[];
  43516. /**
  43517. * Gets or sets a boolean indicating if probes are enabled on this scene
  43518. */
  43519. probesEnabled: boolean;
  43520. /**
  43521. * Gets or sets the current offline provider to use to store scene data
  43522. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43523. */
  43524. offlineProvider: IOfflineProvider;
  43525. /**
  43526. * Gets or sets the action manager associated with the scene
  43527. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43528. */
  43529. actionManager: AbstractActionManager;
  43530. private _meshesForIntersections;
  43531. /**
  43532. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43533. */
  43534. proceduralTexturesEnabled: boolean;
  43535. private _engine;
  43536. private _totalVertices;
  43537. /** @hidden */
  43538. _activeIndices: PerfCounter;
  43539. /** @hidden */
  43540. _activeParticles: PerfCounter;
  43541. /** @hidden */
  43542. _activeBones: PerfCounter;
  43543. private _animationRatio;
  43544. /** @hidden */
  43545. _animationTimeLast: number;
  43546. /** @hidden */
  43547. _animationTime: number;
  43548. /**
  43549. * Gets or sets a general scale for animation speed
  43550. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43551. */
  43552. animationTimeScale: number;
  43553. /** @hidden */
  43554. _cachedMaterial: Nullable<Material>;
  43555. /** @hidden */
  43556. _cachedEffect: Nullable<Effect>;
  43557. /** @hidden */
  43558. _cachedVisibility: Nullable<number>;
  43559. private _renderId;
  43560. private _frameId;
  43561. private _executeWhenReadyTimeoutId;
  43562. private _intermediateRendering;
  43563. private _viewUpdateFlag;
  43564. private _projectionUpdateFlag;
  43565. /** @hidden */
  43566. _toBeDisposed: Nullable<IDisposable>[];
  43567. private _activeRequests;
  43568. /** @hidden */
  43569. _pendingData: any[];
  43570. private _isDisposed;
  43571. /**
  43572. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43573. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43574. */
  43575. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43576. private _activeMeshes;
  43577. private _processedMaterials;
  43578. private _renderTargets;
  43579. /** @hidden */
  43580. _activeParticleSystems: SmartArray<IParticleSystem>;
  43581. private _activeSkeletons;
  43582. private _softwareSkinnedMeshes;
  43583. private _renderingManager;
  43584. /** @hidden */
  43585. _activeAnimatables: Animatable[];
  43586. private _transformMatrix;
  43587. private _sceneUbo;
  43588. /** @hidden */
  43589. _viewMatrix: Matrix;
  43590. private _projectionMatrix;
  43591. /** @hidden */
  43592. _forcedViewPosition: Nullable<Vector3>;
  43593. /** @hidden */
  43594. _frustumPlanes: Plane[];
  43595. /**
  43596. * Gets the list of frustum planes (built from the active camera)
  43597. */
  43598. get frustumPlanes(): Plane[];
  43599. /**
  43600. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43601. * This is useful if there are more lights that the maximum simulteanous authorized
  43602. */
  43603. requireLightSorting: boolean;
  43604. /** @hidden */
  43605. readonly useMaterialMeshMap: boolean;
  43606. /** @hidden */
  43607. readonly useClonedMeshMap: boolean;
  43608. private _externalData;
  43609. private _uid;
  43610. /**
  43611. * @hidden
  43612. * Backing store of defined scene components.
  43613. */
  43614. _components: ISceneComponent[];
  43615. /**
  43616. * @hidden
  43617. * Backing store of defined scene components.
  43618. */
  43619. _serializableComponents: ISceneSerializableComponent[];
  43620. /**
  43621. * List of components to register on the next registration step.
  43622. */
  43623. private _transientComponents;
  43624. /**
  43625. * Registers the transient components if needed.
  43626. */
  43627. private _registerTransientComponents;
  43628. /**
  43629. * @hidden
  43630. * Add a component to the scene.
  43631. * Note that the ccomponent could be registered on th next frame if this is called after
  43632. * the register component stage.
  43633. * @param component Defines the component to add to the scene
  43634. */
  43635. _addComponent(component: ISceneComponent): void;
  43636. /**
  43637. * @hidden
  43638. * Gets a component from the scene.
  43639. * @param name defines the name of the component to retrieve
  43640. * @returns the component or null if not present
  43641. */
  43642. _getComponent(name: string): Nullable<ISceneComponent>;
  43643. /**
  43644. * @hidden
  43645. * Defines the actions happening before camera updates.
  43646. */
  43647. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43648. /**
  43649. * @hidden
  43650. * Defines the actions happening before clear the canvas.
  43651. */
  43652. _beforeClearStage: Stage<SimpleStageAction>;
  43653. /**
  43654. * @hidden
  43655. * Defines the actions when collecting render targets for the frame.
  43656. */
  43657. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43658. /**
  43659. * @hidden
  43660. * Defines the actions happening for one camera in the frame.
  43661. */
  43662. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43663. /**
  43664. * @hidden
  43665. * Defines the actions happening during the per mesh ready checks.
  43666. */
  43667. _isReadyForMeshStage: Stage<MeshStageAction>;
  43668. /**
  43669. * @hidden
  43670. * Defines the actions happening before evaluate active mesh checks.
  43671. */
  43672. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43673. /**
  43674. * @hidden
  43675. * Defines the actions happening during the evaluate sub mesh checks.
  43676. */
  43677. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43678. /**
  43679. * @hidden
  43680. * Defines the actions happening during the active mesh stage.
  43681. */
  43682. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43683. /**
  43684. * @hidden
  43685. * Defines the actions happening during the per camera render target step.
  43686. */
  43687. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43688. /**
  43689. * @hidden
  43690. * Defines the actions happening just before the active camera is drawing.
  43691. */
  43692. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43693. /**
  43694. * @hidden
  43695. * Defines the actions happening just before a render target is drawing.
  43696. */
  43697. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43698. /**
  43699. * @hidden
  43700. * Defines the actions happening just before a rendering group is drawing.
  43701. */
  43702. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43703. /**
  43704. * @hidden
  43705. * Defines the actions happening just before a mesh is drawing.
  43706. */
  43707. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43708. /**
  43709. * @hidden
  43710. * Defines the actions happening just after a mesh has been drawn.
  43711. */
  43712. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43713. /**
  43714. * @hidden
  43715. * Defines the actions happening just after a rendering group has been drawn.
  43716. */
  43717. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43718. /**
  43719. * @hidden
  43720. * Defines the actions happening just after the active camera has been drawn.
  43721. */
  43722. _afterCameraDrawStage: Stage<CameraStageAction>;
  43723. /**
  43724. * @hidden
  43725. * Defines the actions happening just after a render target has been drawn.
  43726. */
  43727. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43728. /**
  43729. * @hidden
  43730. * Defines the actions happening just after rendering all cameras and computing intersections.
  43731. */
  43732. _afterRenderStage: Stage<SimpleStageAction>;
  43733. /**
  43734. * @hidden
  43735. * Defines the actions happening when a pointer move event happens.
  43736. */
  43737. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43738. /**
  43739. * @hidden
  43740. * Defines the actions happening when a pointer down event happens.
  43741. */
  43742. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43743. /**
  43744. * @hidden
  43745. * Defines the actions happening when a pointer up event happens.
  43746. */
  43747. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43748. /**
  43749. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43750. */
  43751. private geometriesByUniqueId;
  43752. /**
  43753. * Creates a new Scene
  43754. * @param engine defines the engine to use to render this scene
  43755. * @param options defines the scene options
  43756. */
  43757. constructor(engine: Engine, options?: SceneOptions);
  43758. /**
  43759. * Gets a string identifying the name of the class
  43760. * @returns "Scene" string
  43761. */
  43762. getClassName(): string;
  43763. private _defaultMeshCandidates;
  43764. /**
  43765. * @hidden
  43766. */
  43767. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43768. private _defaultSubMeshCandidates;
  43769. /**
  43770. * @hidden
  43771. */
  43772. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43773. /**
  43774. * Sets the default candidate providers for the scene.
  43775. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43776. * and getCollidingSubMeshCandidates to their default function
  43777. */
  43778. setDefaultCandidateProviders(): void;
  43779. /**
  43780. * Gets the mesh that is currently under the pointer
  43781. */
  43782. get meshUnderPointer(): Nullable<AbstractMesh>;
  43783. /**
  43784. * Gets or sets the current on-screen X position of the pointer
  43785. */
  43786. get pointerX(): number;
  43787. set pointerX(value: number);
  43788. /**
  43789. * Gets or sets the current on-screen Y position of the pointer
  43790. */
  43791. get pointerY(): number;
  43792. set pointerY(value: number);
  43793. /**
  43794. * Gets the cached material (ie. the latest rendered one)
  43795. * @returns the cached material
  43796. */
  43797. getCachedMaterial(): Nullable<Material>;
  43798. /**
  43799. * Gets the cached effect (ie. the latest rendered one)
  43800. * @returns the cached effect
  43801. */
  43802. getCachedEffect(): Nullable<Effect>;
  43803. /**
  43804. * Gets the cached visibility state (ie. the latest rendered one)
  43805. * @returns the cached visibility state
  43806. */
  43807. getCachedVisibility(): Nullable<number>;
  43808. /**
  43809. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43810. * @param material defines the current material
  43811. * @param effect defines the current effect
  43812. * @param visibility defines the current visibility state
  43813. * @returns true if one parameter is not cached
  43814. */
  43815. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43816. /**
  43817. * Gets the engine associated with the scene
  43818. * @returns an Engine
  43819. */
  43820. getEngine(): Engine;
  43821. /**
  43822. * Gets the total number of vertices rendered per frame
  43823. * @returns the total number of vertices rendered per frame
  43824. */
  43825. getTotalVertices(): number;
  43826. /**
  43827. * Gets the performance counter for total vertices
  43828. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43829. */
  43830. get totalVerticesPerfCounter(): PerfCounter;
  43831. /**
  43832. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43833. * @returns the total number of active indices rendered per frame
  43834. */
  43835. getActiveIndices(): number;
  43836. /**
  43837. * Gets the performance counter for active indices
  43838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43839. */
  43840. get totalActiveIndicesPerfCounter(): PerfCounter;
  43841. /**
  43842. * Gets the total number of active particles rendered per frame
  43843. * @returns the total number of active particles rendered per frame
  43844. */
  43845. getActiveParticles(): number;
  43846. /**
  43847. * Gets the performance counter for active particles
  43848. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43849. */
  43850. get activeParticlesPerfCounter(): PerfCounter;
  43851. /**
  43852. * Gets the total number of active bones rendered per frame
  43853. * @returns the total number of active bones rendered per frame
  43854. */
  43855. getActiveBones(): number;
  43856. /**
  43857. * Gets the performance counter for active bones
  43858. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43859. */
  43860. get activeBonesPerfCounter(): PerfCounter;
  43861. /**
  43862. * Gets the array of active meshes
  43863. * @returns an array of AbstractMesh
  43864. */
  43865. getActiveMeshes(): SmartArray<AbstractMesh>;
  43866. /**
  43867. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43868. * @returns a number
  43869. */
  43870. getAnimationRatio(): number;
  43871. /**
  43872. * Gets an unique Id for the current render phase
  43873. * @returns a number
  43874. */
  43875. getRenderId(): number;
  43876. /**
  43877. * Gets an unique Id for the current frame
  43878. * @returns a number
  43879. */
  43880. getFrameId(): number;
  43881. /** Call this function if you want to manually increment the render Id*/
  43882. incrementRenderId(): void;
  43883. private _createUbo;
  43884. /**
  43885. * Use this method to simulate a pointer move on a mesh
  43886. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43887. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43888. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43889. * @returns the current scene
  43890. */
  43891. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43892. /**
  43893. * Use this method to simulate a pointer down on a mesh
  43894. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43895. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43896. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43897. * @returns the current scene
  43898. */
  43899. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43900. /**
  43901. * Use this method to simulate a pointer up on a mesh
  43902. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43903. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43904. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43905. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43906. * @returns the current scene
  43907. */
  43908. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43909. /**
  43910. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43911. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43912. * @returns true if the pointer was captured
  43913. */
  43914. isPointerCaptured(pointerId?: number): boolean;
  43915. /**
  43916. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43917. * @param attachUp defines if you want to attach events to pointerup
  43918. * @param attachDown defines if you want to attach events to pointerdown
  43919. * @param attachMove defines if you want to attach events to pointermove
  43920. */
  43921. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43922. /** Detaches all event handlers*/
  43923. detachControl(): void;
  43924. /**
  43925. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43926. * Delay loaded resources are not taking in account
  43927. * @return true if all required resources are ready
  43928. */
  43929. isReady(): boolean;
  43930. /** Resets all cached information relative to material (including effect and visibility) */
  43931. resetCachedMaterial(): void;
  43932. /**
  43933. * Registers a function to be called before every frame render
  43934. * @param func defines the function to register
  43935. */
  43936. registerBeforeRender(func: () => void): void;
  43937. /**
  43938. * Unregisters a function called before every frame render
  43939. * @param func defines the function to unregister
  43940. */
  43941. unregisterBeforeRender(func: () => void): void;
  43942. /**
  43943. * Registers a function to be called after every frame render
  43944. * @param func defines the function to register
  43945. */
  43946. registerAfterRender(func: () => void): void;
  43947. /**
  43948. * Unregisters a function called after every frame render
  43949. * @param func defines the function to unregister
  43950. */
  43951. unregisterAfterRender(func: () => void): void;
  43952. private _executeOnceBeforeRender;
  43953. /**
  43954. * The provided function will run before render once and will be disposed afterwards.
  43955. * A timeout delay can be provided so that the function will be executed in N ms.
  43956. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43957. * @param func The function to be executed.
  43958. * @param timeout optional delay in ms
  43959. */
  43960. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43961. /** @hidden */
  43962. _addPendingData(data: any): void;
  43963. /** @hidden */
  43964. _removePendingData(data: any): void;
  43965. /**
  43966. * Returns the number of items waiting to be loaded
  43967. * @returns the number of items waiting to be loaded
  43968. */
  43969. getWaitingItemsCount(): number;
  43970. /**
  43971. * Returns a boolean indicating if the scene is still loading data
  43972. */
  43973. get isLoading(): boolean;
  43974. /**
  43975. * Registers a function to be executed when the scene is ready
  43976. * @param {Function} func - the function to be executed
  43977. */
  43978. executeWhenReady(func: () => void): void;
  43979. /**
  43980. * Returns a promise that resolves when the scene is ready
  43981. * @returns A promise that resolves when the scene is ready
  43982. */
  43983. whenReadyAsync(): Promise<void>;
  43984. /** @hidden */
  43985. _checkIsReady(): void;
  43986. /**
  43987. * Gets all animatable attached to the scene
  43988. */
  43989. get animatables(): Animatable[];
  43990. /**
  43991. * Resets the last animation time frame.
  43992. * Useful to override when animations start running when loading a scene for the first time.
  43993. */
  43994. resetLastAnimationTimeFrame(): void;
  43995. /**
  43996. * Gets the current view matrix
  43997. * @returns a Matrix
  43998. */
  43999. getViewMatrix(): Matrix;
  44000. /**
  44001. * Gets the current projection matrix
  44002. * @returns a Matrix
  44003. */
  44004. getProjectionMatrix(): Matrix;
  44005. /**
  44006. * Gets the current transform matrix
  44007. * @returns a Matrix made of View * Projection
  44008. */
  44009. getTransformMatrix(): Matrix;
  44010. /**
  44011. * Sets the current transform matrix
  44012. * @param viewL defines the View matrix to use
  44013. * @param projectionL defines the Projection matrix to use
  44014. * @param viewR defines the right View matrix to use (if provided)
  44015. * @param projectionR defines the right Projection matrix to use (if provided)
  44016. */
  44017. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44018. /**
  44019. * Gets the uniform buffer used to store scene data
  44020. * @returns a UniformBuffer
  44021. */
  44022. getSceneUniformBuffer(): UniformBuffer;
  44023. /**
  44024. * Gets an unique (relatively to the current scene) Id
  44025. * @returns an unique number for the scene
  44026. */
  44027. getUniqueId(): number;
  44028. /**
  44029. * Add a mesh to the list of scene's meshes
  44030. * @param newMesh defines the mesh to add
  44031. * @param recursive if all child meshes should also be added to the scene
  44032. */
  44033. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44034. /**
  44035. * Remove a mesh for the list of scene's meshes
  44036. * @param toRemove defines the mesh to remove
  44037. * @param recursive if all child meshes should also be removed from the scene
  44038. * @returns the index where the mesh was in the mesh list
  44039. */
  44040. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44041. /**
  44042. * Add a transform node to the list of scene's transform nodes
  44043. * @param newTransformNode defines the transform node to add
  44044. */
  44045. addTransformNode(newTransformNode: TransformNode): void;
  44046. /**
  44047. * Remove a transform node for the list of scene's transform nodes
  44048. * @param toRemove defines the transform node to remove
  44049. * @returns the index where the transform node was in the transform node list
  44050. */
  44051. removeTransformNode(toRemove: TransformNode): number;
  44052. /**
  44053. * Remove a skeleton for the list of scene's skeletons
  44054. * @param toRemove defines the skeleton to remove
  44055. * @returns the index where the skeleton was in the skeleton list
  44056. */
  44057. removeSkeleton(toRemove: Skeleton): number;
  44058. /**
  44059. * Remove a morph target for the list of scene's morph targets
  44060. * @param toRemove defines the morph target to remove
  44061. * @returns the index where the morph target was in the morph target list
  44062. */
  44063. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44064. /**
  44065. * Remove a light for the list of scene's lights
  44066. * @param toRemove defines the light to remove
  44067. * @returns the index where the light was in the light list
  44068. */
  44069. removeLight(toRemove: Light): number;
  44070. /**
  44071. * Remove a camera for the list of scene's cameras
  44072. * @param toRemove defines the camera to remove
  44073. * @returns the index where the camera was in the camera list
  44074. */
  44075. removeCamera(toRemove: Camera): number;
  44076. /**
  44077. * Remove a particle system for the list of scene's particle systems
  44078. * @param toRemove defines the particle system to remove
  44079. * @returns the index where the particle system was in the particle system list
  44080. */
  44081. removeParticleSystem(toRemove: IParticleSystem): number;
  44082. /**
  44083. * Remove a animation for the list of scene's animations
  44084. * @param toRemove defines the animation to remove
  44085. * @returns the index where the animation was in the animation list
  44086. */
  44087. removeAnimation(toRemove: Animation): number;
  44088. /**
  44089. * Will stop the animation of the given target
  44090. * @param target - the target
  44091. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44092. * @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)
  44093. */
  44094. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44095. /**
  44096. * Removes the given animation group from this scene.
  44097. * @param toRemove The animation group to remove
  44098. * @returns The index of the removed animation group
  44099. */
  44100. removeAnimationGroup(toRemove: AnimationGroup): number;
  44101. /**
  44102. * Removes the given multi-material from this scene.
  44103. * @param toRemove The multi-material to remove
  44104. * @returns The index of the removed multi-material
  44105. */
  44106. removeMultiMaterial(toRemove: MultiMaterial): number;
  44107. /**
  44108. * Removes the given material from this scene.
  44109. * @param toRemove The material to remove
  44110. * @returns The index of the removed material
  44111. */
  44112. removeMaterial(toRemove: Material): number;
  44113. /**
  44114. * Removes the given action manager from this scene.
  44115. * @param toRemove The action manager to remove
  44116. * @returns The index of the removed action manager
  44117. */
  44118. removeActionManager(toRemove: AbstractActionManager): number;
  44119. /**
  44120. * Removes the given texture from this scene.
  44121. * @param toRemove The texture to remove
  44122. * @returns The index of the removed texture
  44123. */
  44124. removeTexture(toRemove: BaseTexture): number;
  44125. /**
  44126. * Adds the given light to this scene
  44127. * @param newLight The light to add
  44128. */
  44129. addLight(newLight: Light): void;
  44130. /**
  44131. * Sorts the list list based on light priorities
  44132. */
  44133. sortLightsByPriority(): void;
  44134. /**
  44135. * Adds the given camera to this scene
  44136. * @param newCamera The camera to add
  44137. */
  44138. addCamera(newCamera: Camera): void;
  44139. /**
  44140. * Adds the given skeleton to this scene
  44141. * @param newSkeleton The skeleton to add
  44142. */
  44143. addSkeleton(newSkeleton: Skeleton): void;
  44144. /**
  44145. * Adds the given particle system to this scene
  44146. * @param newParticleSystem The particle system to add
  44147. */
  44148. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44149. /**
  44150. * Adds the given animation to this scene
  44151. * @param newAnimation The animation to add
  44152. */
  44153. addAnimation(newAnimation: Animation): void;
  44154. /**
  44155. * Adds the given animation group to this scene.
  44156. * @param newAnimationGroup The animation group to add
  44157. */
  44158. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44159. /**
  44160. * Adds the given multi-material to this scene
  44161. * @param newMultiMaterial The multi-material to add
  44162. */
  44163. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44164. /**
  44165. * Adds the given material to this scene
  44166. * @param newMaterial The material to add
  44167. */
  44168. addMaterial(newMaterial: Material): void;
  44169. /**
  44170. * Adds the given morph target to this scene
  44171. * @param newMorphTargetManager The morph target to add
  44172. */
  44173. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44174. /**
  44175. * Adds the given geometry to this scene
  44176. * @param newGeometry The geometry to add
  44177. */
  44178. addGeometry(newGeometry: Geometry): void;
  44179. /**
  44180. * Adds the given action manager to this scene
  44181. * @param newActionManager The action manager to add
  44182. */
  44183. addActionManager(newActionManager: AbstractActionManager): void;
  44184. /**
  44185. * Adds the given texture to this scene.
  44186. * @param newTexture The texture to add
  44187. */
  44188. addTexture(newTexture: BaseTexture): void;
  44189. /**
  44190. * Switch active camera
  44191. * @param newCamera defines the new active camera
  44192. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44193. */
  44194. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44195. /**
  44196. * sets the active camera of the scene using its ID
  44197. * @param id defines the camera's ID
  44198. * @return the new active camera or null if none found.
  44199. */
  44200. setActiveCameraByID(id: string): Nullable<Camera>;
  44201. /**
  44202. * sets the active camera of the scene using its name
  44203. * @param name defines the camera's name
  44204. * @returns the new active camera or null if none found.
  44205. */
  44206. setActiveCameraByName(name: string): Nullable<Camera>;
  44207. /**
  44208. * get an animation group using its name
  44209. * @param name defines the material's name
  44210. * @return the animation group or null if none found.
  44211. */
  44212. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44213. /**
  44214. * Get a material using its unique id
  44215. * @param uniqueId defines the material's unique id
  44216. * @return the material or null if none found.
  44217. */
  44218. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44219. /**
  44220. * get a material using its id
  44221. * @param id defines the material's ID
  44222. * @return the material or null if none found.
  44223. */
  44224. getMaterialByID(id: string): Nullable<Material>;
  44225. /**
  44226. * Gets a the last added material using a given id
  44227. * @param id defines the material's ID
  44228. * @return the last material with the given id or null if none found.
  44229. */
  44230. getLastMaterialByID(id: string): Nullable<Material>;
  44231. /**
  44232. * Gets a material using its name
  44233. * @param name defines the material's name
  44234. * @return the material or null if none found.
  44235. */
  44236. getMaterialByName(name: string): Nullable<Material>;
  44237. /**
  44238. * Get a texture using its unique id
  44239. * @param uniqueId defines the texture's unique id
  44240. * @return the texture or null if none found.
  44241. */
  44242. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44243. /**
  44244. * Gets a camera using its id
  44245. * @param id defines the id to look for
  44246. * @returns the camera or null if not found
  44247. */
  44248. getCameraByID(id: string): Nullable<Camera>;
  44249. /**
  44250. * Gets a camera using its unique id
  44251. * @param uniqueId defines the unique id to look for
  44252. * @returns the camera or null if not found
  44253. */
  44254. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44255. /**
  44256. * Gets a camera using its name
  44257. * @param name defines the camera's name
  44258. * @return the camera or null if none found.
  44259. */
  44260. getCameraByName(name: string): Nullable<Camera>;
  44261. /**
  44262. * Gets a bone using its id
  44263. * @param id defines the bone's id
  44264. * @return the bone or null if not found
  44265. */
  44266. getBoneByID(id: string): Nullable<Bone>;
  44267. /**
  44268. * Gets a bone using its id
  44269. * @param name defines the bone's name
  44270. * @return the bone or null if not found
  44271. */
  44272. getBoneByName(name: string): Nullable<Bone>;
  44273. /**
  44274. * Gets a light node using its name
  44275. * @param name defines the the light's name
  44276. * @return the light or null if none found.
  44277. */
  44278. getLightByName(name: string): Nullable<Light>;
  44279. /**
  44280. * Gets a light node using its id
  44281. * @param id defines the light's id
  44282. * @return the light or null if none found.
  44283. */
  44284. getLightByID(id: string): Nullable<Light>;
  44285. /**
  44286. * Gets a light node using its scene-generated unique ID
  44287. * @param uniqueId defines the light's unique id
  44288. * @return the light or null if none found.
  44289. */
  44290. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44291. /**
  44292. * Gets a particle system by id
  44293. * @param id defines the particle system id
  44294. * @return the corresponding system or null if none found
  44295. */
  44296. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44297. /**
  44298. * Gets a geometry using its ID
  44299. * @param id defines the geometry's id
  44300. * @return the geometry or null if none found.
  44301. */
  44302. getGeometryByID(id: string): Nullable<Geometry>;
  44303. private _getGeometryByUniqueID;
  44304. /**
  44305. * Add a new geometry to this scene
  44306. * @param geometry defines the geometry to be added to the scene.
  44307. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44308. * @return a boolean defining if the geometry was added or not
  44309. */
  44310. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44311. /**
  44312. * Removes an existing geometry
  44313. * @param geometry defines the geometry to be removed from the scene
  44314. * @return a boolean defining if the geometry was removed or not
  44315. */
  44316. removeGeometry(geometry: Geometry): boolean;
  44317. /**
  44318. * Gets the list of geometries attached to the scene
  44319. * @returns an array of Geometry
  44320. */
  44321. getGeometries(): Geometry[];
  44322. /**
  44323. * Gets the first added mesh found of a given ID
  44324. * @param id defines the id to search for
  44325. * @return the mesh found or null if not found at all
  44326. */
  44327. getMeshByID(id: string): Nullable<AbstractMesh>;
  44328. /**
  44329. * Gets a list of meshes using their id
  44330. * @param id defines the id to search for
  44331. * @returns a list of meshes
  44332. */
  44333. getMeshesByID(id: string): Array<AbstractMesh>;
  44334. /**
  44335. * Gets the first added transform node found of a given ID
  44336. * @param id defines the id to search for
  44337. * @return the found transform node or null if not found at all.
  44338. */
  44339. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44340. /**
  44341. * Gets a transform node with its auto-generated unique id
  44342. * @param uniqueId efines the unique id to search for
  44343. * @return the found transform node or null if not found at all.
  44344. */
  44345. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44346. /**
  44347. * Gets a list of transform nodes using their id
  44348. * @param id defines the id to search for
  44349. * @returns a list of transform nodes
  44350. */
  44351. getTransformNodesByID(id: string): Array<TransformNode>;
  44352. /**
  44353. * Gets a mesh with its auto-generated unique id
  44354. * @param uniqueId defines the unique id to search for
  44355. * @return the found mesh or null if not found at all.
  44356. */
  44357. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44358. /**
  44359. * Gets a the last added mesh using a given id
  44360. * @param id defines the id to search for
  44361. * @return the found mesh or null if not found at all.
  44362. */
  44363. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44364. /**
  44365. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44366. * @param id defines the id to search for
  44367. * @return the found node or null if not found at all
  44368. */
  44369. getLastEntryByID(id: string): Nullable<Node>;
  44370. /**
  44371. * Gets a node (Mesh, Camera, Light) using a given id
  44372. * @param id defines the id to search for
  44373. * @return the found node or null if not found at all
  44374. */
  44375. getNodeByID(id: string): Nullable<Node>;
  44376. /**
  44377. * Gets a node (Mesh, Camera, Light) using a given name
  44378. * @param name defines the name to search for
  44379. * @return the found node or null if not found at all.
  44380. */
  44381. getNodeByName(name: string): Nullable<Node>;
  44382. /**
  44383. * Gets a mesh using a given name
  44384. * @param name defines the name to search for
  44385. * @return the found mesh or null if not found at all.
  44386. */
  44387. getMeshByName(name: string): Nullable<AbstractMesh>;
  44388. /**
  44389. * Gets a transform node using a given name
  44390. * @param name defines the name to search for
  44391. * @return the found transform node or null if not found at all.
  44392. */
  44393. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44394. /**
  44395. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44396. * @param id defines the id to search for
  44397. * @return the found skeleton or null if not found at all.
  44398. */
  44399. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44400. /**
  44401. * Gets a skeleton using a given auto generated unique id
  44402. * @param uniqueId defines the unique id to search for
  44403. * @return the found skeleton or null if not found at all.
  44404. */
  44405. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44406. /**
  44407. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44408. * @param id defines the id to search for
  44409. * @return the found skeleton or null if not found at all.
  44410. */
  44411. getSkeletonById(id: string): Nullable<Skeleton>;
  44412. /**
  44413. * Gets a skeleton using a given name
  44414. * @param name defines the name to search for
  44415. * @return the found skeleton or null if not found at all.
  44416. */
  44417. getSkeletonByName(name: string): Nullable<Skeleton>;
  44418. /**
  44419. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44420. * @param id defines the id to search for
  44421. * @return the found morph target manager or null if not found at all.
  44422. */
  44423. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44424. /**
  44425. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44426. * @param id defines the id to search for
  44427. * @return the found morph target or null if not found at all.
  44428. */
  44429. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44430. /**
  44431. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44432. * @param name defines the name to search for
  44433. * @return the found morph target or null if not found at all.
  44434. */
  44435. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44436. /**
  44437. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44438. * @param name defines the name to search for
  44439. * @return the found post process or null if not found at all.
  44440. */
  44441. getPostProcessByName(name: string): Nullable<PostProcess>;
  44442. /**
  44443. * Gets a boolean indicating if the given mesh is active
  44444. * @param mesh defines the mesh to look for
  44445. * @returns true if the mesh is in the active list
  44446. */
  44447. isActiveMesh(mesh: AbstractMesh): boolean;
  44448. /**
  44449. * Return a unique id as a string which can serve as an identifier for the scene
  44450. */
  44451. get uid(): string;
  44452. /**
  44453. * Add an externaly attached data from its key.
  44454. * This method call will fail and return false, if such key already exists.
  44455. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44456. * @param key the unique key that identifies the data
  44457. * @param data the data object to associate to the key for this Engine instance
  44458. * @return true if no such key were already present and the data was added successfully, false otherwise
  44459. */
  44460. addExternalData<T>(key: string, data: T): boolean;
  44461. /**
  44462. * Get an externaly attached data from its key
  44463. * @param key the unique key that identifies the data
  44464. * @return the associated data, if present (can be null), or undefined if not present
  44465. */
  44466. getExternalData<T>(key: string): Nullable<T>;
  44467. /**
  44468. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44469. * @param key the unique key that identifies the data
  44470. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44471. * @return the associated data, can be null if the factory returned null.
  44472. */
  44473. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44474. /**
  44475. * Remove an externaly attached data from the Engine instance
  44476. * @param key the unique key that identifies the data
  44477. * @return true if the data was successfully removed, false if it doesn't exist
  44478. */
  44479. removeExternalData(key: string): boolean;
  44480. private _evaluateSubMesh;
  44481. /**
  44482. * Clear the processed materials smart array preventing retention point in material dispose.
  44483. */
  44484. freeProcessedMaterials(): void;
  44485. private _preventFreeActiveMeshesAndRenderingGroups;
  44486. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44487. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44488. * when disposing several meshes in a row or a hierarchy of meshes.
  44489. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44490. */
  44491. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44492. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44493. /**
  44494. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44495. */
  44496. freeActiveMeshes(): void;
  44497. /**
  44498. * Clear the info related to rendering groups preventing retention points during dispose.
  44499. */
  44500. freeRenderingGroups(): void;
  44501. /** @hidden */
  44502. _isInIntermediateRendering(): boolean;
  44503. /**
  44504. * Lambda returning the list of potentially active meshes.
  44505. */
  44506. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44507. /**
  44508. * Lambda returning the list of potentially active sub meshes.
  44509. */
  44510. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44511. /**
  44512. * Lambda returning the list of potentially intersecting sub meshes.
  44513. */
  44514. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44515. /**
  44516. * Lambda returning the list of potentially colliding sub meshes.
  44517. */
  44518. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44519. /** @hidden */
  44520. _activeMeshesFrozen: boolean;
  44521. private _skipEvaluateActiveMeshesCompletely;
  44522. /**
  44523. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44524. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44525. * @param onSuccess optional success callback
  44526. * @param onError optional error callback
  44527. * @returns the current scene
  44528. */
  44529. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44530. /**
  44531. * Use this function to restart evaluating active meshes on every frame
  44532. * @returns the current scene
  44533. */
  44534. unfreezeActiveMeshes(): Scene;
  44535. private _evaluateActiveMeshes;
  44536. private _activeMesh;
  44537. /**
  44538. * Update the transform matrix to update from the current active camera
  44539. * @param force defines a boolean used to force the update even if cache is up to date
  44540. */
  44541. updateTransformMatrix(force?: boolean): void;
  44542. private _bindFrameBuffer;
  44543. /** @hidden */
  44544. _allowPostProcessClearColor: boolean;
  44545. /** @hidden */
  44546. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44547. private _processSubCameras;
  44548. private _checkIntersections;
  44549. /** @hidden */
  44550. _advancePhysicsEngineStep(step: number): void;
  44551. /**
  44552. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44553. */
  44554. getDeterministicFrameTime: () => number;
  44555. /** @hidden */
  44556. _animate(): void;
  44557. /** Execute all animations (for a frame) */
  44558. animate(): void;
  44559. /**
  44560. * Render the scene
  44561. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44562. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44563. */
  44564. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44565. /**
  44566. * Freeze all materials
  44567. * A frozen material will not be updatable but should be faster to render
  44568. */
  44569. freezeMaterials(): void;
  44570. /**
  44571. * Unfreeze all materials
  44572. * A frozen material will not be updatable but should be faster to render
  44573. */
  44574. unfreezeMaterials(): void;
  44575. /**
  44576. * Releases all held ressources
  44577. */
  44578. dispose(): void;
  44579. /**
  44580. * Gets if the scene is already disposed
  44581. */
  44582. get isDisposed(): boolean;
  44583. /**
  44584. * Call this function to reduce memory footprint of the scene.
  44585. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44586. */
  44587. clearCachedVertexData(): void;
  44588. /**
  44589. * This function will remove the local cached buffer data from texture.
  44590. * It will save memory but will prevent the texture from being rebuilt
  44591. */
  44592. cleanCachedTextureBuffer(): void;
  44593. /**
  44594. * Get the world extend vectors with an optional filter
  44595. *
  44596. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44597. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44598. */
  44599. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44600. min: Vector3;
  44601. max: Vector3;
  44602. };
  44603. /**
  44604. * Creates a ray that can be used to pick in the scene
  44605. * @param x defines the x coordinate of the origin (on-screen)
  44606. * @param y defines the y coordinate of the origin (on-screen)
  44607. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44608. * @param camera defines the camera to use for the picking
  44609. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44610. * @returns a Ray
  44611. */
  44612. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44613. /**
  44614. * Creates a ray that can be used to pick in the scene
  44615. * @param x defines the x coordinate of the origin (on-screen)
  44616. * @param y defines the y coordinate of the origin (on-screen)
  44617. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44618. * @param result defines the ray where to store the picking ray
  44619. * @param camera defines the camera to use for the picking
  44620. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44621. * @returns the current scene
  44622. */
  44623. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44624. /**
  44625. * Creates a ray that can be used to pick in the scene
  44626. * @param x defines the x coordinate of the origin (on-screen)
  44627. * @param y defines the y coordinate of the origin (on-screen)
  44628. * @param camera defines the camera to use for the picking
  44629. * @returns a Ray
  44630. */
  44631. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44632. /**
  44633. * Creates a ray that can be used to pick in the scene
  44634. * @param x defines the x coordinate of the origin (on-screen)
  44635. * @param y defines the y coordinate of the origin (on-screen)
  44636. * @param result defines the ray where to store the picking ray
  44637. * @param camera defines the camera to use for the picking
  44638. * @returns the current scene
  44639. */
  44640. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44641. /** Launch a ray to try to pick a mesh in the scene
  44642. * @param x position on screen
  44643. * @param y position on screen
  44644. * @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
  44645. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44646. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44647. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44648. * @returns a PickingInfo
  44649. */
  44650. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44651. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44652. * @param x position on screen
  44653. * @param y position on screen
  44654. * @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
  44655. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44656. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44657. * @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)
  44658. */
  44659. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44660. /** Use the given ray to pick a mesh in the scene
  44661. * @param ray The ray to use to pick meshes
  44662. * @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
  44663. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44664. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44665. * @returns a PickingInfo
  44666. */
  44667. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44668. /**
  44669. * Launch a ray to try to pick a mesh in the scene
  44670. * @param x X position on screen
  44671. * @param y Y position on screen
  44672. * @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
  44673. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44674. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44675. * @returns an array of PickingInfo
  44676. */
  44677. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44678. /**
  44679. * Launch a ray to try to pick a mesh in the scene
  44680. * @param ray Ray to use
  44681. * @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
  44682. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44683. * @returns an array of PickingInfo
  44684. */
  44685. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44686. /**
  44687. * Force the value of meshUnderPointer
  44688. * @param mesh defines the mesh to use
  44689. * @param pointerId optional pointer id when using more than one pointer
  44690. */
  44691. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44692. /**
  44693. * Gets the mesh under the pointer
  44694. * @returns a Mesh or null if no mesh is under the pointer
  44695. */
  44696. getPointerOverMesh(): Nullable<AbstractMesh>;
  44697. /** @hidden */
  44698. _rebuildGeometries(): void;
  44699. /** @hidden */
  44700. _rebuildTextures(): void;
  44701. private _getByTags;
  44702. /**
  44703. * Get a list of meshes by tags
  44704. * @param tagsQuery defines the tags query to use
  44705. * @param forEach defines a predicate used to filter results
  44706. * @returns an array of Mesh
  44707. */
  44708. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44709. /**
  44710. * Get a list of cameras by tags
  44711. * @param tagsQuery defines the tags query to use
  44712. * @param forEach defines a predicate used to filter results
  44713. * @returns an array of Camera
  44714. */
  44715. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44716. /**
  44717. * Get a list of lights by tags
  44718. * @param tagsQuery defines the tags query to use
  44719. * @param forEach defines a predicate used to filter results
  44720. * @returns an array of Light
  44721. */
  44722. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44723. /**
  44724. * Get a list of materials by tags
  44725. * @param tagsQuery defines the tags query to use
  44726. * @param forEach defines a predicate used to filter results
  44727. * @returns an array of Material
  44728. */
  44729. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44730. /**
  44731. * Get a list of transform nodes by tags
  44732. * @param tagsQuery defines the tags query to use
  44733. * @param forEach defines a predicate used to filter results
  44734. * @returns an array of TransformNode
  44735. */
  44736. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44737. /**
  44738. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44739. * This allowed control for front to back rendering or reversly depending of the special needs.
  44740. *
  44741. * @param renderingGroupId The rendering group id corresponding to its index
  44742. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44743. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44744. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44745. */
  44746. 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;
  44747. /**
  44748. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44749. *
  44750. * @param renderingGroupId The rendering group id corresponding to its index
  44751. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44752. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44753. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44754. */
  44755. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44756. /**
  44757. * Gets the current auto clear configuration for one rendering group of the rendering
  44758. * manager.
  44759. * @param index the rendering group index to get the information for
  44760. * @returns The auto clear setup for the requested rendering group
  44761. */
  44762. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44763. private _blockMaterialDirtyMechanism;
  44764. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44765. get blockMaterialDirtyMechanism(): boolean;
  44766. set blockMaterialDirtyMechanism(value: boolean);
  44767. /**
  44768. * Will flag all materials as dirty to trigger new shader compilation
  44769. * @param flag defines the flag used to specify which material part must be marked as dirty
  44770. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44771. */
  44772. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44773. /** @hidden */
  44774. _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;
  44775. /** @hidden */
  44776. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44777. /** @hidden */
  44778. _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;
  44779. /** @hidden */
  44780. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44781. /** @hidden */
  44782. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44783. /** @hidden */
  44784. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44785. }
  44786. }
  44787. declare module BABYLON {
  44788. /**
  44789. * Set of assets to keep when moving a scene into an asset container.
  44790. */
  44791. export class KeepAssets extends AbstractScene {
  44792. }
  44793. /**
  44794. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44795. */
  44796. export class InstantiatedEntries {
  44797. /**
  44798. * List of new root nodes (eg. nodes with no parent)
  44799. */
  44800. rootNodes: TransformNode[];
  44801. /**
  44802. * List of new skeletons
  44803. */
  44804. skeletons: Skeleton[];
  44805. /**
  44806. * List of new animation groups
  44807. */
  44808. animationGroups: AnimationGroup[];
  44809. }
  44810. /**
  44811. * Container with a set of assets that can be added or removed from a scene.
  44812. */
  44813. export class AssetContainer extends AbstractScene {
  44814. private _wasAddedToScene;
  44815. /**
  44816. * The scene the AssetContainer belongs to.
  44817. */
  44818. scene: Scene;
  44819. /**
  44820. * Instantiates an AssetContainer.
  44821. * @param scene The scene the AssetContainer belongs to.
  44822. */
  44823. constructor(scene: Scene);
  44824. /**
  44825. * Instantiate or clone all meshes and add the new ones to the scene.
  44826. * Skeletons and animation groups will all be cloned
  44827. * @param nameFunction defines an optional function used to get new names for clones
  44828. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44829. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44830. */
  44831. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44832. /**
  44833. * Adds all the assets from the container to the scene.
  44834. */
  44835. addAllToScene(): void;
  44836. /**
  44837. * Removes all the assets in the container from the scene
  44838. */
  44839. removeAllFromScene(): void;
  44840. /**
  44841. * Disposes all the assets in the container
  44842. */
  44843. dispose(): void;
  44844. private _moveAssets;
  44845. /**
  44846. * Removes all the assets contained in the scene and adds them to the container.
  44847. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44848. */
  44849. moveAllFromScene(keepAssets?: KeepAssets): void;
  44850. /**
  44851. * 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.
  44852. * @returns the root mesh
  44853. */
  44854. createRootMesh(): Mesh;
  44855. /**
  44856. * Merge animations (direct and animation groups) from this asset container into a scene
  44857. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44858. * @param animatables set of animatables to retarget to a node from the scene
  44859. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44860. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44861. */
  44862. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44863. }
  44864. }
  44865. declare module BABYLON {
  44866. /**
  44867. * Defines how the parser contract is defined.
  44868. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44869. */
  44870. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44871. /**
  44872. * Defines how the individual parser contract is defined.
  44873. * These parser can parse an individual asset
  44874. */
  44875. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44876. /**
  44877. * Base class of the scene acting as a container for the different elements composing a scene.
  44878. * This class is dynamically extended by the different components of the scene increasing
  44879. * flexibility and reducing coupling
  44880. */
  44881. export abstract class AbstractScene {
  44882. /**
  44883. * Stores the list of available parsers in the application.
  44884. */
  44885. private static _BabylonFileParsers;
  44886. /**
  44887. * Stores the list of available individual parsers in the application.
  44888. */
  44889. private static _IndividualBabylonFileParsers;
  44890. /**
  44891. * Adds a parser in the list of available ones
  44892. * @param name Defines the name of the parser
  44893. * @param parser Defines the parser to add
  44894. */
  44895. static AddParser(name: string, parser: BabylonFileParser): void;
  44896. /**
  44897. * Gets a general parser from the list of avaialble ones
  44898. * @param name Defines the name of the parser
  44899. * @returns the requested parser or null
  44900. */
  44901. static GetParser(name: string): Nullable<BabylonFileParser>;
  44902. /**
  44903. * Adds n individual parser in the list of available ones
  44904. * @param name Defines the name of the parser
  44905. * @param parser Defines the parser to add
  44906. */
  44907. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44908. /**
  44909. * Gets an individual parser from the list of avaialble ones
  44910. * @param name Defines the name of the parser
  44911. * @returns the requested parser or null
  44912. */
  44913. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44914. /**
  44915. * Parser json data and populate both a scene and its associated container object
  44916. * @param jsonData Defines the data to parse
  44917. * @param scene Defines the scene to parse the data for
  44918. * @param container Defines the container attached to the parsing sequence
  44919. * @param rootUrl Defines the root url of the data
  44920. */
  44921. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44922. /**
  44923. * Gets the list of root nodes (ie. nodes with no parent)
  44924. */
  44925. rootNodes: Node[];
  44926. /** All of the cameras added to this scene
  44927. * @see https://doc.babylonjs.com/babylon101/cameras
  44928. */
  44929. cameras: Camera[];
  44930. /**
  44931. * All of the lights added to this scene
  44932. * @see https://doc.babylonjs.com/babylon101/lights
  44933. */
  44934. lights: Light[];
  44935. /**
  44936. * All of the (abstract) meshes added to this scene
  44937. */
  44938. meshes: AbstractMesh[];
  44939. /**
  44940. * The list of skeletons added to the scene
  44941. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44942. */
  44943. skeletons: Skeleton[];
  44944. /**
  44945. * All of the particle systems added to this scene
  44946. * @see https://doc.babylonjs.com/babylon101/particles
  44947. */
  44948. particleSystems: IParticleSystem[];
  44949. /**
  44950. * Gets a list of Animations associated with the scene
  44951. */
  44952. animations: Animation[];
  44953. /**
  44954. * All of the animation groups added to this scene
  44955. * @see https://doc.babylonjs.com/how_to/group
  44956. */
  44957. animationGroups: AnimationGroup[];
  44958. /**
  44959. * All of the multi-materials added to this scene
  44960. * @see https://doc.babylonjs.com/how_to/multi_materials
  44961. */
  44962. multiMaterials: MultiMaterial[];
  44963. /**
  44964. * All of the materials added to this scene
  44965. * In the context of a Scene, it is not supposed to be modified manually.
  44966. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44967. * Note also that the order of the Material within the array is not significant and might change.
  44968. * @see https://doc.babylonjs.com/babylon101/materials
  44969. */
  44970. materials: Material[];
  44971. /**
  44972. * The list of morph target managers added to the scene
  44973. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44974. */
  44975. morphTargetManagers: MorphTargetManager[];
  44976. /**
  44977. * The list of geometries used in the scene.
  44978. */
  44979. geometries: Geometry[];
  44980. /**
  44981. * All of the tranform nodes added to this scene
  44982. * In the context of a Scene, it is not supposed to be modified manually.
  44983. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44984. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44985. * @see https://doc.babylonjs.com/how_to/transformnode
  44986. */
  44987. transformNodes: TransformNode[];
  44988. /**
  44989. * ActionManagers available on the scene.
  44990. */
  44991. actionManagers: AbstractActionManager[];
  44992. /**
  44993. * Textures to keep.
  44994. */
  44995. textures: BaseTexture[];
  44996. /** @hidden */
  44997. protected _environmentTexture: Nullable<BaseTexture>;
  44998. /**
  44999. * Texture used in all pbr material as the reflection texture.
  45000. * As in the majority of the scene they are the same (exception for multi room and so on),
  45001. * this is easier to reference from here than from all the materials.
  45002. */
  45003. get environmentTexture(): Nullable<BaseTexture>;
  45004. set environmentTexture(value: Nullable<BaseTexture>);
  45005. /**
  45006. * The list of postprocesses added to the scene
  45007. */
  45008. postProcesses: PostProcess[];
  45009. /**
  45010. * @returns all meshes, lights, cameras, transformNodes and bones
  45011. */
  45012. getNodes(): Array<Node>;
  45013. }
  45014. }
  45015. declare module BABYLON {
  45016. /**
  45017. * Interface used to define options for Sound class
  45018. */
  45019. export interface ISoundOptions {
  45020. /**
  45021. * Does the sound autoplay once loaded.
  45022. */
  45023. autoplay?: boolean;
  45024. /**
  45025. * Does the sound loop after it finishes playing once.
  45026. */
  45027. loop?: boolean;
  45028. /**
  45029. * Sound's volume
  45030. */
  45031. volume?: number;
  45032. /**
  45033. * Is it a spatial sound?
  45034. */
  45035. spatialSound?: boolean;
  45036. /**
  45037. * Maximum distance to hear that sound
  45038. */
  45039. maxDistance?: number;
  45040. /**
  45041. * Uses user defined attenuation function
  45042. */
  45043. useCustomAttenuation?: boolean;
  45044. /**
  45045. * Define the roll off factor of spatial sounds.
  45046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45047. */
  45048. rolloffFactor?: number;
  45049. /**
  45050. * Define the reference distance the sound should be heard perfectly.
  45051. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45052. */
  45053. refDistance?: number;
  45054. /**
  45055. * Define the distance attenuation model the sound will follow.
  45056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45057. */
  45058. distanceModel?: string;
  45059. /**
  45060. * Defines the playback speed (1 by default)
  45061. */
  45062. playbackRate?: number;
  45063. /**
  45064. * Defines if the sound is from a streaming source
  45065. */
  45066. streaming?: boolean;
  45067. /**
  45068. * Defines an optional length (in seconds) inside the sound file
  45069. */
  45070. length?: number;
  45071. /**
  45072. * Defines an optional offset (in seconds) inside the sound file
  45073. */
  45074. offset?: number;
  45075. /**
  45076. * If true, URLs will not be required to state the audio file codec to use.
  45077. */
  45078. skipCodecCheck?: boolean;
  45079. }
  45080. }
  45081. declare module BABYLON {
  45082. /**
  45083. * Defines a sound that can be played in the application.
  45084. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45086. */
  45087. export class Sound {
  45088. /**
  45089. * The name of the sound in the scene.
  45090. */
  45091. name: string;
  45092. /**
  45093. * Does the sound autoplay once loaded.
  45094. */
  45095. autoplay: boolean;
  45096. /**
  45097. * Does the sound loop after it finishes playing once.
  45098. */
  45099. loop: boolean;
  45100. /**
  45101. * Does the sound use a custom attenuation curve to simulate the falloff
  45102. * happening when the source gets further away from the camera.
  45103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45104. */
  45105. useCustomAttenuation: boolean;
  45106. /**
  45107. * The sound track id this sound belongs to.
  45108. */
  45109. soundTrackId: number;
  45110. /**
  45111. * Is this sound currently played.
  45112. */
  45113. isPlaying: boolean;
  45114. /**
  45115. * Is this sound currently paused.
  45116. */
  45117. isPaused: boolean;
  45118. /**
  45119. * Does this sound enables spatial sound.
  45120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45121. */
  45122. spatialSound: boolean;
  45123. /**
  45124. * Define the reference distance the sound should be heard perfectly.
  45125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45126. */
  45127. refDistance: number;
  45128. /**
  45129. * Define the roll off factor of spatial sounds.
  45130. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45131. */
  45132. rolloffFactor: number;
  45133. /**
  45134. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45136. */
  45137. maxDistance: number;
  45138. /**
  45139. * Define the distance attenuation model the sound will follow.
  45140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45141. */
  45142. distanceModel: string;
  45143. /**
  45144. * @hidden
  45145. * Back Compat
  45146. **/
  45147. onended: () => any;
  45148. /**
  45149. * Gets or sets an object used to store user defined information for the sound.
  45150. */
  45151. metadata: any;
  45152. /**
  45153. * Observable event when the current playing sound finishes.
  45154. */
  45155. onEndedObservable: Observable<Sound>;
  45156. /**
  45157. * Gets the current time for the sound.
  45158. */
  45159. get currentTime(): number;
  45160. private _panningModel;
  45161. private _playbackRate;
  45162. private _streaming;
  45163. private _startTime;
  45164. private _startOffset;
  45165. private _position;
  45166. /** @hidden */
  45167. _positionInEmitterSpace: boolean;
  45168. private _localDirection;
  45169. private _volume;
  45170. private _isReadyToPlay;
  45171. private _isDirectional;
  45172. private _readyToPlayCallback;
  45173. private _audioBuffer;
  45174. private _soundSource;
  45175. private _streamingSource;
  45176. private _soundPanner;
  45177. private _soundGain;
  45178. private _inputAudioNode;
  45179. private _outputAudioNode;
  45180. private _coneInnerAngle;
  45181. private _coneOuterAngle;
  45182. private _coneOuterGain;
  45183. private _scene;
  45184. private _connectedTransformNode;
  45185. private _customAttenuationFunction;
  45186. private _registerFunc;
  45187. private _isOutputConnected;
  45188. private _htmlAudioElement;
  45189. private _urlType;
  45190. private _length?;
  45191. private _offset?;
  45192. /** @hidden */
  45193. static _SceneComponentInitialization: (scene: Scene) => void;
  45194. /**
  45195. * Create a sound and attach it to a scene
  45196. * @param name Name of your sound
  45197. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45198. * @param scene defines the scene the sound belongs to
  45199. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45200. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45201. */
  45202. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45203. /**
  45204. * Release the sound and its associated resources
  45205. */
  45206. dispose(): void;
  45207. /**
  45208. * Gets if the sounds is ready to be played or not.
  45209. * @returns true if ready, otherwise false
  45210. */
  45211. isReady(): boolean;
  45212. private _soundLoaded;
  45213. /**
  45214. * Sets the data of the sound from an audiobuffer
  45215. * @param audioBuffer The audioBuffer containing the data
  45216. */
  45217. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45218. /**
  45219. * Updates the current sounds options such as maxdistance, loop...
  45220. * @param options A JSON object containing values named as the object properties
  45221. */
  45222. updateOptions(options: ISoundOptions): void;
  45223. private _createSpatialParameters;
  45224. private _updateSpatialParameters;
  45225. /**
  45226. * Switch the panning model to HRTF:
  45227. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45228. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45229. */
  45230. switchPanningModelToHRTF(): void;
  45231. /**
  45232. * Switch the panning model to Equal Power:
  45233. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45235. */
  45236. switchPanningModelToEqualPower(): void;
  45237. private _switchPanningModel;
  45238. /**
  45239. * Connect this sound to a sound track audio node like gain...
  45240. * @param soundTrackAudioNode the sound track audio node to connect to
  45241. */
  45242. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45243. /**
  45244. * Transform this sound into a directional source
  45245. * @param coneInnerAngle Size of the inner cone in degree
  45246. * @param coneOuterAngle Size of the outer cone in degree
  45247. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45248. */
  45249. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45250. /**
  45251. * Gets or sets the inner angle for the directional cone.
  45252. */
  45253. get directionalConeInnerAngle(): number;
  45254. /**
  45255. * Gets or sets the inner angle for the directional cone.
  45256. */
  45257. set directionalConeInnerAngle(value: number);
  45258. /**
  45259. * Gets or sets the outer angle for the directional cone.
  45260. */
  45261. get directionalConeOuterAngle(): number;
  45262. /**
  45263. * Gets or sets the outer angle for the directional cone.
  45264. */
  45265. set directionalConeOuterAngle(value: number);
  45266. /**
  45267. * Sets the position of the emitter if spatial sound is enabled
  45268. * @param newPosition Defines the new posisiton
  45269. */
  45270. setPosition(newPosition: Vector3): void;
  45271. /**
  45272. * Sets the local direction of the emitter if spatial sound is enabled
  45273. * @param newLocalDirection Defines the new local direction
  45274. */
  45275. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45276. private _updateDirection;
  45277. /** @hidden */
  45278. updateDistanceFromListener(): void;
  45279. /**
  45280. * Sets a new custom attenuation function for the sound.
  45281. * @param callback Defines the function used for the attenuation
  45282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45283. */
  45284. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45285. /**
  45286. * Play the sound
  45287. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45288. * @param offset (optional) Start the sound at a specific time in seconds
  45289. * @param length (optional) Sound duration (in seconds)
  45290. */
  45291. play(time?: number, offset?: number, length?: number): void;
  45292. private _onended;
  45293. /**
  45294. * Stop the sound
  45295. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45296. */
  45297. stop(time?: number): void;
  45298. /**
  45299. * Put the sound in pause
  45300. */
  45301. pause(): void;
  45302. /**
  45303. * Sets a dedicated volume for this sounds
  45304. * @param newVolume Define the new volume of the sound
  45305. * @param time Define time for gradual change to new volume
  45306. */
  45307. setVolume(newVolume: number, time?: number): void;
  45308. /**
  45309. * Set the sound play back rate
  45310. * @param newPlaybackRate Define the playback rate the sound should be played at
  45311. */
  45312. setPlaybackRate(newPlaybackRate: number): void;
  45313. /**
  45314. * Gets the volume of the sound.
  45315. * @returns the volume of the sound
  45316. */
  45317. getVolume(): number;
  45318. /**
  45319. * Attach the sound to a dedicated mesh
  45320. * @param transformNode The transform node to connect the sound with
  45321. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45322. */
  45323. attachToMesh(transformNode: TransformNode): void;
  45324. /**
  45325. * Detach the sound from the previously attached mesh
  45326. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45327. */
  45328. detachFromMesh(): void;
  45329. private _onRegisterAfterWorldMatrixUpdate;
  45330. /**
  45331. * Clone the current sound in the scene.
  45332. * @returns the new sound clone
  45333. */
  45334. clone(): Nullable<Sound>;
  45335. /**
  45336. * Gets the current underlying audio buffer containing the data
  45337. * @returns the audio buffer
  45338. */
  45339. getAudioBuffer(): Nullable<AudioBuffer>;
  45340. /**
  45341. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45342. * @returns the source node
  45343. */
  45344. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45345. /**
  45346. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45347. * @returns the gain node
  45348. */
  45349. getSoundGain(): Nullable<GainNode>;
  45350. /**
  45351. * Serializes the Sound in a JSON representation
  45352. * @returns the JSON representation of the sound
  45353. */
  45354. serialize(): any;
  45355. /**
  45356. * Parse a JSON representation of a sound to innstantiate in a given scene
  45357. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45358. * @param scene Define the scene the new parsed sound should be created in
  45359. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45360. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45361. * @returns the newly parsed sound
  45362. */
  45363. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45364. }
  45365. }
  45366. declare module BABYLON {
  45367. /**
  45368. * This defines an action helpful to play a defined sound on a triggered action.
  45369. */
  45370. export class PlaySoundAction extends Action {
  45371. private _sound;
  45372. /**
  45373. * Instantiate the action
  45374. * @param triggerOptions defines the trigger options
  45375. * @param sound defines the sound to play
  45376. * @param condition defines the trigger related conditions
  45377. */
  45378. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45379. /** @hidden */
  45380. _prepare(): void;
  45381. /**
  45382. * Execute the action and play the sound.
  45383. */
  45384. execute(): void;
  45385. /**
  45386. * Serializes the actions and its related information.
  45387. * @param parent defines the object to serialize in
  45388. * @returns the serialized object
  45389. */
  45390. serialize(parent: any): any;
  45391. }
  45392. /**
  45393. * This defines an action helpful to stop a defined sound on a triggered action.
  45394. */
  45395. export class StopSoundAction extends Action {
  45396. private _sound;
  45397. /**
  45398. * Instantiate the action
  45399. * @param triggerOptions defines the trigger options
  45400. * @param sound defines the sound to stop
  45401. * @param condition defines the trigger related conditions
  45402. */
  45403. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45404. /** @hidden */
  45405. _prepare(): void;
  45406. /**
  45407. * Execute the action and stop the sound.
  45408. */
  45409. execute(): void;
  45410. /**
  45411. * Serializes the actions and its related information.
  45412. * @param parent defines the object to serialize in
  45413. * @returns the serialized object
  45414. */
  45415. serialize(parent: any): any;
  45416. }
  45417. }
  45418. declare module BABYLON {
  45419. /**
  45420. * This defines an action responsible to change the value of a property
  45421. * by interpolating between its current value and the newly set one once triggered.
  45422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45423. */
  45424. export class InterpolateValueAction extends Action {
  45425. /**
  45426. * Defines the path of the property where the value should be interpolated
  45427. */
  45428. propertyPath: string;
  45429. /**
  45430. * Defines the target value at the end of the interpolation.
  45431. */
  45432. value: any;
  45433. /**
  45434. * Defines the time it will take for the property to interpolate to the value.
  45435. */
  45436. duration: number;
  45437. /**
  45438. * Defines if the other scene animations should be stopped when the action has been triggered
  45439. */
  45440. stopOtherAnimations?: boolean;
  45441. /**
  45442. * Defines a callback raised once the interpolation animation has been done.
  45443. */
  45444. onInterpolationDone?: () => void;
  45445. /**
  45446. * Observable triggered once the interpolation animation has been done.
  45447. */
  45448. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45449. private _target;
  45450. private _effectiveTarget;
  45451. private _property;
  45452. /**
  45453. * Instantiate the action
  45454. * @param triggerOptions defines the trigger options
  45455. * @param target defines the object containing the value to interpolate
  45456. * @param propertyPath defines the path to the property in the target object
  45457. * @param value defines the target value at the end of the interpolation
  45458. * @param duration deines the time it will take for the property to interpolate to the value.
  45459. * @param condition defines the trigger related conditions
  45460. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45461. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45462. */
  45463. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45464. /** @hidden */
  45465. _prepare(): void;
  45466. /**
  45467. * Execute the action starts the value interpolation.
  45468. */
  45469. execute(): void;
  45470. /**
  45471. * Serializes the actions and its related information.
  45472. * @param parent defines the object to serialize in
  45473. * @returns the serialized object
  45474. */
  45475. serialize(parent: any): any;
  45476. }
  45477. }
  45478. declare module BABYLON {
  45479. /**
  45480. * This represents the default audio engine used in babylon.
  45481. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45482. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45483. */
  45484. export class AudioEngine implements IAudioEngine {
  45485. private _audioContext;
  45486. private _audioContextInitialized;
  45487. private _muteButton;
  45488. private _hostElement;
  45489. /**
  45490. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45491. */
  45492. canUseWebAudio: boolean;
  45493. /**
  45494. * The master gain node defines the global audio volume of your audio engine.
  45495. */
  45496. masterGain: GainNode;
  45497. /**
  45498. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45499. * @ignoreNaming
  45500. */
  45501. WarnedWebAudioUnsupported: boolean;
  45502. /**
  45503. * Gets whether or not mp3 are supported by your browser.
  45504. */
  45505. isMP3supported: boolean;
  45506. /**
  45507. * Gets whether or not ogg are supported by your browser.
  45508. */
  45509. isOGGsupported: boolean;
  45510. /**
  45511. * Gets whether audio has been unlocked on the device.
  45512. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45513. * a user interaction has happened.
  45514. */
  45515. unlocked: boolean;
  45516. /**
  45517. * Defines if the audio engine relies on a custom unlocked button.
  45518. * In this case, the embedded button will not be displayed.
  45519. */
  45520. useCustomUnlockedButton: boolean;
  45521. /**
  45522. * Event raised when audio has been unlocked on the browser.
  45523. */
  45524. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45525. /**
  45526. * Event raised when audio has been locked on the browser.
  45527. */
  45528. onAudioLockedObservable: Observable<IAudioEngine>;
  45529. /**
  45530. * Gets the current AudioContext if available.
  45531. */
  45532. get audioContext(): Nullable<AudioContext>;
  45533. private _connectedAnalyser;
  45534. /**
  45535. * Instantiates a new audio engine.
  45536. *
  45537. * There should be only one per page as some browsers restrict the number
  45538. * of audio contexts you can create.
  45539. * @param hostElement defines the host element where to display the mute icon if necessary
  45540. */
  45541. constructor(hostElement?: Nullable<HTMLElement>);
  45542. /**
  45543. * Flags the audio engine in Locked state.
  45544. * This happens due to new browser policies preventing audio to autoplay.
  45545. */
  45546. lock(): void;
  45547. /**
  45548. * Unlocks the audio engine once a user action has been done on the dom.
  45549. * This is helpful to resume play once browser policies have been satisfied.
  45550. */
  45551. unlock(): void;
  45552. private _resumeAudioContext;
  45553. private _initializeAudioContext;
  45554. private _tryToRun;
  45555. private _triggerRunningState;
  45556. private _triggerSuspendedState;
  45557. private _displayMuteButton;
  45558. private _moveButtonToTopLeft;
  45559. private _onResize;
  45560. private _hideMuteButton;
  45561. /**
  45562. * Destroy and release the resources associated with the audio ccontext.
  45563. */
  45564. dispose(): void;
  45565. /**
  45566. * Gets the global volume sets on the master gain.
  45567. * @returns the global volume if set or -1 otherwise
  45568. */
  45569. getGlobalVolume(): number;
  45570. /**
  45571. * Sets the global volume of your experience (sets on the master gain).
  45572. * @param newVolume Defines the new global volume of the application
  45573. */
  45574. setGlobalVolume(newVolume: number): void;
  45575. /**
  45576. * Connect the audio engine to an audio analyser allowing some amazing
  45577. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45579. * @param analyser The analyser to connect to the engine
  45580. */
  45581. connectToAnalyser(analyser: Analyser): void;
  45582. }
  45583. }
  45584. declare module BABYLON {
  45585. /**
  45586. * Options allowed during the creation of a sound track.
  45587. */
  45588. export interface ISoundTrackOptions {
  45589. /**
  45590. * The volume the sound track should take during creation
  45591. */
  45592. volume?: number;
  45593. /**
  45594. * Define if the sound track is the main sound track of the scene
  45595. */
  45596. mainTrack?: boolean;
  45597. }
  45598. /**
  45599. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45600. * It will be also used in a future release to apply effects on a specific track.
  45601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45602. */
  45603. export class SoundTrack {
  45604. /**
  45605. * The unique identifier of the sound track in the scene.
  45606. */
  45607. id: number;
  45608. /**
  45609. * The list of sounds included in the sound track.
  45610. */
  45611. soundCollection: Array<Sound>;
  45612. private _outputAudioNode;
  45613. private _scene;
  45614. private _connectedAnalyser;
  45615. private _options;
  45616. private _isInitialized;
  45617. /**
  45618. * Creates a new sound track.
  45619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45620. * @param scene Define the scene the sound track belongs to
  45621. * @param options
  45622. */
  45623. constructor(scene: Scene, options?: ISoundTrackOptions);
  45624. private _initializeSoundTrackAudioGraph;
  45625. /**
  45626. * Release the sound track and its associated resources
  45627. */
  45628. dispose(): void;
  45629. /**
  45630. * Adds a sound to this sound track
  45631. * @param sound define the cound to add
  45632. * @ignoreNaming
  45633. */
  45634. addSound(sound: Sound): void;
  45635. /**
  45636. * Removes a sound to this sound track
  45637. * @param sound define the cound to remove
  45638. * @ignoreNaming
  45639. */
  45640. removeSound(sound: Sound): void;
  45641. /**
  45642. * Set a global volume for the full sound track.
  45643. * @param newVolume Define the new volume of the sound track
  45644. */
  45645. setVolume(newVolume: number): void;
  45646. /**
  45647. * Switch the panning model to HRTF:
  45648. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45650. */
  45651. switchPanningModelToHRTF(): void;
  45652. /**
  45653. * Switch the panning model to Equal Power:
  45654. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45656. */
  45657. switchPanningModelToEqualPower(): void;
  45658. /**
  45659. * Connect the sound track to an audio analyser allowing some amazing
  45660. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45661. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45662. * @param analyser The analyser to connect to the engine
  45663. */
  45664. connectToAnalyser(analyser: Analyser): void;
  45665. }
  45666. }
  45667. declare module BABYLON {
  45668. interface AbstractScene {
  45669. /**
  45670. * The list of sounds used in the scene.
  45671. */
  45672. sounds: Nullable<Array<Sound>>;
  45673. }
  45674. interface Scene {
  45675. /**
  45676. * @hidden
  45677. * Backing field
  45678. */
  45679. _mainSoundTrack: SoundTrack;
  45680. /**
  45681. * The main sound track played by the scene.
  45682. * It cotains your primary collection of sounds.
  45683. */
  45684. mainSoundTrack: SoundTrack;
  45685. /**
  45686. * The list of sound tracks added to the scene
  45687. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45688. */
  45689. soundTracks: Nullable<Array<SoundTrack>>;
  45690. /**
  45691. * Gets a sound using a given name
  45692. * @param name defines the name to search for
  45693. * @return the found sound or null if not found at all.
  45694. */
  45695. getSoundByName(name: string): Nullable<Sound>;
  45696. /**
  45697. * Gets or sets if audio support is enabled
  45698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45699. */
  45700. audioEnabled: boolean;
  45701. /**
  45702. * Gets or sets if audio will be output to headphones
  45703. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45704. */
  45705. headphone: boolean;
  45706. /**
  45707. * Gets or sets custom audio listener position provider
  45708. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45709. */
  45710. audioListenerPositionProvider: Nullable<() => Vector3>;
  45711. /**
  45712. * Gets or sets a refresh rate when using 3D audio positioning
  45713. */
  45714. audioPositioningRefreshRate: number;
  45715. }
  45716. /**
  45717. * Defines the sound scene component responsible to manage any sounds
  45718. * in a given scene.
  45719. */
  45720. export class AudioSceneComponent implements ISceneSerializableComponent {
  45721. private static _CameraDirectionLH;
  45722. private static _CameraDirectionRH;
  45723. /**
  45724. * The component name helpfull to identify the component in the list of scene components.
  45725. */
  45726. readonly name: string;
  45727. /**
  45728. * The scene the component belongs to.
  45729. */
  45730. scene: Scene;
  45731. private _audioEnabled;
  45732. /**
  45733. * Gets whether audio is enabled or not.
  45734. * Please use related enable/disable method to switch state.
  45735. */
  45736. get audioEnabled(): boolean;
  45737. private _headphone;
  45738. /**
  45739. * Gets whether audio is outputing to headphone or not.
  45740. * Please use the according Switch methods to change output.
  45741. */
  45742. get headphone(): boolean;
  45743. /**
  45744. * Gets or sets a refresh rate when using 3D audio positioning
  45745. */
  45746. audioPositioningRefreshRate: number;
  45747. private _audioListenerPositionProvider;
  45748. /**
  45749. * Gets the current audio listener position provider
  45750. */
  45751. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45752. /**
  45753. * Sets a custom listener position for all sounds in the scene
  45754. * By default, this is the position of the first active camera
  45755. */
  45756. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45757. /**
  45758. * Creates a new instance of the component for the given scene
  45759. * @param scene Defines the scene to register the component in
  45760. */
  45761. constructor(scene: Scene);
  45762. /**
  45763. * Registers the component in a given scene
  45764. */
  45765. register(): void;
  45766. /**
  45767. * Rebuilds the elements related to this component in case of
  45768. * context lost for instance.
  45769. */
  45770. rebuild(): void;
  45771. /**
  45772. * Serializes the component data to the specified json object
  45773. * @param serializationObject The object to serialize to
  45774. */
  45775. serialize(serializationObject: any): void;
  45776. /**
  45777. * Adds all the elements from the container to the scene
  45778. * @param container the container holding the elements
  45779. */
  45780. addFromContainer(container: AbstractScene): void;
  45781. /**
  45782. * Removes all the elements in the container from the scene
  45783. * @param container contains the elements to remove
  45784. * @param dispose if the removed element should be disposed (default: false)
  45785. */
  45786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45787. /**
  45788. * Disposes the component and the associated ressources.
  45789. */
  45790. dispose(): void;
  45791. /**
  45792. * Disables audio in the associated scene.
  45793. */
  45794. disableAudio(): void;
  45795. /**
  45796. * Enables audio in the associated scene.
  45797. */
  45798. enableAudio(): void;
  45799. /**
  45800. * Switch audio to headphone output.
  45801. */
  45802. switchAudioModeForHeadphones(): void;
  45803. /**
  45804. * Switch audio to normal speakers.
  45805. */
  45806. switchAudioModeForNormalSpeakers(): void;
  45807. private _cachedCameraDirection;
  45808. private _cachedCameraPosition;
  45809. private _lastCheck;
  45810. private _afterRender;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * Wraps one or more Sound objects and selects one with random weight for playback.
  45816. */
  45817. export class WeightedSound {
  45818. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45819. loop: boolean;
  45820. private _coneInnerAngle;
  45821. private _coneOuterAngle;
  45822. private _volume;
  45823. /** A Sound is currently playing. */
  45824. isPlaying: boolean;
  45825. /** A Sound is currently paused. */
  45826. isPaused: boolean;
  45827. private _sounds;
  45828. private _weights;
  45829. private _currentIndex?;
  45830. /**
  45831. * Creates a new WeightedSound from the list of sounds given.
  45832. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45833. * @param sounds Array of Sounds that will be selected from.
  45834. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45835. */
  45836. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45837. /**
  45838. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45839. */
  45840. get directionalConeInnerAngle(): number;
  45841. /**
  45842. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45843. */
  45844. set directionalConeInnerAngle(value: number);
  45845. /**
  45846. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45847. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45848. */
  45849. get directionalConeOuterAngle(): number;
  45850. /**
  45851. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45852. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45853. */
  45854. set directionalConeOuterAngle(value: number);
  45855. /**
  45856. * Playback volume.
  45857. */
  45858. get volume(): number;
  45859. /**
  45860. * Playback volume.
  45861. */
  45862. set volume(value: number);
  45863. private _onended;
  45864. /**
  45865. * Suspend playback
  45866. */
  45867. pause(): void;
  45868. /**
  45869. * Stop playback
  45870. */
  45871. stop(): void;
  45872. /**
  45873. * Start playback.
  45874. * @param startOffset Position the clip head at a specific time in seconds.
  45875. */
  45876. play(startOffset?: number): void;
  45877. }
  45878. }
  45879. declare module BABYLON {
  45880. /**
  45881. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45882. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45883. */
  45884. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45885. /**
  45886. * Gets the name of the behavior.
  45887. */
  45888. get name(): string;
  45889. /**
  45890. * The easing function used by animations
  45891. */
  45892. static EasingFunction: BackEase;
  45893. /**
  45894. * The easing mode used by animations
  45895. */
  45896. static EasingMode: number;
  45897. /**
  45898. * The duration of the animation, in milliseconds
  45899. */
  45900. transitionDuration: number;
  45901. /**
  45902. * Length of the distance animated by the transition when lower radius is reached
  45903. */
  45904. lowerRadiusTransitionRange: number;
  45905. /**
  45906. * Length of the distance animated by the transition when upper radius is reached
  45907. */
  45908. upperRadiusTransitionRange: number;
  45909. private _autoTransitionRange;
  45910. /**
  45911. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45912. */
  45913. get autoTransitionRange(): boolean;
  45914. /**
  45915. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45916. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45917. */
  45918. set autoTransitionRange(value: boolean);
  45919. private _attachedCamera;
  45920. private _onAfterCheckInputsObserver;
  45921. private _onMeshTargetChangedObserver;
  45922. /**
  45923. * Initializes the behavior.
  45924. */
  45925. init(): void;
  45926. /**
  45927. * Attaches the behavior to its arc rotate camera.
  45928. * @param camera Defines the camera to attach the behavior to
  45929. */
  45930. attach(camera: ArcRotateCamera): void;
  45931. /**
  45932. * Detaches the behavior from its current arc rotate camera.
  45933. */
  45934. detach(): void;
  45935. private _radiusIsAnimating;
  45936. private _radiusBounceTransition;
  45937. private _animatables;
  45938. private _cachedWheelPrecision;
  45939. /**
  45940. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45941. * @param radiusLimit The limit to check against.
  45942. * @return Bool to indicate if at limit.
  45943. */
  45944. private _isRadiusAtLimit;
  45945. /**
  45946. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45947. * @param radiusDelta The delta by which to animate to. Can be negative.
  45948. */
  45949. private _applyBoundRadiusAnimation;
  45950. /**
  45951. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45952. */
  45953. protected _clearAnimationLocks(): void;
  45954. /**
  45955. * Stops and removes all animations that have been applied to the camera
  45956. */
  45957. stopAllAnimations(): void;
  45958. }
  45959. }
  45960. declare module BABYLON {
  45961. /**
  45962. * 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.
  45963. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45964. */
  45965. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45966. /**
  45967. * Gets the name of the behavior.
  45968. */
  45969. get name(): string;
  45970. private _mode;
  45971. private _radiusScale;
  45972. private _positionScale;
  45973. private _defaultElevation;
  45974. private _elevationReturnTime;
  45975. private _elevationReturnWaitTime;
  45976. private _zoomStopsAnimation;
  45977. private _framingTime;
  45978. /**
  45979. * The easing function used by animations
  45980. */
  45981. static EasingFunction: ExponentialEase;
  45982. /**
  45983. * The easing mode used by animations
  45984. */
  45985. static EasingMode: number;
  45986. /**
  45987. * Sets the current mode used by the behavior
  45988. */
  45989. set mode(mode: number);
  45990. /**
  45991. * Gets current mode used by the behavior.
  45992. */
  45993. get mode(): number;
  45994. /**
  45995. * Sets the scale applied to the radius (1 by default)
  45996. */
  45997. set radiusScale(radius: number);
  45998. /**
  45999. * Gets the scale applied to the radius
  46000. */
  46001. get radiusScale(): number;
  46002. /**
  46003. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46004. */
  46005. set positionScale(scale: number);
  46006. /**
  46007. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46008. */
  46009. get positionScale(): number;
  46010. /**
  46011. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46012. * behaviour is triggered, in radians.
  46013. */
  46014. set defaultElevation(elevation: number);
  46015. /**
  46016. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46017. * behaviour is triggered, in radians.
  46018. */
  46019. get defaultElevation(): number;
  46020. /**
  46021. * Sets the time (in milliseconds) taken to return to the default beta position.
  46022. * Negative value indicates camera should not return to default.
  46023. */
  46024. set elevationReturnTime(speed: number);
  46025. /**
  46026. * Gets the time (in milliseconds) taken to return to the default beta position.
  46027. * Negative value indicates camera should not return to default.
  46028. */
  46029. get elevationReturnTime(): number;
  46030. /**
  46031. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46032. */
  46033. set elevationReturnWaitTime(time: number);
  46034. /**
  46035. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46036. */
  46037. get elevationReturnWaitTime(): number;
  46038. /**
  46039. * Sets the flag that indicates if user zooming should stop animation.
  46040. */
  46041. set zoomStopsAnimation(flag: boolean);
  46042. /**
  46043. * Gets the flag that indicates if user zooming should stop animation.
  46044. */
  46045. get zoomStopsAnimation(): boolean;
  46046. /**
  46047. * Sets the transition time when framing the mesh, in milliseconds
  46048. */
  46049. set framingTime(time: number);
  46050. /**
  46051. * Gets the transition time when framing the mesh, in milliseconds
  46052. */
  46053. get framingTime(): number;
  46054. /**
  46055. * Define if the behavior should automatically change the configured
  46056. * camera limits and sensibilities.
  46057. */
  46058. autoCorrectCameraLimitsAndSensibility: boolean;
  46059. private _onPrePointerObservableObserver;
  46060. private _onAfterCheckInputsObserver;
  46061. private _onMeshTargetChangedObserver;
  46062. private _attachedCamera;
  46063. private _isPointerDown;
  46064. private _lastInteractionTime;
  46065. /**
  46066. * Initializes the behavior.
  46067. */
  46068. init(): void;
  46069. /**
  46070. * Attaches the behavior to its arc rotate camera.
  46071. * @param camera Defines the camera to attach the behavior to
  46072. */
  46073. attach(camera: ArcRotateCamera): void;
  46074. /**
  46075. * Detaches the behavior from its current arc rotate camera.
  46076. */
  46077. detach(): void;
  46078. private _animatables;
  46079. private _betaIsAnimating;
  46080. private _betaTransition;
  46081. private _radiusTransition;
  46082. private _vectorTransition;
  46083. /**
  46084. * Targets the given mesh and updates zoom level accordingly.
  46085. * @param mesh The mesh to target.
  46086. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46087. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46088. */
  46089. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46090. /**
  46091. * Targets the given mesh with its children and updates zoom level accordingly.
  46092. * @param mesh The mesh to target.
  46093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46095. */
  46096. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46097. /**
  46098. * Targets the given meshes with their children and updates zoom level accordingly.
  46099. * @param meshes The mesh to target.
  46100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46102. */
  46103. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46104. /**
  46105. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46106. * @param minimumWorld Determines the smaller position of the bounding box extend
  46107. * @param maximumWorld Determines the bigger position of the bounding box extend
  46108. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46109. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46110. */
  46111. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46112. /**
  46113. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46114. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46115. * frustum width.
  46116. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46117. * to fully enclose the mesh in the viewing frustum.
  46118. */
  46119. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46120. /**
  46121. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46122. * is automatically returned to its default position (expected to be above ground plane).
  46123. */
  46124. private _maintainCameraAboveGround;
  46125. /**
  46126. * Returns the frustum slope based on the canvas ratio and camera FOV
  46127. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46128. */
  46129. private _getFrustumSlope;
  46130. /**
  46131. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46132. */
  46133. private _clearAnimationLocks;
  46134. /**
  46135. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46136. */
  46137. private _applyUserInteraction;
  46138. /**
  46139. * Stops and removes all animations that have been applied to the camera
  46140. */
  46141. stopAllAnimations(): void;
  46142. /**
  46143. * Gets a value indicating if the user is moving the camera
  46144. */
  46145. get isUserIsMoving(): boolean;
  46146. /**
  46147. * The camera can move all the way towards the mesh.
  46148. */
  46149. static IgnoreBoundsSizeMode: number;
  46150. /**
  46151. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46152. */
  46153. static FitFrustumSidesMode: number;
  46154. }
  46155. }
  46156. declare module BABYLON {
  46157. /**
  46158. * Base class for Camera Pointer Inputs.
  46159. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46160. * for example usage.
  46161. */
  46162. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46163. /**
  46164. * Defines the camera the input is attached to.
  46165. */
  46166. abstract camera: Camera;
  46167. /**
  46168. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46169. */
  46170. protected _altKey: boolean;
  46171. protected _ctrlKey: boolean;
  46172. protected _metaKey: boolean;
  46173. protected _shiftKey: boolean;
  46174. /**
  46175. * Which mouse buttons were pressed at time of last mouse event.
  46176. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46177. */
  46178. protected _buttonsPressed: number;
  46179. /**
  46180. * Defines the buttons associated with the input to handle camera move.
  46181. */
  46182. buttons: number[];
  46183. /**
  46184. * Attach the input controls to a specific dom element to get the input from.
  46185. * @param element Defines the element the controls should be listened from
  46186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46187. */
  46188. attachControl(noPreventDefault?: boolean): void;
  46189. /**
  46190. * Detach the current controls from the specified dom element.
  46191. */
  46192. detachControl(): void;
  46193. /**
  46194. * Gets the class name of the current input.
  46195. * @returns the class name
  46196. */
  46197. getClassName(): string;
  46198. /**
  46199. * Get the friendly name associated with the input class.
  46200. * @returns the input friendly name
  46201. */
  46202. getSimpleName(): string;
  46203. /**
  46204. * Called on pointer POINTERDOUBLETAP event.
  46205. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46206. */
  46207. protected onDoubleTap(type: string): void;
  46208. /**
  46209. * Called on pointer POINTERMOVE event if only a single touch is active.
  46210. * Override this method to provide functionality.
  46211. */
  46212. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46213. /**
  46214. * Called on pointer POINTERMOVE event if multiple touches are active.
  46215. * Override this method to provide functionality.
  46216. */
  46217. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46218. /**
  46219. * Called on JS contextmenu event.
  46220. * Override this method to provide functionality.
  46221. */
  46222. protected onContextMenu(evt: PointerEvent): void;
  46223. /**
  46224. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46225. * press.
  46226. * Override this method to provide functionality.
  46227. */
  46228. protected onButtonDown(evt: PointerEvent): void;
  46229. /**
  46230. * Called each time a new POINTERUP event occurs. Ie, for each button
  46231. * release.
  46232. * Override this method to provide functionality.
  46233. */
  46234. protected onButtonUp(evt: PointerEvent): void;
  46235. /**
  46236. * Called when window becomes inactive.
  46237. * Override this method to provide functionality.
  46238. */
  46239. protected onLostFocus(): void;
  46240. private _pointerInput;
  46241. private _observer;
  46242. private _onLostFocus;
  46243. private pointA;
  46244. private pointB;
  46245. }
  46246. }
  46247. declare module BABYLON {
  46248. /**
  46249. * Manage the pointers inputs to control an arc rotate camera.
  46250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46251. */
  46252. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46253. /**
  46254. * Defines the camera the input is attached to.
  46255. */
  46256. camera: ArcRotateCamera;
  46257. /**
  46258. * Gets the class name of the current input.
  46259. * @returns the class name
  46260. */
  46261. getClassName(): string;
  46262. /**
  46263. * Defines the buttons associated with the input to handle camera move.
  46264. */
  46265. buttons: number[];
  46266. /**
  46267. * Defines the pointer angular sensibility along the X axis or how fast is
  46268. * the camera rotating.
  46269. */
  46270. angularSensibilityX: number;
  46271. /**
  46272. * Defines the pointer angular sensibility along the Y axis or how fast is
  46273. * the camera rotating.
  46274. */
  46275. angularSensibilityY: number;
  46276. /**
  46277. * Defines the pointer pinch precision or how fast is the camera zooming.
  46278. */
  46279. pinchPrecision: number;
  46280. /**
  46281. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46282. * from 0.
  46283. * It defines the percentage of current camera.radius to use as delta when
  46284. * pinch zoom is used.
  46285. */
  46286. pinchDeltaPercentage: number;
  46287. /**
  46288. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46289. * that any object in the plane at the camera's target point will scale
  46290. * perfectly with finger motion.
  46291. * Overrides pinchDeltaPercentage and pinchPrecision.
  46292. */
  46293. useNaturalPinchZoom: boolean;
  46294. /**
  46295. * Defines the pointer panning sensibility or how fast is the camera moving.
  46296. */
  46297. panningSensibility: number;
  46298. /**
  46299. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46300. */
  46301. multiTouchPanning: boolean;
  46302. /**
  46303. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46304. * zoom (pinch) through multitouch.
  46305. */
  46306. multiTouchPanAndZoom: boolean;
  46307. /**
  46308. * Revers pinch action direction.
  46309. */
  46310. pinchInwards: boolean;
  46311. private _isPanClick;
  46312. private _twoFingerActivityCount;
  46313. private _isPinching;
  46314. /**
  46315. * Called on pointer POINTERMOVE event if only a single touch is active.
  46316. */
  46317. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46318. /**
  46319. * Called on pointer POINTERDOUBLETAP event.
  46320. */
  46321. protected onDoubleTap(type: string): void;
  46322. /**
  46323. * Called on pointer POINTERMOVE event if multiple touches are active.
  46324. */
  46325. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46326. /**
  46327. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46328. * press.
  46329. */
  46330. protected onButtonDown(evt: PointerEvent): void;
  46331. /**
  46332. * Called each time a new POINTERUP event occurs. Ie, for each button
  46333. * release.
  46334. */
  46335. protected onButtonUp(evt: PointerEvent): void;
  46336. /**
  46337. * Called when window becomes inactive.
  46338. */
  46339. protected onLostFocus(): void;
  46340. }
  46341. }
  46342. declare module BABYLON {
  46343. /**
  46344. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46345. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46346. */
  46347. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46348. /**
  46349. * Defines the camera the input is attached to.
  46350. */
  46351. camera: ArcRotateCamera;
  46352. /**
  46353. * Defines the list of key codes associated with the up action (increase alpha)
  46354. */
  46355. keysUp: number[];
  46356. /**
  46357. * Defines the list of key codes associated with the down action (decrease alpha)
  46358. */
  46359. keysDown: number[];
  46360. /**
  46361. * Defines the list of key codes associated with the left action (increase beta)
  46362. */
  46363. keysLeft: number[];
  46364. /**
  46365. * Defines the list of key codes associated with the right action (decrease beta)
  46366. */
  46367. keysRight: number[];
  46368. /**
  46369. * Defines the list of key codes associated with the reset action.
  46370. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46371. */
  46372. keysReset: number[];
  46373. /**
  46374. * Defines the panning sensibility of the inputs.
  46375. * (How fast is the camera panning)
  46376. */
  46377. panningSensibility: number;
  46378. /**
  46379. * Defines the zooming sensibility of the inputs.
  46380. * (How fast is the camera zooming)
  46381. */
  46382. zoomingSensibility: number;
  46383. /**
  46384. * Defines whether maintaining the alt key down switch the movement mode from
  46385. * orientation to zoom.
  46386. */
  46387. useAltToZoom: boolean;
  46388. /**
  46389. * Rotation speed of the camera
  46390. */
  46391. angularSpeed: number;
  46392. private _keys;
  46393. private _ctrlPressed;
  46394. private _altPressed;
  46395. private _onCanvasBlurObserver;
  46396. private _onKeyboardObserver;
  46397. private _engine;
  46398. private _scene;
  46399. /**
  46400. * Attach the input controls to a specific dom element to get the input from.
  46401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46402. */
  46403. attachControl(noPreventDefault?: boolean): void;
  46404. /**
  46405. * Detach the current controls from the specified dom element.
  46406. */
  46407. detachControl(): void;
  46408. /**
  46409. * Update the current camera state depending on the inputs that have been used this frame.
  46410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46411. */
  46412. checkInputs(): void;
  46413. /**
  46414. * Gets the class name of the current intput.
  46415. * @returns the class name
  46416. */
  46417. getClassName(): string;
  46418. /**
  46419. * Get the friendly name associated with the input class.
  46420. * @returns the input friendly name
  46421. */
  46422. getSimpleName(): string;
  46423. }
  46424. }
  46425. declare module BABYLON {
  46426. /**
  46427. * Manage the mouse wheel inputs to control an arc rotate camera.
  46428. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46429. */
  46430. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46431. /**
  46432. * Defines the camera the input is attached to.
  46433. */
  46434. camera: ArcRotateCamera;
  46435. /**
  46436. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46437. */
  46438. wheelPrecision: number;
  46439. /**
  46440. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46441. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46442. */
  46443. wheelDeltaPercentage: number;
  46444. private _wheel;
  46445. private _observer;
  46446. private computeDeltaFromMouseWheelLegacyEvent;
  46447. /**
  46448. * Attach the input controls to a specific dom element to get the input from.
  46449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46450. */
  46451. attachControl(noPreventDefault?: boolean): void;
  46452. /**
  46453. * Detach the current controls from the specified dom element.
  46454. */
  46455. detachControl(): void;
  46456. /**
  46457. * Gets the class name of the current intput.
  46458. * @returns the class name
  46459. */
  46460. getClassName(): string;
  46461. /**
  46462. * Get the friendly name associated with the input class.
  46463. * @returns the input friendly name
  46464. */
  46465. getSimpleName(): string;
  46466. }
  46467. }
  46468. declare module BABYLON {
  46469. /**
  46470. * Default Inputs manager for the ArcRotateCamera.
  46471. * It groups all the default supported inputs for ease of use.
  46472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46473. */
  46474. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46475. /**
  46476. * Instantiates a new ArcRotateCameraInputsManager.
  46477. * @param camera Defines the camera the inputs belong to
  46478. */
  46479. constructor(camera: ArcRotateCamera);
  46480. /**
  46481. * Add mouse wheel input support to the input manager.
  46482. * @returns the current input manager
  46483. */
  46484. addMouseWheel(): ArcRotateCameraInputsManager;
  46485. /**
  46486. * Add pointers input support to the input manager.
  46487. * @returns the current input manager
  46488. */
  46489. addPointers(): ArcRotateCameraInputsManager;
  46490. /**
  46491. * Add keyboard input support to the input manager.
  46492. * @returns the current input manager
  46493. */
  46494. addKeyboard(): ArcRotateCameraInputsManager;
  46495. }
  46496. }
  46497. declare module BABYLON {
  46498. /**
  46499. * This represents an orbital type of camera.
  46500. *
  46501. * 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.
  46502. * 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.
  46503. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46504. */
  46505. export class ArcRotateCamera extends TargetCamera {
  46506. /**
  46507. * Defines the rotation angle of the camera along the longitudinal axis.
  46508. */
  46509. alpha: number;
  46510. /**
  46511. * Defines the rotation angle of the camera along the latitudinal axis.
  46512. */
  46513. beta: number;
  46514. /**
  46515. * Defines the radius of the camera from it s target point.
  46516. */
  46517. radius: number;
  46518. protected _target: Vector3;
  46519. protected _targetHost: Nullable<AbstractMesh>;
  46520. /**
  46521. * Defines the target point of the camera.
  46522. * The camera looks towards it form the radius distance.
  46523. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46524. */
  46525. get target(): Vector3;
  46526. set target(value: Vector3);
  46527. /**
  46528. * Define the current local position of the camera in the scene
  46529. */
  46530. get position(): Vector3;
  46531. set position(newPosition: Vector3);
  46532. protected _upToYMatrix: Matrix;
  46533. protected _YToUpMatrix: Matrix;
  46534. /**
  46535. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46536. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46537. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46538. */
  46539. set upVector(vec: Vector3);
  46540. get upVector(): Vector3;
  46541. /**
  46542. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46543. */
  46544. setMatUp(): void;
  46545. /**
  46546. * Current inertia value on the longitudinal axis.
  46547. * The bigger this number the longer it will take for the camera to stop.
  46548. */
  46549. inertialAlphaOffset: number;
  46550. /**
  46551. * Current inertia value on the latitudinal axis.
  46552. * The bigger this number the longer it will take for the camera to stop.
  46553. */
  46554. inertialBetaOffset: number;
  46555. /**
  46556. * Current inertia value on the radius axis.
  46557. * The bigger this number the longer it will take for the camera to stop.
  46558. */
  46559. inertialRadiusOffset: number;
  46560. /**
  46561. * Minimum allowed angle on the longitudinal axis.
  46562. * This can help limiting how the Camera is able to move in the scene.
  46563. */
  46564. lowerAlphaLimit: Nullable<number>;
  46565. /**
  46566. * Maximum allowed angle on the longitudinal axis.
  46567. * This can help limiting how the Camera is able to move in the scene.
  46568. */
  46569. upperAlphaLimit: Nullable<number>;
  46570. /**
  46571. * Minimum allowed angle on the latitudinal axis.
  46572. * This can help limiting how the Camera is able to move in the scene.
  46573. */
  46574. lowerBetaLimit: number;
  46575. /**
  46576. * Maximum allowed angle on the latitudinal axis.
  46577. * This can help limiting how the Camera is able to move in the scene.
  46578. */
  46579. upperBetaLimit: number;
  46580. /**
  46581. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46582. * This can help limiting how the Camera is able to move in the scene.
  46583. */
  46584. lowerRadiusLimit: Nullable<number>;
  46585. /**
  46586. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46587. * This can help limiting how the Camera is able to move in the scene.
  46588. */
  46589. upperRadiusLimit: Nullable<number>;
  46590. /**
  46591. * Defines the current inertia value used during panning of the camera along the X axis.
  46592. */
  46593. inertialPanningX: number;
  46594. /**
  46595. * Defines the current inertia value used during panning of the camera along the Y axis.
  46596. */
  46597. inertialPanningY: number;
  46598. /**
  46599. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46600. * Basically if your fingers moves away from more than this distance you will be considered
  46601. * in pinch mode.
  46602. */
  46603. pinchToPanMaxDistance: number;
  46604. /**
  46605. * Defines the maximum distance the camera can pan.
  46606. * This could help keeping the cammera always in your scene.
  46607. */
  46608. panningDistanceLimit: Nullable<number>;
  46609. /**
  46610. * Defines the target of the camera before paning.
  46611. */
  46612. panningOriginTarget: Vector3;
  46613. /**
  46614. * Defines the value of the inertia used during panning.
  46615. * 0 would mean stop inertia and one would mean no decelleration at all.
  46616. */
  46617. panningInertia: number;
  46618. /**
  46619. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46620. */
  46621. get angularSensibilityX(): number;
  46622. set angularSensibilityX(value: number);
  46623. /**
  46624. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46625. */
  46626. get angularSensibilityY(): number;
  46627. set angularSensibilityY(value: number);
  46628. /**
  46629. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46630. */
  46631. get pinchPrecision(): number;
  46632. set pinchPrecision(value: number);
  46633. /**
  46634. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46635. * It will be used instead of pinchDeltaPrecision if different from 0.
  46636. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46637. */
  46638. get pinchDeltaPercentage(): number;
  46639. set pinchDeltaPercentage(value: number);
  46640. /**
  46641. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46642. * and pinch delta percentage.
  46643. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46644. * that any object in the plane at the camera's target point will scale
  46645. * perfectly with finger motion.
  46646. */
  46647. get useNaturalPinchZoom(): boolean;
  46648. set useNaturalPinchZoom(value: boolean);
  46649. /**
  46650. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46651. */
  46652. get panningSensibility(): number;
  46653. set panningSensibility(value: number);
  46654. /**
  46655. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46656. */
  46657. get keysUp(): number[];
  46658. set keysUp(value: number[]);
  46659. /**
  46660. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46661. */
  46662. get keysDown(): number[];
  46663. set keysDown(value: number[]);
  46664. /**
  46665. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46666. */
  46667. get keysLeft(): number[];
  46668. set keysLeft(value: number[]);
  46669. /**
  46670. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46671. */
  46672. get keysRight(): number[];
  46673. set keysRight(value: number[]);
  46674. /**
  46675. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46676. */
  46677. get wheelPrecision(): number;
  46678. set wheelPrecision(value: number);
  46679. /**
  46680. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46681. * It will be used instead of pinchDeltaPrecision if different from 0.
  46682. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46683. */
  46684. get wheelDeltaPercentage(): number;
  46685. set wheelDeltaPercentage(value: number);
  46686. /**
  46687. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46688. */
  46689. zoomOnFactor: number;
  46690. /**
  46691. * Defines a screen offset for the camera position.
  46692. */
  46693. targetScreenOffset: Vector2;
  46694. /**
  46695. * Allows the camera to be completely reversed.
  46696. * If false the camera can not arrive upside down.
  46697. */
  46698. allowUpsideDown: boolean;
  46699. /**
  46700. * Define if double tap/click is used to restore the previously saved state of the camera.
  46701. */
  46702. useInputToRestoreState: boolean;
  46703. /** @hidden */
  46704. _viewMatrix: Matrix;
  46705. /** @hidden */
  46706. _useCtrlForPanning: boolean;
  46707. /** @hidden */
  46708. _panningMouseButton: number;
  46709. /**
  46710. * Defines the input associated to the camera.
  46711. */
  46712. inputs: ArcRotateCameraInputsManager;
  46713. /** @hidden */
  46714. _reset: () => void;
  46715. /**
  46716. * Defines the allowed panning axis.
  46717. */
  46718. panningAxis: Vector3;
  46719. protected _localDirection: Vector3;
  46720. protected _transformedDirection: Vector3;
  46721. private _bouncingBehavior;
  46722. /**
  46723. * Gets the bouncing behavior of the camera if it has been enabled.
  46724. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46725. */
  46726. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46727. /**
  46728. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46729. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46730. */
  46731. get useBouncingBehavior(): boolean;
  46732. set useBouncingBehavior(value: boolean);
  46733. private _framingBehavior;
  46734. /**
  46735. * Gets the framing behavior of the camera if it has been enabled.
  46736. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46737. */
  46738. get framingBehavior(): Nullable<FramingBehavior>;
  46739. /**
  46740. * Defines if the framing behavior of the camera is enabled on the camera.
  46741. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46742. */
  46743. get useFramingBehavior(): boolean;
  46744. set useFramingBehavior(value: boolean);
  46745. private _autoRotationBehavior;
  46746. /**
  46747. * Gets the auto rotation behavior of the camera if it has been enabled.
  46748. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46749. */
  46750. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46751. /**
  46752. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46753. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46754. */
  46755. get useAutoRotationBehavior(): boolean;
  46756. set useAutoRotationBehavior(value: boolean);
  46757. /**
  46758. * Observable triggered when the mesh target has been changed on the camera.
  46759. */
  46760. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46761. /**
  46762. * Event raised when the camera is colliding with a mesh.
  46763. */
  46764. onCollide: (collidedMesh: AbstractMesh) => void;
  46765. /**
  46766. * Defines whether the camera should check collision with the objects oh the scene.
  46767. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46768. */
  46769. checkCollisions: boolean;
  46770. /**
  46771. * Defines the collision radius of the camera.
  46772. * This simulates a sphere around the camera.
  46773. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46774. */
  46775. collisionRadius: Vector3;
  46776. protected _collider: Collider;
  46777. protected _previousPosition: Vector3;
  46778. protected _collisionVelocity: Vector3;
  46779. protected _newPosition: Vector3;
  46780. protected _previousAlpha: number;
  46781. protected _previousBeta: number;
  46782. protected _previousRadius: number;
  46783. protected _collisionTriggered: boolean;
  46784. protected _targetBoundingCenter: Nullable<Vector3>;
  46785. private _computationVector;
  46786. /**
  46787. * Instantiates a new ArcRotateCamera in a given scene
  46788. * @param name Defines the name of the camera
  46789. * @param alpha Defines the camera rotation along the logitudinal axis
  46790. * @param beta Defines the camera rotation along the latitudinal axis
  46791. * @param radius Defines the camera distance from its target
  46792. * @param target Defines the camera target
  46793. * @param scene Defines the scene the camera belongs to
  46794. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46795. */
  46796. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46797. /** @hidden */
  46798. _initCache(): void;
  46799. /** @hidden */
  46800. _updateCache(ignoreParentClass?: boolean): void;
  46801. protected _getTargetPosition(): Vector3;
  46802. private _storedAlpha;
  46803. private _storedBeta;
  46804. private _storedRadius;
  46805. private _storedTarget;
  46806. private _storedTargetScreenOffset;
  46807. /**
  46808. * Stores the current state of the camera (alpha, beta, radius and target)
  46809. * @returns the camera itself
  46810. */
  46811. storeState(): Camera;
  46812. /**
  46813. * @hidden
  46814. * Restored camera state. You must call storeState() first
  46815. */
  46816. _restoreStateValues(): boolean;
  46817. /** @hidden */
  46818. _isSynchronizedViewMatrix(): boolean;
  46819. /**
  46820. * Attach the input controls to a specific dom element to get the input from.
  46821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46822. */
  46823. attachControl(noPreventDefault?: boolean): void;
  46824. /**
  46825. * Attach the input controls to a specific dom element to get the input from.
  46826. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46828. */
  46829. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46830. /**
  46831. * Attached controls to the current camera.
  46832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46833. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46834. */
  46835. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46836. /**
  46837. * Attached controls to the current camera.
  46838. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46840. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46841. */
  46842. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46843. /**
  46844. * Attached controls to the current camera.
  46845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46846. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46847. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46848. */
  46849. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46850. /**
  46851. * Detach the current controls from the specified dom element.
  46852. */
  46853. detachControl(): void;
  46854. /**
  46855. * Detach the current controls from the specified dom element.
  46856. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46857. */
  46858. detachControl(ignored: any): void;
  46859. /** @hidden */
  46860. _checkInputs(): void;
  46861. protected _checkLimits(): void;
  46862. /**
  46863. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46864. */
  46865. rebuildAnglesAndRadius(): void;
  46866. /**
  46867. * Use a position to define the current camera related information like alpha, beta and radius
  46868. * @param position Defines the position to set the camera at
  46869. */
  46870. setPosition(position: Vector3): void;
  46871. /**
  46872. * Defines the target the camera should look at.
  46873. * This will automatically adapt alpha beta and radius to fit within the new target.
  46874. * @param target Defines the new target as a Vector or a mesh
  46875. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46876. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46877. */
  46878. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46879. /** @hidden */
  46880. _getViewMatrix(): Matrix;
  46881. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46882. /**
  46883. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46884. * @param meshes Defines the mesh to zoom on
  46885. * @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)
  46886. */
  46887. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46888. /**
  46889. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46890. * The target will be changed but the radius
  46891. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46892. * @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)
  46893. */
  46894. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46895. min: Vector3;
  46896. max: Vector3;
  46897. distance: number;
  46898. }, doNotUpdateMaxZ?: boolean): void;
  46899. /**
  46900. * @override
  46901. * Override Camera.createRigCamera
  46902. */
  46903. createRigCamera(name: string, cameraIndex: number): Camera;
  46904. /**
  46905. * @hidden
  46906. * @override
  46907. * Override Camera._updateRigCameras
  46908. */
  46909. _updateRigCameras(): void;
  46910. /**
  46911. * Destroy the camera and release the current resources hold by it.
  46912. */
  46913. dispose(): void;
  46914. /**
  46915. * Gets the current object class name.
  46916. * @return the class name
  46917. */
  46918. getClassName(): string;
  46919. }
  46920. }
  46921. declare module BABYLON {
  46922. /**
  46923. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46924. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46925. */
  46926. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46927. /**
  46928. * Gets the name of the behavior.
  46929. */
  46930. get name(): string;
  46931. private _zoomStopsAnimation;
  46932. private _idleRotationSpeed;
  46933. private _idleRotationWaitTime;
  46934. private _idleRotationSpinupTime;
  46935. /**
  46936. * Sets the flag that indicates if user zooming should stop animation.
  46937. */
  46938. set zoomStopsAnimation(flag: boolean);
  46939. /**
  46940. * Gets the flag that indicates if user zooming should stop animation.
  46941. */
  46942. get zoomStopsAnimation(): boolean;
  46943. /**
  46944. * Sets the default speed at which the camera rotates around the model.
  46945. */
  46946. set idleRotationSpeed(speed: number);
  46947. /**
  46948. * Gets the default speed at which the camera rotates around the model.
  46949. */
  46950. get idleRotationSpeed(): number;
  46951. /**
  46952. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46953. */
  46954. set idleRotationWaitTime(time: number);
  46955. /**
  46956. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46957. */
  46958. get idleRotationWaitTime(): number;
  46959. /**
  46960. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46961. */
  46962. set idleRotationSpinupTime(time: number);
  46963. /**
  46964. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46965. */
  46966. get idleRotationSpinupTime(): number;
  46967. /**
  46968. * Gets a value indicating if the camera is currently rotating because of this behavior
  46969. */
  46970. get rotationInProgress(): boolean;
  46971. private _onPrePointerObservableObserver;
  46972. private _onAfterCheckInputsObserver;
  46973. private _attachedCamera;
  46974. private _isPointerDown;
  46975. private _lastFrameTime;
  46976. private _lastInteractionTime;
  46977. private _cameraRotationSpeed;
  46978. /**
  46979. * Initializes the behavior.
  46980. */
  46981. init(): void;
  46982. /**
  46983. * Attaches the behavior to its arc rotate camera.
  46984. * @param camera Defines the camera to attach the behavior to
  46985. */
  46986. attach(camera: ArcRotateCamera): void;
  46987. /**
  46988. * Detaches the behavior from its current arc rotate camera.
  46989. */
  46990. detach(): void;
  46991. /**
  46992. * Returns true if user is scrolling.
  46993. * @return true if user is scrolling.
  46994. */
  46995. private _userIsZooming;
  46996. private _lastFrameRadius;
  46997. private _shouldAnimationStopForInteraction;
  46998. /**
  46999. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47000. */
  47001. private _applyUserInteraction;
  47002. private _userIsMoving;
  47003. }
  47004. }
  47005. declare module BABYLON {
  47006. /**
  47007. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47008. */
  47009. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47010. private ui;
  47011. /**
  47012. * The name of the behavior
  47013. */
  47014. name: string;
  47015. /**
  47016. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47017. */
  47018. distanceAwayFromFace: number;
  47019. /**
  47020. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47021. */
  47022. distanceAwayFromBottomOfFace: number;
  47023. private _faceVectors;
  47024. private _target;
  47025. private _scene;
  47026. private _onRenderObserver;
  47027. private _tmpMatrix;
  47028. private _tmpVector;
  47029. /**
  47030. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47031. * @param ui The transform node that should be attched to the mesh
  47032. */
  47033. constructor(ui: TransformNode);
  47034. /**
  47035. * Initializes the behavior
  47036. */
  47037. init(): void;
  47038. private _closestFace;
  47039. private _zeroVector;
  47040. private _lookAtTmpMatrix;
  47041. private _lookAtToRef;
  47042. /**
  47043. * Attaches the AttachToBoxBehavior to the passed in mesh
  47044. * @param target The mesh that the specified node will be attached to
  47045. */
  47046. attach(target: Mesh): void;
  47047. /**
  47048. * Detaches the behavior from the mesh
  47049. */
  47050. detach(): void;
  47051. }
  47052. }
  47053. declare module BABYLON {
  47054. /**
  47055. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47056. */
  47057. export class FadeInOutBehavior implements Behavior<Mesh> {
  47058. /**
  47059. * Time in milliseconds to delay before fading in (Default: 0)
  47060. */
  47061. delay: number;
  47062. /**
  47063. * Time in milliseconds for the mesh to fade in (Default: 300)
  47064. */
  47065. fadeInTime: number;
  47066. private _millisecondsPerFrame;
  47067. private _hovered;
  47068. private _hoverValue;
  47069. private _ownerNode;
  47070. /**
  47071. * Instatiates the FadeInOutBehavior
  47072. */
  47073. constructor();
  47074. /**
  47075. * The name of the behavior
  47076. */
  47077. get name(): string;
  47078. /**
  47079. * Initializes the behavior
  47080. */
  47081. init(): void;
  47082. /**
  47083. * Attaches the fade behavior on the passed in mesh
  47084. * @param ownerNode The mesh that will be faded in/out once attached
  47085. */
  47086. attach(ownerNode: Mesh): void;
  47087. /**
  47088. * Detaches the behavior from the mesh
  47089. */
  47090. detach(): void;
  47091. /**
  47092. * Triggers the mesh to begin fading in or out
  47093. * @param value if the object should fade in or out (true to fade in)
  47094. */
  47095. fadeIn(value: boolean): void;
  47096. private _update;
  47097. private _setAllVisibility;
  47098. }
  47099. }
  47100. declare module BABYLON {
  47101. /**
  47102. * Class containing a set of static utilities functions for managing Pivots
  47103. * @hidden
  47104. */
  47105. export class PivotTools {
  47106. private static _PivotCached;
  47107. private static _OldPivotPoint;
  47108. private static _PivotTranslation;
  47109. private static _PivotTmpVector;
  47110. private static _PivotPostMultiplyPivotMatrix;
  47111. /** @hidden */
  47112. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47113. /** @hidden */
  47114. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47115. }
  47116. }
  47117. declare module BABYLON {
  47118. /**
  47119. * Class containing static functions to help procedurally build meshes
  47120. */
  47121. export class PlaneBuilder {
  47122. /**
  47123. * Creates a plane mesh
  47124. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47125. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47126. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47128. * * 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
  47129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47130. * @param name defines the name of the mesh
  47131. * @param options defines the options used to create the mesh
  47132. * @param scene defines the hosting scene
  47133. * @returns the plane mesh
  47134. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47135. */
  47136. static CreatePlane(name: string, options: {
  47137. size?: number;
  47138. width?: number;
  47139. height?: number;
  47140. sideOrientation?: number;
  47141. frontUVs?: Vector4;
  47142. backUVs?: Vector4;
  47143. updatable?: boolean;
  47144. sourcePlane?: Plane;
  47145. }, scene?: Nullable<Scene>): Mesh;
  47146. }
  47147. }
  47148. declare module BABYLON {
  47149. /**
  47150. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47151. */
  47152. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47153. private static _AnyMouseID;
  47154. /**
  47155. * Abstract mesh the behavior is set on
  47156. */
  47157. attachedNode: AbstractMesh;
  47158. private _dragPlane;
  47159. private _scene;
  47160. private _pointerObserver;
  47161. private _beforeRenderObserver;
  47162. private static _planeScene;
  47163. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47164. /**
  47165. * 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)
  47166. */
  47167. maxDragAngle: number;
  47168. /**
  47169. * @hidden
  47170. */
  47171. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47172. /**
  47173. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47174. */
  47175. currentDraggingPointerID: number;
  47176. /**
  47177. * The last position where the pointer hit the drag plane in world space
  47178. */
  47179. lastDragPosition: Vector3;
  47180. /**
  47181. * If the behavior is currently in a dragging state
  47182. */
  47183. dragging: boolean;
  47184. /**
  47185. * 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)
  47186. */
  47187. dragDeltaRatio: number;
  47188. /**
  47189. * If the drag plane orientation should be updated during the dragging (Default: true)
  47190. */
  47191. updateDragPlane: boolean;
  47192. private _debugMode;
  47193. private _moving;
  47194. /**
  47195. * Fires each time the attached mesh is dragged with the pointer
  47196. * * delta between last drag position and current drag position in world space
  47197. * * dragDistance along the drag axis
  47198. * * dragPlaneNormal normal of the current drag plane used during the drag
  47199. * * dragPlanePoint in world space where the drag intersects the drag plane
  47200. */
  47201. onDragObservable: Observable<{
  47202. delta: Vector3;
  47203. dragPlanePoint: Vector3;
  47204. dragPlaneNormal: Vector3;
  47205. dragDistance: number;
  47206. pointerId: number;
  47207. }>;
  47208. /**
  47209. * Fires each time a drag begins (eg. mouse down on mesh)
  47210. */
  47211. onDragStartObservable: Observable<{
  47212. dragPlanePoint: Vector3;
  47213. pointerId: number;
  47214. }>;
  47215. /**
  47216. * Fires each time a drag ends (eg. mouse release after drag)
  47217. */
  47218. onDragEndObservable: Observable<{
  47219. dragPlanePoint: Vector3;
  47220. pointerId: number;
  47221. }>;
  47222. /**
  47223. * If the attached mesh should be moved when dragged
  47224. */
  47225. moveAttached: boolean;
  47226. /**
  47227. * If the drag behavior will react to drag events (Default: true)
  47228. */
  47229. enabled: boolean;
  47230. /**
  47231. * If pointer events should start and release the drag (Default: true)
  47232. */
  47233. startAndReleaseDragOnPointerEvents: boolean;
  47234. /**
  47235. * If camera controls should be detached during the drag
  47236. */
  47237. detachCameraControls: boolean;
  47238. /**
  47239. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47240. */
  47241. useObjectOrientationForDragging: boolean;
  47242. private _options;
  47243. /**
  47244. * Gets the options used by the behavior
  47245. */
  47246. get options(): {
  47247. dragAxis?: Vector3;
  47248. dragPlaneNormal?: Vector3;
  47249. };
  47250. /**
  47251. * Sets the options used by the behavior
  47252. */
  47253. set options(options: {
  47254. dragAxis?: Vector3;
  47255. dragPlaneNormal?: Vector3;
  47256. });
  47257. /**
  47258. * Creates a pointer drag behavior that can be attached to a mesh
  47259. * @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)
  47260. */
  47261. constructor(options?: {
  47262. dragAxis?: Vector3;
  47263. dragPlaneNormal?: Vector3;
  47264. });
  47265. /**
  47266. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47267. */
  47268. validateDrag: (targetPosition: Vector3) => boolean;
  47269. /**
  47270. * The name of the behavior
  47271. */
  47272. get name(): string;
  47273. /**
  47274. * Initializes the behavior
  47275. */
  47276. init(): void;
  47277. private _tmpVector;
  47278. private _alternatePickedPoint;
  47279. private _worldDragAxis;
  47280. private _targetPosition;
  47281. private _attachedToElement;
  47282. /**
  47283. * Attaches the drag behavior the passed in mesh
  47284. * @param ownerNode The mesh that will be dragged around once attached
  47285. * @param predicate Predicate to use for pick filtering
  47286. */
  47287. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47288. /**
  47289. * Force relase the drag action by code.
  47290. */
  47291. releaseDrag(): void;
  47292. private _startDragRay;
  47293. private _lastPointerRay;
  47294. /**
  47295. * Simulates the start of a pointer drag event on the behavior
  47296. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47297. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47298. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47299. */
  47300. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47301. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47302. private _dragDelta;
  47303. protected _moveDrag(ray: Ray): void;
  47304. private _pickWithRayOnDragPlane;
  47305. private _pointA;
  47306. private _pointC;
  47307. private _localAxis;
  47308. private _lookAt;
  47309. private _updateDragPlanePosition;
  47310. /**
  47311. * Detaches the behavior from the mesh
  47312. */
  47313. detach(): void;
  47314. }
  47315. }
  47316. declare module BABYLON {
  47317. /**
  47318. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47319. */
  47320. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47321. private _dragBehaviorA;
  47322. private _dragBehaviorB;
  47323. private _startDistance;
  47324. private _initialScale;
  47325. private _targetScale;
  47326. private _ownerNode;
  47327. private _sceneRenderObserver;
  47328. /**
  47329. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47330. */
  47331. constructor();
  47332. /**
  47333. * The name of the behavior
  47334. */
  47335. get name(): string;
  47336. /**
  47337. * Initializes the behavior
  47338. */
  47339. init(): void;
  47340. private _getCurrentDistance;
  47341. /**
  47342. * Attaches the scale behavior the passed in mesh
  47343. * @param ownerNode The mesh that will be scaled around once attached
  47344. */
  47345. attach(ownerNode: Mesh): void;
  47346. /**
  47347. * Detaches the behavior from the mesh
  47348. */
  47349. detach(): void;
  47350. }
  47351. }
  47352. declare module BABYLON {
  47353. /**
  47354. * 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
  47355. */
  47356. export class SixDofDragBehavior implements Behavior<Mesh> {
  47357. private static _virtualScene;
  47358. private _ownerNode;
  47359. private _sceneRenderObserver;
  47360. private _scene;
  47361. private _targetPosition;
  47362. private _virtualOriginMesh;
  47363. private _virtualDragMesh;
  47364. private _pointerObserver;
  47365. private _moving;
  47366. private _startingOrientation;
  47367. private _attachedToElement;
  47368. /**
  47369. * 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)
  47370. */
  47371. private zDragFactor;
  47372. /**
  47373. * If the object should rotate to face the drag origin
  47374. */
  47375. rotateDraggedObject: boolean;
  47376. /**
  47377. * If the behavior is currently in a dragging state
  47378. */
  47379. dragging: boolean;
  47380. /**
  47381. * 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)
  47382. */
  47383. dragDeltaRatio: number;
  47384. /**
  47385. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47386. */
  47387. currentDraggingPointerID: number;
  47388. /**
  47389. * If camera controls should be detached during the drag
  47390. */
  47391. detachCameraControls: boolean;
  47392. /**
  47393. * Fires each time a drag starts
  47394. */
  47395. onDragStartObservable: Observable<{}>;
  47396. /**
  47397. * Fires each time a drag happens
  47398. */
  47399. onDragObservable: Observable<void>;
  47400. /**
  47401. * Fires each time a drag ends (eg. mouse release after drag)
  47402. */
  47403. onDragEndObservable: Observable<{}>;
  47404. /**
  47405. * 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
  47406. */
  47407. constructor();
  47408. /**
  47409. * The name of the behavior
  47410. */
  47411. get name(): string;
  47412. /**
  47413. * Initializes the behavior
  47414. */
  47415. init(): void;
  47416. /**
  47417. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47418. */
  47419. private get _pointerCamera();
  47420. /**
  47421. * Attaches the scale behavior the passed in mesh
  47422. * @param ownerNode The mesh that will be scaled around once attached
  47423. */
  47424. attach(ownerNode: Mesh): void;
  47425. /**
  47426. * Detaches the behavior from the mesh
  47427. */
  47428. detach(): void;
  47429. }
  47430. }
  47431. declare module BABYLON {
  47432. /**
  47433. * Class used to apply inverse kinematics to bones
  47434. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47435. */
  47436. export class BoneIKController {
  47437. private static _tmpVecs;
  47438. private static _tmpQuat;
  47439. private static _tmpMats;
  47440. /**
  47441. * Gets or sets the target mesh
  47442. */
  47443. targetMesh: AbstractMesh;
  47444. /** Gets or sets the mesh used as pole */
  47445. poleTargetMesh: AbstractMesh;
  47446. /**
  47447. * Gets or sets the bone used as pole
  47448. */
  47449. poleTargetBone: Nullable<Bone>;
  47450. /**
  47451. * Gets or sets the target position
  47452. */
  47453. targetPosition: Vector3;
  47454. /**
  47455. * Gets or sets the pole target position
  47456. */
  47457. poleTargetPosition: Vector3;
  47458. /**
  47459. * Gets or sets the pole target local offset
  47460. */
  47461. poleTargetLocalOffset: Vector3;
  47462. /**
  47463. * Gets or sets the pole angle
  47464. */
  47465. poleAngle: number;
  47466. /**
  47467. * Gets or sets the mesh associated with the controller
  47468. */
  47469. mesh: AbstractMesh;
  47470. /**
  47471. * 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)
  47472. */
  47473. slerpAmount: number;
  47474. private _bone1Quat;
  47475. private _bone1Mat;
  47476. private _bone2Ang;
  47477. private _bone1;
  47478. private _bone2;
  47479. private _bone1Length;
  47480. private _bone2Length;
  47481. private _maxAngle;
  47482. private _maxReach;
  47483. private _rightHandedSystem;
  47484. private _bendAxis;
  47485. private _slerping;
  47486. private _adjustRoll;
  47487. /**
  47488. * Gets or sets maximum allowed angle
  47489. */
  47490. get maxAngle(): number;
  47491. set maxAngle(value: number);
  47492. /**
  47493. * Creates a new BoneIKController
  47494. * @param mesh defines the mesh to control
  47495. * @param bone defines the bone to control
  47496. * @param options defines options to set up the controller
  47497. */
  47498. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47499. targetMesh?: AbstractMesh;
  47500. poleTargetMesh?: AbstractMesh;
  47501. poleTargetBone?: Bone;
  47502. poleTargetLocalOffset?: Vector3;
  47503. poleAngle?: number;
  47504. bendAxis?: Vector3;
  47505. maxAngle?: number;
  47506. slerpAmount?: number;
  47507. });
  47508. private _setMaxAngle;
  47509. /**
  47510. * Force the controller to update the bones
  47511. */
  47512. update(): void;
  47513. }
  47514. }
  47515. declare module BABYLON {
  47516. /**
  47517. * Class used to make a bone look toward a point in space
  47518. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47519. */
  47520. export class BoneLookController {
  47521. private static _tmpVecs;
  47522. private static _tmpQuat;
  47523. private static _tmpMats;
  47524. /**
  47525. * The target Vector3 that the bone will look at
  47526. */
  47527. target: Vector3;
  47528. /**
  47529. * The mesh that the bone is attached to
  47530. */
  47531. mesh: AbstractMesh;
  47532. /**
  47533. * The bone that will be looking to the target
  47534. */
  47535. bone: Bone;
  47536. /**
  47537. * The up axis of the coordinate system that is used when the bone is rotated
  47538. */
  47539. upAxis: Vector3;
  47540. /**
  47541. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47542. */
  47543. upAxisSpace: Space;
  47544. /**
  47545. * Used to make an adjustment to the yaw of the bone
  47546. */
  47547. adjustYaw: number;
  47548. /**
  47549. * Used to make an adjustment to the pitch of the bone
  47550. */
  47551. adjustPitch: number;
  47552. /**
  47553. * Used to make an adjustment to the roll of the bone
  47554. */
  47555. adjustRoll: number;
  47556. /**
  47557. * 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)
  47558. */
  47559. slerpAmount: number;
  47560. private _minYaw;
  47561. private _maxYaw;
  47562. private _minPitch;
  47563. private _maxPitch;
  47564. private _minYawSin;
  47565. private _minYawCos;
  47566. private _maxYawSin;
  47567. private _maxYawCos;
  47568. private _midYawConstraint;
  47569. private _minPitchTan;
  47570. private _maxPitchTan;
  47571. private _boneQuat;
  47572. private _slerping;
  47573. private _transformYawPitch;
  47574. private _transformYawPitchInv;
  47575. private _firstFrameSkipped;
  47576. private _yawRange;
  47577. private _fowardAxis;
  47578. /**
  47579. * Gets or sets the minimum yaw angle that the bone can look to
  47580. */
  47581. get minYaw(): number;
  47582. set minYaw(value: number);
  47583. /**
  47584. * Gets or sets the maximum yaw angle that the bone can look to
  47585. */
  47586. get maxYaw(): number;
  47587. set maxYaw(value: number);
  47588. /**
  47589. * Gets or sets the minimum pitch angle that the bone can look to
  47590. */
  47591. get minPitch(): number;
  47592. set minPitch(value: number);
  47593. /**
  47594. * Gets or sets the maximum pitch angle that the bone can look to
  47595. */
  47596. get maxPitch(): number;
  47597. set maxPitch(value: number);
  47598. /**
  47599. * Create a BoneLookController
  47600. * @param mesh the mesh that the bone belongs to
  47601. * @param bone the bone that will be looking to the target
  47602. * @param target the target Vector3 to look at
  47603. * @param options optional settings:
  47604. * * maxYaw: the maximum angle the bone will yaw to
  47605. * * minYaw: the minimum angle the bone will yaw to
  47606. * * maxPitch: the maximum angle the bone will pitch to
  47607. * * minPitch: the minimum angle the bone will yaw to
  47608. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47609. * * upAxis: the up axis of the coordinate system
  47610. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47611. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47612. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47613. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47614. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47615. * * adjustRoll: used to make an adjustment to the roll of the bone
  47616. **/
  47617. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47618. maxYaw?: number;
  47619. minYaw?: number;
  47620. maxPitch?: number;
  47621. minPitch?: number;
  47622. slerpAmount?: number;
  47623. upAxis?: Vector3;
  47624. upAxisSpace?: Space;
  47625. yawAxis?: Vector3;
  47626. pitchAxis?: Vector3;
  47627. adjustYaw?: number;
  47628. adjustPitch?: number;
  47629. adjustRoll?: number;
  47630. });
  47631. /**
  47632. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47633. */
  47634. update(): void;
  47635. private _getAngleDiff;
  47636. private _getAngleBetween;
  47637. private _isAngleBetween;
  47638. }
  47639. }
  47640. declare module BABYLON {
  47641. /**
  47642. * Manage the gamepad inputs to control an arc rotate camera.
  47643. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47644. */
  47645. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47646. /**
  47647. * Defines the camera the input is attached to.
  47648. */
  47649. camera: ArcRotateCamera;
  47650. /**
  47651. * Defines the gamepad the input is gathering event from.
  47652. */
  47653. gamepad: Nullable<Gamepad>;
  47654. /**
  47655. * Defines the gamepad rotation sensiblity.
  47656. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47657. */
  47658. gamepadRotationSensibility: number;
  47659. /**
  47660. * Defines the gamepad move sensiblity.
  47661. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47662. */
  47663. gamepadMoveSensibility: number;
  47664. private _yAxisScale;
  47665. /**
  47666. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47667. */
  47668. get invertYAxis(): boolean;
  47669. set invertYAxis(value: boolean);
  47670. private _onGamepadConnectedObserver;
  47671. private _onGamepadDisconnectedObserver;
  47672. /**
  47673. * Attach the input controls to a specific dom element to get the input from.
  47674. */
  47675. attachControl(): void;
  47676. /**
  47677. * Detach the current controls from the specified dom element.
  47678. */
  47679. detachControl(): void;
  47680. /**
  47681. * Update the current camera state depending on the inputs that have been used this frame.
  47682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47683. */
  47684. checkInputs(): void;
  47685. /**
  47686. * Gets the class name of the current intput.
  47687. * @returns the class name
  47688. */
  47689. getClassName(): string;
  47690. /**
  47691. * Get the friendly name associated with the input class.
  47692. * @returns the input friendly name
  47693. */
  47694. getSimpleName(): string;
  47695. }
  47696. }
  47697. declare module BABYLON {
  47698. interface ArcRotateCameraInputsManager {
  47699. /**
  47700. * Add orientation input support to the input manager.
  47701. * @returns the current input manager
  47702. */
  47703. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47704. }
  47705. /**
  47706. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47707. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47708. */
  47709. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47710. /**
  47711. * Defines the camera the input is attached to.
  47712. */
  47713. camera: ArcRotateCamera;
  47714. /**
  47715. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47716. */
  47717. alphaCorrection: number;
  47718. /**
  47719. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47720. */
  47721. gammaCorrection: number;
  47722. private _alpha;
  47723. private _gamma;
  47724. private _dirty;
  47725. private _deviceOrientationHandler;
  47726. /**
  47727. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47728. */
  47729. constructor();
  47730. /**
  47731. * Attach the input controls to a specific dom element to get the input from.
  47732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47733. */
  47734. attachControl(noPreventDefault?: boolean): void;
  47735. /** @hidden */
  47736. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47737. /**
  47738. * Update the current camera state depending on the inputs that have been used this frame.
  47739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47740. */
  47741. checkInputs(): void;
  47742. /**
  47743. * Detach the current controls from the specified dom element.
  47744. */
  47745. detachControl(): void;
  47746. /**
  47747. * Gets the class name of the current intput.
  47748. * @returns the class name
  47749. */
  47750. getClassName(): string;
  47751. /**
  47752. * Get the friendly name associated with the input class.
  47753. * @returns the input friendly name
  47754. */
  47755. getSimpleName(): string;
  47756. }
  47757. }
  47758. declare module BABYLON {
  47759. /**
  47760. * Listen to mouse events to control the camera.
  47761. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47762. */
  47763. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47764. /**
  47765. * Defines the camera the input is attached to.
  47766. */
  47767. camera: FlyCamera;
  47768. /**
  47769. * Defines if touch is enabled. (Default is true.)
  47770. */
  47771. touchEnabled: boolean;
  47772. /**
  47773. * Defines the buttons associated with the input to handle camera rotation.
  47774. */
  47775. buttons: number[];
  47776. /**
  47777. * Assign buttons for Yaw control.
  47778. */
  47779. buttonsYaw: number[];
  47780. /**
  47781. * Assign buttons for Pitch control.
  47782. */
  47783. buttonsPitch: number[];
  47784. /**
  47785. * Assign buttons for Roll control.
  47786. */
  47787. buttonsRoll: number[];
  47788. /**
  47789. * Detect if any button is being pressed while mouse is moved.
  47790. * -1 = Mouse locked.
  47791. * 0 = Left button.
  47792. * 1 = Middle Button.
  47793. * 2 = Right Button.
  47794. */
  47795. activeButton: number;
  47796. /**
  47797. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47798. * Higher values reduce its sensitivity.
  47799. */
  47800. angularSensibility: number;
  47801. private _observer;
  47802. private _rollObserver;
  47803. private previousPosition;
  47804. private noPreventDefault;
  47805. private element;
  47806. /**
  47807. * Listen to mouse events to control the camera.
  47808. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47809. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47810. */
  47811. constructor(touchEnabled?: boolean);
  47812. /**
  47813. * Attach the mouse control to the HTML DOM element.
  47814. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47815. */
  47816. attachControl(noPreventDefault?: boolean): void;
  47817. /**
  47818. * Detach the current controls from the specified dom element.
  47819. */
  47820. detachControl(): void;
  47821. /**
  47822. * Gets the class name of the current input.
  47823. * @returns the class name.
  47824. */
  47825. getClassName(): string;
  47826. /**
  47827. * Get the friendly name associated with the input class.
  47828. * @returns the input's friendly name.
  47829. */
  47830. getSimpleName(): string;
  47831. private _pointerInput;
  47832. private _onMouseMove;
  47833. /**
  47834. * Rotate camera by mouse offset.
  47835. */
  47836. private rotateCamera;
  47837. }
  47838. }
  47839. declare module BABYLON {
  47840. /**
  47841. * Default Inputs manager for the FlyCamera.
  47842. * It groups all the default supported inputs for ease of use.
  47843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47844. */
  47845. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47846. /**
  47847. * Instantiates a new FlyCameraInputsManager.
  47848. * @param camera Defines the camera the inputs belong to.
  47849. */
  47850. constructor(camera: FlyCamera);
  47851. /**
  47852. * Add keyboard input support to the input manager.
  47853. * @returns the new FlyCameraKeyboardMoveInput().
  47854. */
  47855. addKeyboard(): FlyCameraInputsManager;
  47856. /**
  47857. * Add mouse input support to the input manager.
  47858. * @param touchEnabled Enable touch screen support.
  47859. * @returns the new FlyCameraMouseInput().
  47860. */
  47861. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47862. }
  47863. }
  47864. declare module BABYLON {
  47865. /**
  47866. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47867. * such as in a 3D Space Shooter or a Flight Simulator.
  47868. */
  47869. export class FlyCamera extends TargetCamera {
  47870. /**
  47871. * Define the collision ellipsoid of the camera.
  47872. * This is helpful for simulating a camera body, like a player's body.
  47873. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47874. */
  47875. ellipsoid: Vector3;
  47876. /**
  47877. * Define an offset for the position of the ellipsoid around the camera.
  47878. * This can be helpful if the camera is attached away from the player's body center,
  47879. * such as at its head.
  47880. */
  47881. ellipsoidOffset: Vector3;
  47882. /**
  47883. * Enable or disable collisions of the camera with the rest of the scene objects.
  47884. */
  47885. checkCollisions: boolean;
  47886. /**
  47887. * Enable or disable gravity on the camera.
  47888. */
  47889. applyGravity: boolean;
  47890. /**
  47891. * Define the current direction the camera is moving to.
  47892. */
  47893. cameraDirection: Vector3;
  47894. /**
  47895. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47896. * This overrides and empties cameraRotation.
  47897. */
  47898. rotationQuaternion: Quaternion;
  47899. /**
  47900. * Track Roll to maintain the wanted Rolling when looking around.
  47901. */
  47902. _trackRoll: number;
  47903. /**
  47904. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47905. */
  47906. rollCorrect: number;
  47907. /**
  47908. * Mimic a banked turn, Rolling the camera when Yawing.
  47909. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47910. */
  47911. bankedTurn: boolean;
  47912. /**
  47913. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47914. */
  47915. bankedTurnLimit: number;
  47916. /**
  47917. * Value of 0 disables the banked Roll.
  47918. * Value of 1 is equal to the Yaw angle in radians.
  47919. */
  47920. bankedTurnMultiplier: number;
  47921. /**
  47922. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47923. */
  47924. inputs: FlyCameraInputsManager;
  47925. /**
  47926. * Gets the input sensibility for mouse input.
  47927. * Higher values reduce sensitivity.
  47928. */
  47929. get angularSensibility(): number;
  47930. /**
  47931. * Sets the input sensibility for a mouse input.
  47932. * Higher values reduce sensitivity.
  47933. */
  47934. set angularSensibility(value: number);
  47935. /**
  47936. * Get the keys for camera movement forward.
  47937. */
  47938. get keysForward(): number[];
  47939. /**
  47940. * Set the keys for camera movement forward.
  47941. */
  47942. set keysForward(value: number[]);
  47943. /**
  47944. * Get the keys for camera movement backward.
  47945. */
  47946. get keysBackward(): number[];
  47947. set keysBackward(value: number[]);
  47948. /**
  47949. * Get the keys for camera movement up.
  47950. */
  47951. get keysUp(): number[];
  47952. /**
  47953. * Set the keys for camera movement up.
  47954. */
  47955. set keysUp(value: number[]);
  47956. /**
  47957. * Get the keys for camera movement down.
  47958. */
  47959. get keysDown(): number[];
  47960. /**
  47961. * Set the keys for camera movement down.
  47962. */
  47963. set keysDown(value: number[]);
  47964. /**
  47965. * Get the keys for camera movement left.
  47966. */
  47967. get keysLeft(): number[];
  47968. /**
  47969. * Set the keys for camera movement left.
  47970. */
  47971. set keysLeft(value: number[]);
  47972. /**
  47973. * Set the keys for camera movement right.
  47974. */
  47975. get keysRight(): number[];
  47976. /**
  47977. * Set the keys for camera movement right.
  47978. */
  47979. set keysRight(value: number[]);
  47980. /**
  47981. * Event raised when the camera collides with a mesh in the scene.
  47982. */
  47983. onCollide: (collidedMesh: AbstractMesh) => void;
  47984. private _collider;
  47985. private _needMoveForGravity;
  47986. private _oldPosition;
  47987. private _diffPosition;
  47988. private _newPosition;
  47989. /** @hidden */
  47990. _localDirection: Vector3;
  47991. /** @hidden */
  47992. _transformedDirection: Vector3;
  47993. /**
  47994. * Instantiates a FlyCamera.
  47995. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47996. * such as in a 3D Space Shooter or a Flight Simulator.
  47997. * @param name Define the name of the camera in the scene.
  47998. * @param position Define the starting position of the camera in the scene.
  47999. * @param scene Define the scene the camera belongs to.
  48000. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  48001. */
  48002. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48003. /**
  48004. * Attach the input controls to a specific dom element to get the input from.
  48005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48006. */
  48007. attachControl(noPreventDefault?: boolean): void;
  48008. /**
  48009. * Detach a control from the HTML DOM element.
  48010. * The camera will stop reacting to that input.
  48011. */
  48012. detachControl(): void;
  48013. private _collisionMask;
  48014. /**
  48015. * Get the mask that the camera ignores in collision events.
  48016. */
  48017. get collisionMask(): number;
  48018. /**
  48019. * Set the mask that the camera ignores in collision events.
  48020. */
  48021. set collisionMask(mask: number);
  48022. /** @hidden */
  48023. _collideWithWorld(displacement: Vector3): void;
  48024. /** @hidden */
  48025. private _onCollisionPositionChange;
  48026. /** @hidden */
  48027. _checkInputs(): void;
  48028. /** @hidden */
  48029. _decideIfNeedsToMove(): boolean;
  48030. /** @hidden */
  48031. _updatePosition(): void;
  48032. /**
  48033. * Restore the Roll to its target value at the rate specified.
  48034. * @param rate - Higher means slower restoring.
  48035. * @hidden
  48036. */
  48037. restoreRoll(rate: number): void;
  48038. /**
  48039. * Destroy the camera and release the current resources held by it.
  48040. */
  48041. dispose(): void;
  48042. /**
  48043. * Get the current object class name.
  48044. * @returns the class name.
  48045. */
  48046. getClassName(): string;
  48047. }
  48048. }
  48049. declare module BABYLON {
  48050. /**
  48051. * Listen to keyboard events to control the camera.
  48052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48053. */
  48054. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48055. /**
  48056. * Defines the camera the input is attached to.
  48057. */
  48058. camera: FlyCamera;
  48059. /**
  48060. * The list of keyboard keys used to control the forward move of the camera.
  48061. */
  48062. keysForward: number[];
  48063. /**
  48064. * The list of keyboard keys used to control the backward move of the camera.
  48065. */
  48066. keysBackward: number[];
  48067. /**
  48068. * The list of keyboard keys used to control the forward move of the camera.
  48069. */
  48070. keysUp: number[];
  48071. /**
  48072. * The list of keyboard keys used to control the backward move of the camera.
  48073. */
  48074. keysDown: number[];
  48075. /**
  48076. * The list of keyboard keys used to control the right strafe move of the camera.
  48077. */
  48078. keysRight: number[];
  48079. /**
  48080. * The list of keyboard keys used to control the left strafe move of the camera.
  48081. */
  48082. keysLeft: number[];
  48083. private _keys;
  48084. private _onCanvasBlurObserver;
  48085. private _onKeyboardObserver;
  48086. private _engine;
  48087. private _scene;
  48088. /**
  48089. * Attach the input controls to a specific dom element to get the input from.
  48090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48091. */
  48092. attachControl(noPreventDefault?: boolean): void;
  48093. /**
  48094. * Detach the current controls from the specified dom element.
  48095. */
  48096. detachControl(): void;
  48097. /**
  48098. * Gets the class name of the current intput.
  48099. * @returns the class name
  48100. */
  48101. getClassName(): string;
  48102. /** @hidden */
  48103. _onLostFocus(e: FocusEvent): void;
  48104. /**
  48105. * Get the friendly name associated with the input class.
  48106. * @returns the input friendly name
  48107. */
  48108. getSimpleName(): string;
  48109. /**
  48110. * Update the current camera state depending on the inputs that have been used this frame.
  48111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48112. */
  48113. checkInputs(): void;
  48114. }
  48115. }
  48116. declare module BABYLON {
  48117. /**
  48118. * Manage the mouse wheel inputs to control a follow camera.
  48119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48120. */
  48121. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48122. /**
  48123. * Defines the camera the input is attached to.
  48124. */
  48125. camera: FollowCamera;
  48126. /**
  48127. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48128. */
  48129. axisControlRadius: boolean;
  48130. /**
  48131. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48132. */
  48133. axisControlHeight: boolean;
  48134. /**
  48135. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48136. */
  48137. axisControlRotation: boolean;
  48138. /**
  48139. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48140. * relation to mouseWheel events.
  48141. */
  48142. wheelPrecision: number;
  48143. /**
  48144. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48145. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48146. */
  48147. wheelDeltaPercentage: number;
  48148. private _wheel;
  48149. private _observer;
  48150. /**
  48151. * Attach the input controls to a specific dom element to get the input from.
  48152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48153. */
  48154. attachControl(noPreventDefault?: boolean): void;
  48155. /**
  48156. * Detach the current controls from the specified dom element.
  48157. */
  48158. detachControl(): void;
  48159. /**
  48160. * Gets the class name of the current intput.
  48161. * @returns the class name
  48162. */
  48163. getClassName(): string;
  48164. /**
  48165. * Get the friendly name associated with the input class.
  48166. * @returns the input friendly name
  48167. */
  48168. getSimpleName(): string;
  48169. }
  48170. }
  48171. declare module BABYLON {
  48172. /**
  48173. * Manage the pointers inputs to control an follow camera.
  48174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48175. */
  48176. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48177. /**
  48178. * Defines the camera the input is attached to.
  48179. */
  48180. camera: FollowCamera;
  48181. /**
  48182. * Gets the class name of the current input.
  48183. * @returns the class name
  48184. */
  48185. getClassName(): string;
  48186. /**
  48187. * Defines the pointer angular sensibility along the X axis or how fast is
  48188. * the camera rotating.
  48189. * A negative number will reverse the axis direction.
  48190. */
  48191. angularSensibilityX: number;
  48192. /**
  48193. * Defines the pointer angular sensibility along the Y axis or how fast is
  48194. * the camera rotating.
  48195. * A negative number will reverse the axis direction.
  48196. */
  48197. angularSensibilityY: number;
  48198. /**
  48199. * Defines the pointer pinch precision or how fast is the camera zooming.
  48200. * A negative number will reverse the axis direction.
  48201. */
  48202. pinchPrecision: number;
  48203. /**
  48204. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48205. * from 0.
  48206. * It defines the percentage of current camera.radius to use as delta when
  48207. * pinch zoom is used.
  48208. */
  48209. pinchDeltaPercentage: number;
  48210. /**
  48211. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48212. */
  48213. axisXControlRadius: boolean;
  48214. /**
  48215. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48216. */
  48217. axisXControlHeight: boolean;
  48218. /**
  48219. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48220. */
  48221. axisXControlRotation: boolean;
  48222. /**
  48223. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48224. */
  48225. axisYControlRadius: boolean;
  48226. /**
  48227. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48228. */
  48229. axisYControlHeight: boolean;
  48230. /**
  48231. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48232. */
  48233. axisYControlRotation: boolean;
  48234. /**
  48235. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48236. */
  48237. axisPinchControlRadius: boolean;
  48238. /**
  48239. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48240. */
  48241. axisPinchControlHeight: boolean;
  48242. /**
  48243. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48244. */
  48245. axisPinchControlRotation: boolean;
  48246. /**
  48247. * Log error messages if basic misconfiguration has occurred.
  48248. */
  48249. warningEnable: boolean;
  48250. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48251. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48252. private _warningCounter;
  48253. private _warning;
  48254. }
  48255. }
  48256. declare module BABYLON {
  48257. /**
  48258. * Default Inputs manager for the FollowCamera.
  48259. * It groups all the default supported inputs for ease of use.
  48260. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48261. */
  48262. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48263. /**
  48264. * Instantiates a new FollowCameraInputsManager.
  48265. * @param camera Defines the camera the inputs belong to
  48266. */
  48267. constructor(camera: FollowCamera);
  48268. /**
  48269. * Add keyboard input support to the input manager.
  48270. * @returns the current input manager
  48271. */
  48272. addKeyboard(): FollowCameraInputsManager;
  48273. /**
  48274. * Add mouse wheel input support to the input manager.
  48275. * @returns the current input manager
  48276. */
  48277. addMouseWheel(): FollowCameraInputsManager;
  48278. /**
  48279. * Add pointers input support to the input manager.
  48280. * @returns the current input manager
  48281. */
  48282. addPointers(): FollowCameraInputsManager;
  48283. /**
  48284. * Add orientation input support to the input manager.
  48285. * @returns the current input manager
  48286. */
  48287. addVRDeviceOrientation(): FollowCameraInputsManager;
  48288. }
  48289. }
  48290. declare module BABYLON {
  48291. /**
  48292. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48293. * an arc rotate version arcFollowCamera are available.
  48294. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48295. */
  48296. export class FollowCamera extends TargetCamera {
  48297. /**
  48298. * Distance the follow camera should follow an object at
  48299. */
  48300. radius: number;
  48301. /**
  48302. * Minimum allowed distance of the camera to the axis of rotation
  48303. * (The camera can not get closer).
  48304. * This can help limiting how the Camera is able to move in the scene.
  48305. */
  48306. lowerRadiusLimit: Nullable<number>;
  48307. /**
  48308. * Maximum allowed distance of the camera to the axis of rotation
  48309. * (The camera can not get further).
  48310. * This can help limiting how the Camera is able to move in the scene.
  48311. */
  48312. upperRadiusLimit: Nullable<number>;
  48313. /**
  48314. * Define a rotation offset between the camera and the object it follows
  48315. */
  48316. rotationOffset: number;
  48317. /**
  48318. * Minimum allowed angle to camera position relative to target object.
  48319. * This can help limiting how the Camera is able to move in the scene.
  48320. */
  48321. lowerRotationOffsetLimit: Nullable<number>;
  48322. /**
  48323. * Maximum allowed angle to camera position relative to target object.
  48324. * This can help limiting how the Camera is able to move in the scene.
  48325. */
  48326. upperRotationOffsetLimit: Nullable<number>;
  48327. /**
  48328. * Define a height offset between the camera and the object it follows.
  48329. * It can help following an object from the top (like a car chaing a plane)
  48330. */
  48331. heightOffset: number;
  48332. /**
  48333. * Minimum allowed height of camera position relative to target object.
  48334. * This can help limiting how the Camera is able to move in the scene.
  48335. */
  48336. lowerHeightOffsetLimit: Nullable<number>;
  48337. /**
  48338. * Maximum allowed height of camera position relative to target object.
  48339. * This can help limiting how the Camera is able to move in the scene.
  48340. */
  48341. upperHeightOffsetLimit: Nullable<number>;
  48342. /**
  48343. * Define how fast the camera can accelerate to follow it s target.
  48344. */
  48345. cameraAcceleration: number;
  48346. /**
  48347. * Define the speed limit of the camera following an object.
  48348. */
  48349. maxCameraSpeed: number;
  48350. /**
  48351. * Define the target of the camera.
  48352. */
  48353. lockedTarget: Nullable<AbstractMesh>;
  48354. /**
  48355. * Defines the input associated with the camera.
  48356. */
  48357. inputs: FollowCameraInputsManager;
  48358. /**
  48359. * Instantiates the follow camera.
  48360. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48361. * @param name Define the name of the camera in the scene
  48362. * @param position Define the position of the camera
  48363. * @param scene Define the scene the camera belong to
  48364. * @param lockedTarget Define the target of the camera
  48365. */
  48366. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48367. private _follow;
  48368. /**
  48369. * Attach the input controls to a specific dom element to get the input from.
  48370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48371. */
  48372. attachControl(noPreventDefault?: boolean): void;
  48373. /**
  48374. * Detach the current controls from the specified dom element.
  48375. */
  48376. detachControl(): void;
  48377. /** @hidden */
  48378. _checkInputs(): void;
  48379. private _checkLimits;
  48380. /**
  48381. * Gets the camera class name.
  48382. * @returns the class name
  48383. */
  48384. getClassName(): string;
  48385. }
  48386. /**
  48387. * Arc Rotate version of the follow camera.
  48388. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48389. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48390. */
  48391. export class ArcFollowCamera extends TargetCamera {
  48392. /** The longitudinal angle of the camera */
  48393. alpha: number;
  48394. /** The latitudinal angle of the camera */
  48395. beta: number;
  48396. /** The radius of the camera from its target */
  48397. radius: number;
  48398. private _cartesianCoordinates;
  48399. /** Define the camera target (the mesh it should follow) */
  48400. private _meshTarget;
  48401. /**
  48402. * Instantiates a new ArcFollowCamera
  48403. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48404. * @param name Define the name of the camera
  48405. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48406. * @param beta Define the rotation angle of the camera around the elevation axis
  48407. * @param radius Define the radius of the camera from its target point
  48408. * @param target Define the target of the camera
  48409. * @param scene Define the scene the camera belongs to
  48410. */
  48411. constructor(name: string,
  48412. /** The longitudinal angle of the camera */
  48413. alpha: number,
  48414. /** The latitudinal angle of the camera */
  48415. beta: number,
  48416. /** The radius of the camera from its target */
  48417. radius: number,
  48418. /** Define the camera target (the mesh it should follow) */
  48419. target: Nullable<AbstractMesh>, scene: Scene);
  48420. private _follow;
  48421. /** @hidden */
  48422. _checkInputs(): void;
  48423. /**
  48424. * Returns the class name of the object.
  48425. * It is mostly used internally for serialization purposes.
  48426. */
  48427. getClassName(): string;
  48428. }
  48429. }
  48430. declare module BABYLON {
  48431. /**
  48432. * Manage the keyboard inputs to control the movement of a follow camera.
  48433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48434. */
  48435. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48436. /**
  48437. * Defines the camera the input is attached to.
  48438. */
  48439. camera: FollowCamera;
  48440. /**
  48441. * Defines the list of key codes associated with the up action (increase heightOffset)
  48442. */
  48443. keysHeightOffsetIncr: number[];
  48444. /**
  48445. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48446. */
  48447. keysHeightOffsetDecr: number[];
  48448. /**
  48449. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48450. */
  48451. keysHeightOffsetModifierAlt: boolean;
  48452. /**
  48453. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48454. */
  48455. keysHeightOffsetModifierCtrl: boolean;
  48456. /**
  48457. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48458. */
  48459. keysHeightOffsetModifierShift: boolean;
  48460. /**
  48461. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48462. */
  48463. keysRotationOffsetIncr: number[];
  48464. /**
  48465. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48466. */
  48467. keysRotationOffsetDecr: number[];
  48468. /**
  48469. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48470. */
  48471. keysRotationOffsetModifierAlt: boolean;
  48472. /**
  48473. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48474. */
  48475. keysRotationOffsetModifierCtrl: boolean;
  48476. /**
  48477. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48478. */
  48479. keysRotationOffsetModifierShift: boolean;
  48480. /**
  48481. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48482. */
  48483. keysRadiusIncr: number[];
  48484. /**
  48485. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48486. */
  48487. keysRadiusDecr: number[];
  48488. /**
  48489. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48490. */
  48491. keysRadiusModifierAlt: boolean;
  48492. /**
  48493. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48494. */
  48495. keysRadiusModifierCtrl: boolean;
  48496. /**
  48497. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48498. */
  48499. keysRadiusModifierShift: boolean;
  48500. /**
  48501. * Defines the rate of change of heightOffset.
  48502. */
  48503. heightSensibility: number;
  48504. /**
  48505. * Defines the rate of change of rotationOffset.
  48506. */
  48507. rotationSensibility: number;
  48508. /**
  48509. * Defines the rate of change of radius.
  48510. */
  48511. radiusSensibility: number;
  48512. private _keys;
  48513. private _ctrlPressed;
  48514. private _altPressed;
  48515. private _shiftPressed;
  48516. private _onCanvasBlurObserver;
  48517. private _onKeyboardObserver;
  48518. private _engine;
  48519. private _scene;
  48520. /**
  48521. * Attach the input controls to a specific dom element to get the input from.
  48522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48523. */
  48524. attachControl(noPreventDefault?: boolean): void;
  48525. /**
  48526. * Detach the current controls from the specified dom element.
  48527. */
  48528. detachControl(): void;
  48529. /**
  48530. * Update the current camera state depending on the inputs that have been used this frame.
  48531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48532. */
  48533. checkInputs(): void;
  48534. /**
  48535. * Gets the class name of the current input.
  48536. * @returns the class name
  48537. */
  48538. getClassName(): string;
  48539. /**
  48540. * Get the friendly name associated with the input class.
  48541. * @returns the input friendly name
  48542. */
  48543. getSimpleName(): string;
  48544. /**
  48545. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48546. * allow modification of the heightOffset value.
  48547. */
  48548. private _modifierHeightOffset;
  48549. /**
  48550. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48551. * allow modification of the rotationOffset value.
  48552. */
  48553. private _modifierRotationOffset;
  48554. /**
  48555. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48556. * allow modification of the radius value.
  48557. */
  48558. private _modifierRadius;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. interface FreeCameraInputsManager {
  48563. /**
  48564. * @hidden
  48565. */
  48566. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48567. /**
  48568. * Add orientation input support to the input manager.
  48569. * @returns the current input manager
  48570. */
  48571. addDeviceOrientation(): FreeCameraInputsManager;
  48572. }
  48573. /**
  48574. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48575. * Screen rotation is taken into account.
  48576. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48577. */
  48578. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48579. private _camera;
  48580. private _screenOrientationAngle;
  48581. private _constantTranform;
  48582. private _screenQuaternion;
  48583. private _alpha;
  48584. private _beta;
  48585. private _gamma;
  48586. /**
  48587. * Can be used to detect if a device orientation sensor is available on a device
  48588. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48589. * @returns a promise that will resolve on orientation change
  48590. */
  48591. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48592. /**
  48593. * @hidden
  48594. */
  48595. _onDeviceOrientationChangedObservable: Observable<void>;
  48596. /**
  48597. * Instantiates a new input
  48598. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48599. */
  48600. constructor();
  48601. /**
  48602. * Define the camera controlled by the input.
  48603. */
  48604. get camera(): FreeCamera;
  48605. set camera(camera: FreeCamera);
  48606. /**
  48607. * Attach the input controls to a specific dom element to get the input from.
  48608. */
  48609. attachControl(): void;
  48610. private _orientationChanged;
  48611. private _deviceOrientation;
  48612. /**
  48613. * Detach the current controls from the specified dom element.
  48614. */
  48615. detachControl(): void;
  48616. /**
  48617. * Update the current camera state depending on the inputs that have been used this frame.
  48618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48619. */
  48620. checkInputs(): void;
  48621. /**
  48622. * Gets the class name of the current intput.
  48623. * @returns the class name
  48624. */
  48625. getClassName(): string;
  48626. /**
  48627. * Get the friendly name associated with the input class.
  48628. * @returns the input friendly name
  48629. */
  48630. getSimpleName(): string;
  48631. }
  48632. }
  48633. declare module BABYLON {
  48634. /**
  48635. * Manage the gamepad inputs to control a free camera.
  48636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48637. */
  48638. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48639. /**
  48640. * Define the camera the input is attached to.
  48641. */
  48642. camera: FreeCamera;
  48643. /**
  48644. * Define the Gamepad controlling the input
  48645. */
  48646. gamepad: Nullable<Gamepad>;
  48647. /**
  48648. * Defines the gamepad rotation sensiblity.
  48649. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48650. */
  48651. gamepadAngularSensibility: number;
  48652. /**
  48653. * Defines the gamepad move sensiblity.
  48654. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48655. */
  48656. gamepadMoveSensibility: number;
  48657. private _yAxisScale;
  48658. /**
  48659. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48660. */
  48661. get invertYAxis(): boolean;
  48662. set invertYAxis(value: boolean);
  48663. private _onGamepadConnectedObserver;
  48664. private _onGamepadDisconnectedObserver;
  48665. private _cameraTransform;
  48666. private _deltaTransform;
  48667. private _vector3;
  48668. private _vector2;
  48669. /**
  48670. * Attach the input controls to a specific dom element to get the input from.
  48671. */
  48672. attachControl(): void;
  48673. /**
  48674. * Detach the current controls from the specified dom element.
  48675. */
  48676. detachControl(): void;
  48677. /**
  48678. * Update the current camera state depending on the inputs that have been used this frame.
  48679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48680. */
  48681. checkInputs(): void;
  48682. /**
  48683. * Gets the class name of the current intput.
  48684. * @returns the class name
  48685. */
  48686. getClassName(): string;
  48687. /**
  48688. * Get the friendly name associated with the input class.
  48689. * @returns the input friendly name
  48690. */
  48691. getSimpleName(): string;
  48692. }
  48693. }
  48694. declare module BABYLON {
  48695. /**
  48696. * Defines the potential axis of a Joystick
  48697. */
  48698. export enum JoystickAxis {
  48699. /** X axis */
  48700. X = 0,
  48701. /** Y axis */
  48702. Y = 1,
  48703. /** Z axis */
  48704. Z = 2
  48705. }
  48706. /**
  48707. * Represents the different customization options available
  48708. * for VirtualJoystick
  48709. */
  48710. interface VirtualJoystickCustomizations {
  48711. /**
  48712. * Size of the joystick's puck
  48713. */
  48714. puckSize: number;
  48715. /**
  48716. * Size of the joystick's container
  48717. */
  48718. containerSize: number;
  48719. /**
  48720. * Color of the joystick && puck
  48721. */
  48722. color: string;
  48723. /**
  48724. * Image URL for the joystick's puck
  48725. */
  48726. puckImage?: string;
  48727. /**
  48728. * Image URL for the joystick's container
  48729. */
  48730. containerImage?: string;
  48731. /**
  48732. * Defines the unmoving position of the joystick container
  48733. */
  48734. position?: {
  48735. x: number;
  48736. y: number;
  48737. };
  48738. /**
  48739. * Defines whether or not the joystick container is always visible
  48740. */
  48741. alwaysVisible: boolean;
  48742. /**
  48743. * Defines whether or not to limit the movement of the puck to the joystick's container
  48744. */
  48745. limitToContainer: boolean;
  48746. }
  48747. /**
  48748. * Class used to define virtual joystick (used in touch mode)
  48749. */
  48750. export class VirtualJoystick {
  48751. /**
  48752. * Gets or sets a boolean indicating that left and right values must be inverted
  48753. */
  48754. reverseLeftRight: boolean;
  48755. /**
  48756. * Gets or sets a boolean indicating that up and down values must be inverted
  48757. */
  48758. reverseUpDown: boolean;
  48759. /**
  48760. * Gets the offset value for the position (ie. the change of the position value)
  48761. */
  48762. deltaPosition: Vector3;
  48763. /**
  48764. * Gets a boolean indicating if the virtual joystick was pressed
  48765. */
  48766. pressed: boolean;
  48767. /**
  48768. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48769. */
  48770. static Canvas: Nullable<HTMLCanvasElement>;
  48771. /**
  48772. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48773. */
  48774. limitToContainer: boolean;
  48775. private static _globalJoystickIndex;
  48776. private static _alwaysVisibleSticks;
  48777. private static vjCanvasContext;
  48778. private static vjCanvasWidth;
  48779. private static vjCanvasHeight;
  48780. private static halfWidth;
  48781. private static _GetDefaultOptions;
  48782. private _action;
  48783. private _axisTargetedByLeftAndRight;
  48784. private _axisTargetedByUpAndDown;
  48785. private _joystickSensibility;
  48786. private _inversedSensibility;
  48787. private _joystickPointerID;
  48788. private _joystickColor;
  48789. private _joystickPointerPos;
  48790. private _joystickPreviousPointerPos;
  48791. private _joystickPointerStartPos;
  48792. private _deltaJoystickVector;
  48793. private _leftJoystick;
  48794. private _touches;
  48795. private _joystickPosition;
  48796. private _alwaysVisible;
  48797. private _puckImage;
  48798. private _containerImage;
  48799. private _joystickPuckSize;
  48800. private _joystickContainerSize;
  48801. private _clearPuckSize;
  48802. private _clearContainerSize;
  48803. private _clearPuckSizeOffset;
  48804. private _clearContainerSizeOffset;
  48805. private _onPointerDownHandlerRef;
  48806. private _onPointerMoveHandlerRef;
  48807. private _onPointerUpHandlerRef;
  48808. private _onResize;
  48809. /**
  48810. * Creates a new virtual joystick
  48811. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48812. * @param customizations Defines the options we want to customize the VirtualJoystick
  48813. */
  48814. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48815. /**
  48816. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48817. * @param newJoystickSensibility defines the new sensibility
  48818. */
  48819. setJoystickSensibility(newJoystickSensibility: number): void;
  48820. private _onPointerDown;
  48821. private _onPointerMove;
  48822. private _onPointerUp;
  48823. /**
  48824. * Change the color of the virtual joystick
  48825. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48826. */
  48827. setJoystickColor(newColor: string): void;
  48828. /**
  48829. * Size of the joystick's container
  48830. */
  48831. set containerSize(newSize: number);
  48832. get containerSize(): number;
  48833. /**
  48834. * Size of the joystick's puck
  48835. */
  48836. set puckSize(newSize: number);
  48837. get puckSize(): number;
  48838. /**
  48839. * Clears the set position of the joystick
  48840. */
  48841. clearPosition(): void;
  48842. /**
  48843. * Defines whether or not the joystick container is always visible
  48844. */
  48845. set alwaysVisible(value: boolean);
  48846. get alwaysVisible(): boolean;
  48847. /**
  48848. * Sets the constant position of the Joystick container
  48849. * @param x X axis coordinate
  48850. * @param y Y axis coordinate
  48851. */
  48852. setPosition(x: number, y: number): void;
  48853. /**
  48854. * Defines a callback to call when the joystick is touched
  48855. * @param action defines the callback
  48856. */
  48857. setActionOnTouch(action: () => any): void;
  48858. /**
  48859. * Defines which axis you'd like to control for left & right
  48860. * @param axis defines the axis to use
  48861. */
  48862. setAxisForLeftRight(axis: JoystickAxis): void;
  48863. /**
  48864. * Defines which axis you'd like to control for up & down
  48865. * @param axis defines the axis to use
  48866. */
  48867. setAxisForUpDown(axis: JoystickAxis): void;
  48868. /**
  48869. * Clears the canvas from the previous puck / container draw
  48870. */
  48871. private _clearPreviousDraw;
  48872. /**
  48873. * Loads `urlPath` to be used for the container's image
  48874. * @param urlPath defines the urlPath of an image to use
  48875. */
  48876. setContainerImage(urlPath: string): void;
  48877. /**
  48878. * Loads `urlPath` to be used for the puck's image
  48879. * @param urlPath defines the urlPath of an image to use
  48880. */
  48881. setPuckImage(urlPath: string): void;
  48882. /**
  48883. * Draws the Virtual Joystick's container
  48884. */
  48885. private _drawContainer;
  48886. /**
  48887. * Draws the Virtual Joystick's puck
  48888. */
  48889. private _drawPuck;
  48890. private _drawVirtualJoystick;
  48891. /**
  48892. * Release internal HTML canvas
  48893. */
  48894. releaseCanvas(): void;
  48895. }
  48896. }
  48897. declare module BABYLON {
  48898. interface FreeCameraInputsManager {
  48899. /**
  48900. * Add virtual joystick input support to the input manager.
  48901. * @returns the current input manager
  48902. */
  48903. addVirtualJoystick(): FreeCameraInputsManager;
  48904. }
  48905. /**
  48906. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48908. */
  48909. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48910. /**
  48911. * Defines the camera the input is attached to.
  48912. */
  48913. camera: FreeCamera;
  48914. private _leftjoystick;
  48915. private _rightjoystick;
  48916. /**
  48917. * Gets the left stick of the virtual joystick.
  48918. * @returns The virtual Joystick
  48919. */
  48920. getLeftJoystick(): VirtualJoystick;
  48921. /**
  48922. * Gets the right stick of the virtual joystick.
  48923. * @returns The virtual Joystick
  48924. */
  48925. getRightJoystick(): VirtualJoystick;
  48926. /**
  48927. * Update the current camera state depending on the inputs that have been used this frame.
  48928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48929. */
  48930. checkInputs(): void;
  48931. /**
  48932. * Attach the input controls to a specific dom element to get the input from.
  48933. */
  48934. attachControl(): void;
  48935. /**
  48936. * Detach the current controls from the specified dom element.
  48937. */
  48938. detachControl(): void;
  48939. /**
  48940. * Gets the class name of the current intput.
  48941. * @returns the class name
  48942. */
  48943. getClassName(): string;
  48944. /**
  48945. * Get the friendly name associated with the input class.
  48946. * @returns the input friendly name
  48947. */
  48948. getSimpleName(): string;
  48949. }
  48950. }
  48951. declare module BABYLON {
  48952. /**
  48953. * This represents a FPS type of camera controlled by touch.
  48954. * This is like a universal camera minus the Gamepad controls.
  48955. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48956. */
  48957. export class TouchCamera extends FreeCamera {
  48958. /**
  48959. * Defines the touch sensibility for rotation.
  48960. * The higher the faster.
  48961. */
  48962. get touchAngularSensibility(): number;
  48963. set touchAngularSensibility(value: number);
  48964. /**
  48965. * Defines the touch sensibility for move.
  48966. * The higher the faster.
  48967. */
  48968. get touchMoveSensibility(): number;
  48969. set touchMoveSensibility(value: number);
  48970. /**
  48971. * Instantiates a new touch camera.
  48972. * This represents a FPS type of camera controlled by touch.
  48973. * This is like a universal camera minus the Gamepad controls.
  48974. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48975. * @param name Define the name of the camera in the scene
  48976. * @param position Define the start position of the camera in the scene
  48977. * @param scene Define the scene the camera belongs to
  48978. */
  48979. constructor(name: string, position: Vector3, scene: Scene);
  48980. /**
  48981. * Gets the current object class name.
  48982. * @return the class name
  48983. */
  48984. getClassName(): string;
  48985. /** @hidden */
  48986. _setupInputs(): void;
  48987. }
  48988. }
  48989. declare module BABYLON {
  48990. /**
  48991. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48992. * being tilted forward or back and left or right.
  48993. */
  48994. export class DeviceOrientationCamera extends FreeCamera {
  48995. private _initialQuaternion;
  48996. private _quaternionCache;
  48997. private _tmpDragQuaternion;
  48998. private _disablePointerInputWhenUsingDeviceOrientation;
  48999. /**
  49000. * Creates a new device orientation camera
  49001. * @param name The name of the camera
  49002. * @param position The start position camera
  49003. * @param scene The scene the camera belongs to
  49004. */
  49005. constructor(name: string, position: Vector3, scene: Scene);
  49006. /**
  49007. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49008. */
  49009. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49010. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49011. private _dragFactor;
  49012. /**
  49013. * Enabled turning on the y axis when the orientation sensor is active
  49014. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49015. */
  49016. enableHorizontalDragging(dragFactor?: number): void;
  49017. /**
  49018. * Gets the current instance class name ("DeviceOrientationCamera").
  49019. * This helps avoiding instanceof at run time.
  49020. * @returns the class name
  49021. */
  49022. getClassName(): string;
  49023. /**
  49024. * @hidden
  49025. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49026. */
  49027. _checkInputs(): void;
  49028. /**
  49029. * Reset the camera to its default orientation on the specified axis only.
  49030. * @param axis The axis to reset
  49031. */
  49032. resetToCurrentRotation(axis?: Axis): void;
  49033. }
  49034. }
  49035. declare module BABYLON {
  49036. /**
  49037. * Defines supported buttons for XBox360 compatible gamepads
  49038. */
  49039. export enum Xbox360Button {
  49040. /** A */
  49041. A = 0,
  49042. /** B */
  49043. B = 1,
  49044. /** X */
  49045. X = 2,
  49046. /** Y */
  49047. Y = 3,
  49048. /** Left button */
  49049. LB = 4,
  49050. /** Right button */
  49051. RB = 5,
  49052. /** Back */
  49053. Back = 8,
  49054. /** Start */
  49055. Start = 9,
  49056. /** Left stick */
  49057. LeftStick = 10,
  49058. /** Right stick */
  49059. RightStick = 11
  49060. }
  49061. /** Defines values for XBox360 DPad */
  49062. export enum Xbox360Dpad {
  49063. /** Up */
  49064. Up = 12,
  49065. /** Down */
  49066. Down = 13,
  49067. /** Left */
  49068. Left = 14,
  49069. /** Right */
  49070. Right = 15
  49071. }
  49072. /**
  49073. * Defines a XBox360 gamepad
  49074. */
  49075. export class Xbox360Pad extends Gamepad {
  49076. private _leftTrigger;
  49077. private _rightTrigger;
  49078. private _onlefttriggerchanged;
  49079. private _onrighttriggerchanged;
  49080. private _onbuttondown;
  49081. private _onbuttonup;
  49082. private _ondpaddown;
  49083. private _ondpadup;
  49084. /** Observable raised when a button is pressed */
  49085. onButtonDownObservable: Observable<Xbox360Button>;
  49086. /** Observable raised when a button is released */
  49087. onButtonUpObservable: Observable<Xbox360Button>;
  49088. /** Observable raised when a pad is pressed */
  49089. onPadDownObservable: Observable<Xbox360Dpad>;
  49090. /** Observable raised when a pad is released */
  49091. onPadUpObservable: Observable<Xbox360Dpad>;
  49092. private _buttonA;
  49093. private _buttonB;
  49094. private _buttonX;
  49095. private _buttonY;
  49096. private _buttonBack;
  49097. private _buttonStart;
  49098. private _buttonLB;
  49099. private _buttonRB;
  49100. private _buttonLeftStick;
  49101. private _buttonRightStick;
  49102. private _dPadUp;
  49103. private _dPadDown;
  49104. private _dPadLeft;
  49105. private _dPadRight;
  49106. private _isXboxOnePad;
  49107. /**
  49108. * Creates a new XBox360 gamepad object
  49109. * @param id defines the id of this gamepad
  49110. * @param index defines its index
  49111. * @param gamepad defines the internal HTML gamepad object
  49112. * @param xboxOne defines if it is a XBox One gamepad
  49113. */
  49114. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49115. /**
  49116. * Defines the callback to call when left trigger is pressed
  49117. * @param callback defines the callback to use
  49118. */
  49119. onlefttriggerchanged(callback: (value: number) => void): void;
  49120. /**
  49121. * Defines the callback to call when right trigger is pressed
  49122. * @param callback defines the callback to use
  49123. */
  49124. onrighttriggerchanged(callback: (value: number) => void): void;
  49125. /**
  49126. * Gets the left trigger value
  49127. */
  49128. get leftTrigger(): number;
  49129. /**
  49130. * Sets the left trigger value
  49131. */
  49132. set leftTrigger(newValue: number);
  49133. /**
  49134. * Gets the right trigger value
  49135. */
  49136. get rightTrigger(): number;
  49137. /**
  49138. * Sets the right trigger value
  49139. */
  49140. set rightTrigger(newValue: number);
  49141. /**
  49142. * Defines the callback to call when a button is pressed
  49143. * @param callback defines the callback to use
  49144. */
  49145. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49146. /**
  49147. * Defines the callback to call when a button is released
  49148. * @param callback defines the callback to use
  49149. */
  49150. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49151. /**
  49152. * Defines the callback to call when a pad is pressed
  49153. * @param callback defines the callback to use
  49154. */
  49155. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49156. /**
  49157. * Defines the callback to call when a pad is released
  49158. * @param callback defines the callback to use
  49159. */
  49160. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49161. private _setButtonValue;
  49162. private _setDPadValue;
  49163. /**
  49164. * Gets the value of the `A` button
  49165. */
  49166. get buttonA(): number;
  49167. /**
  49168. * Sets the value of the `A` button
  49169. */
  49170. set buttonA(value: number);
  49171. /**
  49172. * Gets the value of the `B` button
  49173. */
  49174. get buttonB(): number;
  49175. /**
  49176. * Sets the value of the `B` button
  49177. */
  49178. set buttonB(value: number);
  49179. /**
  49180. * Gets the value of the `X` button
  49181. */
  49182. get buttonX(): number;
  49183. /**
  49184. * Sets the value of the `X` button
  49185. */
  49186. set buttonX(value: number);
  49187. /**
  49188. * Gets the value of the `Y` button
  49189. */
  49190. get buttonY(): number;
  49191. /**
  49192. * Sets the value of the `Y` button
  49193. */
  49194. set buttonY(value: number);
  49195. /**
  49196. * Gets the value of the `Start` button
  49197. */
  49198. get buttonStart(): number;
  49199. /**
  49200. * Sets the value of the `Start` button
  49201. */
  49202. set buttonStart(value: number);
  49203. /**
  49204. * Gets the value of the `Back` button
  49205. */
  49206. get buttonBack(): number;
  49207. /**
  49208. * Sets the value of the `Back` button
  49209. */
  49210. set buttonBack(value: number);
  49211. /**
  49212. * Gets the value of the `Left` button
  49213. */
  49214. get buttonLB(): number;
  49215. /**
  49216. * Sets the value of the `Left` button
  49217. */
  49218. set buttonLB(value: number);
  49219. /**
  49220. * Gets the value of the `Right` button
  49221. */
  49222. get buttonRB(): number;
  49223. /**
  49224. * Sets the value of the `Right` button
  49225. */
  49226. set buttonRB(value: number);
  49227. /**
  49228. * Gets the value of the Left joystick
  49229. */
  49230. get buttonLeftStick(): number;
  49231. /**
  49232. * Sets the value of the Left joystick
  49233. */
  49234. set buttonLeftStick(value: number);
  49235. /**
  49236. * Gets the value of the Right joystick
  49237. */
  49238. get buttonRightStick(): number;
  49239. /**
  49240. * Sets the value of the Right joystick
  49241. */
  49242. set buttonRightStick(value: number);
  49243. /**
  49244. * Gets the value of D-pad up
  49245. */
  49246. get dPadUp(): number;
  49247. /**
  49248. * Sets the value of D-pad up
  49249. */
  49250. set dPadUp(value: number);
  49251. /**
  49252. * Gets the value of D-pad down
  49253. */
  49254. get dPadDown(): number;
  49255. /**
  49256. * Sets the value of D-pad down
  49257. */
  49258. set dPadDown(value: number);
  49259. /**
  49260. * Gets the value of D-pad left
  49261. */
  49262. get dPadLeft(): number;
  49263. /**
  49264. * Sets the value of D-pad left
  49265. */
  49266. set dPadLeft(value: number);
  49267. /**
  49268. * Gets the value of D-pad right
  49269. */
  49270. get dPadRight(): number;
  49271. /**
  49272. * Sets the value of D-pad right
  49273. */
  49274. set dPadRight(value: number);
  49275. /**
  49276. * Force the gamepad to synchronize with device values
  49277. */
  49278. update(): void;
  49279. /**
  49280. * Disposes the gamepad
  49281. */
  49282. dispose(): void;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * Defines supported buttons for DualShock compatible gamepads
  49288. */
  49289. export enum DualShockButton {
  49290. /** Cross */
  49291. Cross = 0,
  49292. /** Circle */
  49293. Circle = 1,
  49294. /** Square */
  49295. Square = 2,
  49296. /** Triangle */
  49297. Triangle = 3,
  49298. /** L1 */
  49299. L1 = 4,
  49300. /** R1 */
  49301. R1 = 5,
  49302. /** Share */
  49303. Share = 8,
  49304. /** Options */
  49305. Options = 9,
  49306. /** Left stick */
  49307. LeftStick = 10,
  49308. /** Right stick */
  49309. RightStick = 11
  49310. }
  49311. /** Defines values for DualShock DPad */
  49312. export enum DualShockDpad {
  49313. /** Up */
  49314. Up = 12,
  49315. /** Down */
  49316. Down = 13,
  49317. /** Left */
  49318. Left = 14,
  49319. /** Right */
  49320. Right = 15
  49321. }
  49322. /**
  49323. * Defines a DualShock gamepad
  49324. */
  49325. export class DualShockPad extends Gamepad {
  49326. private _leftTrigger;
  49327. private _rightTrigger;
  49328. private _onlefttriggerchanged;
  49329. private _onrighttriggerchanged;
  49330. private _onbuttondown;
  49331. private _onbuttonup;
  49332. private _ondpaddown;
  49333. private _ondpadup;
  49334. /** Observable raised when a button is pressed */
  49335. onButtonDownObservable: Observable<DualShockButton>;
  49336. /** Observable raised when a button is released */
  49337. onButtonUpObservable: Observable<DualShockButton>;
  49338. /** Observable raised when a pad is pressed */
  49339. onPadDownObservable: Observable<DualShockDpad>;
  49340. /** Observable raised when a pad is released */
  49341. onPadUpObservable: Observable<DualShockDpad>;
  49342. private _buttonCross;
  49343. private _buttonCircle;
  49344. private _buttonSquare;
  49345. private _buttonTriangle;
  49346. private _buttonShare;
  49347. private _buttonOptions;
  49348. private _buttonL1;
  49349. private _buttonR1;
  49350. private _buttonLeftStick;
  49351. private _buttonRightStick;
  49352. private _dPadUp;
  49353. private _dPadDown;
  49354. private _dPadLeft;
  49355. private _dPadRight;
  49356. /**
  49357. * Creates a new DualShock gamepad object
  49358. * @param id defines the id of this gamepad
  49359. * @param index defines its index
  49360. * @param gamepad defines the internal HTML gamepad object
  49361. */
  49362. constructor(id: string, index: number, gamepad: any);
  49363. /**
  49364. * Defines the callback to call when left trigger is pressed
  49365. * @param callback defines the callback to use
  49366. */
  49367. onlefttriggerchanged(callback: (value: number) => void): void;
  49368. /**
  49369. * Defines the callback to call when right trigger is pressed
  49370. * @param callback defines the callback to use
  49371. */
  49372. onrighttriggerchanged(callback: (value: number) => void): void;
  49373. /**
  49374. * Gets the left trigger value
  49375. */
  49376. get leftTrigger(): number;
  49377. /**
  49378. * Sets the left trigger value
  49379. */
  49380. set leftTrigger(newValue: number);
  49381. /**
  49382. * Gets the right trigger value
  49383. */
  49384. get rightTrigger(): number;
  49385. /**
  49386. * Sets the right trigger value
  49387. */
  49388. set rightTrigger(newValue: number);
  49389. /**
  49390. * Defines the callback to call when a button is pressed
  49391. * @param callback defines the callback to use
  49392. */
  49393. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49394. /**
  49395. * Defines the callback to call when a button is released
  49396. * @param callback defines the callback to use
  49397. */
  49398. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49399. /**
  49400. * Defines the callback to call when a pad is pressed
  49401. * @param callback defines the callback to use
  49402. */
  49403. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49404. /**
  49405. * Defines the callback to call when a pad is released
  49406. * @param callback defines the callback to use
  49407. */
  49408. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49409. private _setButtonValue;
  49410. private _setDPadValue;
  49411. /**
  49412. * Gets the value of the `Cross` button
  49413. */
  49414. get buttonCross(): number;
  49415. /**
  49416. * Sets the value of the `Cross` button
  49417. */
  49418. set buttonCross(value: number);
  49419. /**
  49420. * Gets the value of the `Circle` button
  49421. */
  49422. get buttonCircle(): number;
  49423. /**
  49424. * Sets the value of the `Circle` button
  49425. */
  49426. set buttonCircle(value: number);
  49427. /**
  49428. * Gets the value of the `Square` button
  49429. */
  49430. get buttonSquare(): number;
  49431. /**
  49432. * Sets the value of the `Square` button
  49433. */
  49434. set buttonSquare(value: number);
  49435. /**
  49436. * Gets the value of the `Triangle` button
  49437. */
  49438. get buttonTriangle(): number;
  49439. /**
  49440. * Sets the value of the `Triangle` button
  49441. */
  49442. set buttonTriangle(value: number);
  49443. /**
  49444. * Gets the value of the `Options` button
  49445. */
  49446. get buttonOptions(): number;
  49447. /**
  49448. * Sets the value of the `Options` button
  49449. */
  49450. set buttonOptions(value: number);
  49451. /**
  49452. * Gets the value of the `Share` button
  49453. */
  49454. get buttonShare(): number;
  49455. /**
  49456. * Sets the value of the `Share` button
  49457. */
  49458. set buttonShare(value: number);
  49459. /**
  49460. * Gets the value of the `L1` button
  49461. */
  49462. get buttonL1(): number;
  49463. /**
  49464. * Sets the value of the `L1` button
  49465. */
  49466. set buttonL1(value: number);
  49467. /**
  49468. * Gets the value of the `R1` button
  49469. */
  49470. get buttonR1(): number;
  49471. /**
  49472. * Sets the value of the `R1` button
  49473. */
  49474. set buttonR1(value: number);
  49475. /**
  49476. * Gets the value of the Left joystick
  49477. */
  49478. get buttonLeftStick(): number;
  49479. /**
  49480. * Sets the value of the Left joystick
  49481. */
  49482. set buttonLeftStick(value: number);
  49483. /**
  49484. * Gets the value of the Right joystick
  49485. */
  49486. get buttonRightStick(): number;
  49487. /**
  49488. * Sets the value of the Right joystick
  49489. */
  49490. set buttonRightStick(value: number);
  49491. /**
  49492. * Gets the value of D-pad up
  49493. */
  49494. get dPadUp(): number;
  49495. /**
  49496. * Sets the value of D-pad up
  49497. */
  49498. set dPadUp(value: number);
  49499. /**
  49500. * Gets the value of D-pad down
  49501. */
  49502. get dPadDown(): number;
  49503. /**
  49504. * Sets the value of D-pad down
  49505. */
  49506. set dPadDown(value: number);
  49507. /**
  49508. * Gets the value of D-pad left
  49509. */
  49510. get dPadLeft(): number;
  49511. /**
  49512. * Sets the value of D-pad left
  49513. */
  49514. set dPadLeft(value: number);
  49515. /**
  49516. * Gets the value of D-pad right
  49517. */
  49518. get dPadRight(): number;
  49519. /**
  49520. * Sets the value of D-pad right
  49521. */
  49522. set dPadRight(value: number);
  49523. /**
  49524. * Force the gamepad to synchronize with device values
  49525. */
  49526. update(): void;
  49527. /**
  49528. * Disposes the gamepad
  49529. */
  49530. dispose(): void;
  49531. }
  49532. }
  49533. declare module BABYLON {
  49534. /**
  49535. * Manager for handling gamepads
  49536. */
  49537. export class GamepadManager {
  49538. private _scene?;
  49539. private _babylonGamepads;
  49540. private _oneGamepadConnected;
  49541. /** @hidden */
  49542. _isMonitoring: boolean;
  49543. private _gamepadEventSupported;
  49544. private _gamepadSupport?;
  49545. /**
  49546. * observable to be triggered when the gamepad controller has been connected
  49547. */
  49548. onGamepadConnectedObservable: Observable<Gamepad>;
  49549. /**
  49550. * observable to be triggered when the gamepad controller has been disconnected
  49551. */
  49552. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49553. private _onGamepadConnectedEvent;
  49554. private _onGamepadDisconnectedEvent;
  49555. /**
  49556. * Initializes the gamepad manager
  49557. * @param _scene BabylonJS scene
  49558. */
  49559. constructor(_scene?: Scene | undefined);
  49560. /**
  49561. * The gamepads in the game pad manager
  49562. */
  49563. get gamepads(): Gamepad[];
  49564. /**
  49565. * Get the gamepad controllers based on type
  49566. * @param type The type of gamepad controller
  49567. * @returns Nullable gamepad
  49568. */
  49569. getGamepadByType(type?: number): Nullable<Gamepad>;
  49570. /**
  49571. * Disposes the gamepad manager
  49572. */
  49573. dispose(): void;
  49574. private _addNewGamepad;
  49575. private _startMonitoringGamepads;
  49576. private _stopMonitoringGamepads;
  49577. /** @hidden */
  49578. _checkGamepadsStatus(): void;
  49579. private _updateGamepadObjects;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. interface Scene {
  49584. /** @hidden */
  49585. _gamepadManager: Nullable<GamepadManager>;
  49586. /**
  49587. * Gets the gamepad manager associated with the scene
  49588. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49589. */
  49590. gamepadManager: GamepadManager;
  49591. }
  49592. /**
  49593. * Interface representing a free camera inputs manager
  49594. */
  49595. interface FreeCameraInputsManager {
  49596. /**
  49597. * Adds gamepad input support to the FreeCameraInputsManager.
  49598. * @returns the FreeCameraInputsManager
  49599. */
  49600. addGamepad(): FreeCameraInputsManager;
  49601. }
  49602. /**
  49603. * Interface representing an arc rotate camera inputs manager
  49604. */
  49605. interface ArcRotateCameraInputsManager {
  49606. /**
  49607. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49608. * @returns the camera inputs manager
  49609. */
  49610. addGamepad(): ArcRotateCameraInputsManager;
  49611. }
  49612. /**
  49613. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49614. */
  49615. export class GamepadSystemSceneComponent implements ISceneComponent {
  49616. /**
  49617. * The component name helpfull to identify the component in the list of scene components.
  49618. */
  49619. readonly name: string;
  49620. /**
  49621. * The scene the component belongs to.
  49622. */
  49623. scene: Scene;
  49624. /**
  49625. * Creates a new instance of the component for the given scene
  49626. * @param scene Defines the scene to register the component in
  49627. */
  49628. constructor(scene: Scene);
  49629. /**
  49630. * Registers the component in a given scene
  49631. */
  49632. register(): void;
  49633. /**
  49634. * Rebuilds the elements related to this component in case of
  49635. * context lost for instance.
  49636. */
  49637. rebuild(): void;
  49638. /**
  49639. * Disposes the component and the associated ressources
  49640. */
  49641. dispose(): void;
  49642. private _beforeCameraUpdate;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * 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,
  49648. * which still works and will still be found in many Playgrounds.
  49649. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49650. */
  49651. export class UniversalCamera extends TouchCamera {
  49652. /**
  49653. * Defines the gamepad rotation sensiblity.
  49654. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49655. */
  49656. get gamepadAngularSensibility(): number;
  49657. set gamepadAngularSensibility(value: number);
  49658. /**
  49659. * Defines the gamepad move sensiblity.
  49660. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49661. */
  49662. get gamepadMoveSensibility(): number;
  49663. set gamepadMoveSensibility(value: number);
  49664. /**
  49665. * 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,
  49666. * which still works and will still be found in many Playgrounds.
  49667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49668. * @param name Define the name of the camera in the scene
  49669. * @param position Define the start position of the camera in the scene
  49670. * @param scene Define the scene the camera belongs to
  49671. */
  49672. constructor(name: string, position: Vector3, scene: Scene);
  49673. /**
  49674. * Gets the current object class name.
  49675. * @return the class name
  49676. */
  49677. getClassName(): string;
  49678. }
  49679. }
  49680. declare module BABYLON {
  49681. /**
  49682. * This represents a FPS type of camera. This is only here for back compat purpose.
  49683. * Please use the UniversalCamera instead as both are identical.
  49684. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49685. */
  49686. export class GamepadCamera extends UniversalCamera {
  49687. /**
  49688. * Instantiates a new Gamepad Camera
  49689. * This represents a FPS type of camera. This is only here for back compat purpose.
  49690. * Please use the UniversalCamera instead as both are identical.
  49691. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49692. * @param name Define the name of the camera in the scene
  49693. * @param position Define the start position of the camera in the scene
  49694. * @param scene Define the scene the camera belongs to
  49695. */
  49696. constructor(name: string, position: Vector3, scene: Scene);
  49697. /**
  49698. * Gets the current object class name.
  49699. * @return the class name
  49700. */
  49701. getClassName(): string;
  49702. }
  49703. }
  49704. declare module BABYLON {
  49705. /** @hidden */
  49706. export var passPixelShader: {
  49707. name: string;
  49708. shader: string;
  49709. };
  49710. }
  49711. declare module BABYLON {
  49712. /** @hidden */
  49713. export var passCubePixelShader: {
  49714. name: string;
  49715. shader: string;
  49716. };
  49717. }
  49718. declare module BABYLON {
  49719. /**
  49720. * PassPostProcess which produces an output the same as it's input
  49721. */
  49722. export class PassPostProcess extends PostProcess {
  49723. /**
  49724. * Gets a string identifying the name of the class
  49725. * @returns "PassPostProcess" string
  49726. */
  49727. getClassName(): string;
  49728. /**
  49729. * Creates the PassPostProcess
  49730. * @param name The name of the effect.
  49731. * @param options The required width/height ratio to downsize to before computing the render pass.
  49732. * @param camera The camera to apply the render pass to.
  49733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49734. * @param engine The engine which the post process will be applied. (default: current engine)
  49735. * @param reusable If the post process can be reused on the same frame. (default: false)
  49736. * @param textureType The type of texture to be used when performing the post processing.
  49737. * @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)
  49738. */
  49739. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49740. /** @hidden */
  49741. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49742. }
  49743. /**
  49744. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49745. */
  49746. export class PassCubePostProcess extends PostProcess {
  49747. private _face;
  49748. /**
  49749. * Gets or sets the cube face to display.
  49750. * * 0 is +X
  49751. * * 1 is -X
  49752. * * 2 is +Y
  49753. * * 3 is -Y
  49754. * * 4 is +Z
  49755. * * 5 is -Z
  49756. */
  49757. get face(): number;
  49758. set face(value: number);
  49759. /**
  49760. * Gets a string identifying the name of the class
  49761. * @returns "PassCubePostProcess" string
  49762. */
  49763. getClassName(): string;
  49764. /**
  49765. * Creates the PassCubePostProcess
  49766. * @param name The name of the effect.
  49767. * @param options The required width/height ratio to downsize to before computing the render pass.
  49768. * @param camera The camera to apply the render pass to.
  49769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49770. * @param engine The engine which the post process will be applied. (default: current engine)
  49771. * @param reusable If the post process can be reused on the same frame. (default: false)
  49772. * @param textureType The type of texture to be used when performing the post processing.
  49773. * @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)
  49774. */
  49775. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49776. /** @hidden */
  49777. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49778. }
  49779. }
  49780. declare module BABYLON {
  49781. /** @hidden */
  49782. export var anaglyphPixelShader: {
  49783. name: string;
  49784. shader: string;
  49785. };
  49786. }
  49787. declare module BABYLON {
  49788. /**
  49789. * Postprocess used to generate anaglyphic rendering
  49790. */
  49791. export class AnaglyphPostProcess extends PostProcess {
  49792. private _passedProcess;
  49793. /**
  49794. * Gets a string identifying the name of the class
  49795. * @returns "AnaglyphPostProcess" string
  49796. */
  49797. getClassName(): string;
  49798. /**
  49799. * Creates a new AnaglyphPostProcess
  49800. * @param name defines postprocess name
  49801. * @param options defines creation options or target ratio scale
  49802. * @param rigCameras defines cameras using this postprocess
  49803. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49804. * @param engine defines hosting engine
  49805. * @param reusable defines if the postprocess will be reused multiple times per frame
  49806. */
  49807. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49808. }
  49809. }
  49810. declare module BABYLON {
  49811. /**
  49812. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49813. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49814. */
  49815. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49816. /**
  49817. * Creates a new AnaglyphArcRotateCamera
  49818. * @param name defines camera name
  49819. * @param alpha defines alpha angle (in radians)
  49820. * @param beta defines beta angle (in radians)
  49821. * @param radius defines radius
  49822. * @param target defines camera target
  49823. * @param interaxialDistance defines distance between each color axis
  49824. * @param scene defines the hosting scene
  49825. */
  49826. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49827. /**
  49828. * Gets camera class name
  49829. * @returns AnaglyphArcRotateCamera
  49830. */
  49831. getClassName(): string;
  49832. }
  49833. }
  49834. declare module BABYLON {
  49835. /**
  49836. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49837. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49838. */
  49839. export class AnaglyphFreeCamera extends FreeCamera {
  49840. /**
  49841. * Creates a new AnaglyphFreeCamera
  49842. * @param name defines camera name
  49843. * @param position defines initial position
  49844. * @param interaxialDistance defines distance between each color axis
  49845. * @param scene defines the hosting scene
  49846. */
  49847. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49848. /**
  49849. * Gets camera class name
  49850. * @returns AnaglyphFreeCamera
  49851. */
  49852. getClassName(): string;
  49853. }
  49854. }
  49855. declare module BABYLON {
  49856. /**
  49857. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49858. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49859. */
  49860. export class AnaglyphGamepadCamera extends GamepadCamera {
  49861. /**
  49862. * Creates a new AnaglyphGamepadCamera
  49863. * @param name defines camera name
  49864. * @param position defines initial position
  49865. * @param interaxialDistance defines distance between each color axis
  49866. * @param scene defines the hosting scene
  49867. */
  49868. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49869. /**
  49870. * Gets camera class name
  49871. * @returns AnaglyphGamepadCamera
  49872. */
  49873. getClassName(): string;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49879. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49880. */
  49881. export class AnaglyphUniversalCamera extends UniversalCamera {
  49882. /**
  49883. * Creates a new AnaglyphUniversalCamera
  49884. * @param name defines camera name
  49885. * @param position defines initial position
  49886. * @param interaxialDistance defines distance between each color axis
  49887. * @param scene defines the hosting scene
  49888. */
  49889. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49890. /**
  49891. * Gets camera class name
  49892. * @returns AnaglyphUniversalCamera
  49893. */
  49894. getClassName(): string;
  49895. }
  49896. }
  49897. declare module BABYLON {
  49898. /**
  49899. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49900. * @see https://doc.babylonjs.com/features/cameras
  49901. */
  49902. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49903. /**
  49904. * Creates a new StereoscopicArcRotateCamera
  49905. * @param name defines camera name
  49906. * @param alpha defines alpha angle (in radians)
  49907. * @param beta defines beta angle (in radians)
  49908. * @param radius defines radius
  49909. * @param target defines camera target
  49910. * @param interaxialDistance defines distance between each color axis
  49911. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49912. * @param scene defines the hosting scene
  49913. */
  49914. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49915. /**
  49916. * Gets camera class name
  49917. * @returns StereoscopicArcRotateCamera
  49918. */
  49919. getClassName(): string;
  49920. }
  49921. }
  49922. declare module BABYLON {
  49923. /**
  49924. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49925. * @see https://doc.babylonjs.com/features/cameras
  49926. */
  49927. export class StereoscopicFreeCamera extends FreeCamera {
  49928. /**
  49929. * Creates a new StereoscopicFreeCamera
  49930. * @param name defines camera name
  49931. * @param position defines initial position
  49932. * @param interaxialDistance defines distance between each color axis
  49933. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49934. * @param scene defines the hosting scene
  49935. */
  49936. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49937. /**
  49938. * Gets camera class name
  49939. * @returns StereoscopicFreeCamera
  49940. */
  49941. getClassName(): string;
  49942. }
  49943. }
  49944. declare module BABYLON {
  49945. /**
  49946. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49947. * @see https://doc.babylonjs.com/features/cameras
  49948. */
  49949. export class StereoscopicGamepadCamera extends GamepadCamera {
  49950. /**
  49951. * Creates a new StereoscopicGamepadCamera
  49952. * @param name defines camera name
  49953. * @param position defines initial position
  49954. * @param interaxialDistance defines distance between each color axis
  49955. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49956. * @param scene defines the hosting scene
  49957. */
  49958. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49959. /**
  49960. * Gets camera class name
  49961. * @returns StereoscopicGamepadCamera
  49962. */
  49963. getClassName(): string;
  49964. }
  49965. }
  49966. declare module BABYLON {
  49967. /**
  49968. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49969. * @see https://doc.babylonjs.com/features/cameras
  49970. */
  49971. export class StereoscopicUniversalCamera extends UniversalCamera {
  49972. /**
  49973. * Creates a new StereoscopicUniversalCamera
  49974. * @param name defines camera name
  49975. * @param position defines initial position
  49976. * @param interaxialDistance defines distance between each color axis
  49977. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49978. * @param scene defines the hosting scene
  49979. */
  49980. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49981. /**
  49982. * Gets camera class name
  49983. * @returns StereoscopicUniversalCamera
  49984. */
  49985. getClassName(): string;
  49986. }
  49987. }
  49988. declare module BABYLON {
  49989. /**
  49990. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49993. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49994. */
  49995. export class VirtualJoysticksCamera extends FreeCamera {
  49996. /**
  49997. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49998. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49999. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50000. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50001. * @param name Define the name of the camera in the scene
  50002. * @param position Define the start position of the camera in the scene
  50003. * @param scene Define the scene the camera belongs to
  50004. */
  50005. constructor(name: string, position: Vector3, scene: Scene);
  50006. /**
  50007. * Gets the current object class name.
  50008. * @return the class name
  50009. */
  50010. getClassName(): string;
  50011. }
  50012. }
  50013. declare module BABYLON {
  50014. /**
  50015. * This represents all the required metrics to create a VR camera.
  50016. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50017. */
  50018. export class VRCameraMetrics {
  50019. /**
  50020. * Define the horizontal resolution off the screen.
  50021. */
  50022. hResolution: number;
  50023. /**
  50024. * Define the vertical resolution off the screen.
  50025. */
  50026. vResolution: number;
  50027. /**
  50028. * Define the horizontal screen size.
  50029. */
  50030. hScreenSize: number;
  50031. /**
  50032. * Define the vertical screen size.
  50033. */
  50034. vScreenSize: number;
  50035. /**
  50036. * Define the vertical screen center position.
  50037. */
  50038. vScreenCenter: number;
  50039. /**
  50040. * Define the distance of the eyes to the screen.
  50041. */
  50042. eyeToScreenDistance: number;
  50043. /**
  50044. * Define the distance between both lenses
  50045. */
  50046. lensSeparationDistance: number;
  50047. /**
  50048. * Define the distance between both viewer's eyes.
  50049. */
  50050. interpupillaryDistance: number;
  50051. /**
  50052. * Define the distortion factor of the VR postprocess.
  50053. * Please, touch with care.
  50054. */
  50055. distortionK: number[];
  50056. /**
  50057. * Define the chromatic aberration correction factors for the VR post process.
  50058. */
  50059. chromaAbCorrection: number[];
  50060. /**
  50061. * Define the scale factor of the post process.
  50062. * The smaller the better but the slower.
  50063. */
  50064. postProcessScaleFactor: number;
  50065. /**
  50066. * Define an offset for the lens center.
  50067. */
  50068. lensCenterOffset: number;
  50069. /**
  50070. * Define if the current vr camera should compensate the distortion of the lense or not.
  50071. */
  50072. compensateDistortion: boolean;
  50073. /**
  50074. * Defines if multiview should be enabled when rendering (Default: false)
  50075. */
  50076. multiviewEnabled: boolean;
  50077. /**
  50078. * Gets the rendering aspect ratio based on the provided resolutions.
  50079. */
  50080. get aspectRatio(): number;
  50081. /**
  50082. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50083. */
  50084. get aspectRatioFov(): number;
  50085. /**
  50086. * @hidden
  50087. */
  50088. get leftHMatrix(): Matrix;
  50089. /**
  50090. * @hidden
  50091. */
  50092. get rightHMatrix(): Matrix;
  50093. /**
  50094. * @hidden
  50095. */
  50096. get leftPreViewMatrix(): Matrix;
  50097. /**
  50098. * @hidden
  50099. */
  50100. get rightPreViewMatrix(): Matrix;
  50101. /**
  50102. * Get the default VRMetrics based on the most generic setup.
  50103. * @returns the default vr metrics
  50104. */
  50105. static GetDefault(): VRCameraMetrics;
  50106. }
  50107. }
  50108. declare module BABYLON {
  50109. /** @hidden */
  50110. export var vrDistortionCorrectionPixelShader: {
  50111. name: string;
  50112. shader: string;
  50113. };
  50114. }
  50115. declare module BABYLON {
  50116. /**
  50117. * VRDistortionCorrectionPostProcess used for mobile VR
  50118. */
  50119. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50120. private _isRightEye;
  50121. private _distortionFactors;
  50122. private _postProcessScaleFactor;
  50123. private _lensCenterOffset;
  50124. private _scaleIn;
  50125. private _scaleFactor;
  50126. private _lensCenter;
  50127. /**
  50128. * Gets a string identifying the name of the class
  50129. * @returns "VRDistortionCorrectionPostProcess" string
  50130. */
  50131. getClassName(): string;
  50132. /**
  50133. * Initializes the VRDistortionCorrectionPostProcess
  50134. * @param name The name of the effect.
  50135. * @param camera The camera to apply the render pass to.
  50136. * @param isRightEye If this is for the right eye distortion
  50137. * @param vrMetrics All the required metrics for the VR camera
  50138. */
  50139. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50140. }
  50141. }
  50142. declare module BABYLON {
  50143. /**
  50144. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50145. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50146. */
  50147. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50148. /**
  50149. * Creates a new VRDeviceOrientationArcRotateCamera
  50150. * @param name defines camera name
  50151. * @param alpha defines the camera rotation along the logitudinal axis
  50152. * @param beta defines the camera rotation along the latitudinal axis
  50153. * @param radius defines the camera distance from its target
  50154. * @param target defines the camera target
  50155. * @param scene defines the scene the camera belongs to
  50156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50158. */
  50159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50160. /**
  50161. * Gets camera class name
  50162. * @returns VRDeviceOrientationArcRotateCamera
  50163. */
  50164. getClassName(): string;
  50165. }
  50166. }
  50167. declare module BABYLON {
  50168. /**
  50169. * Camera used to simulate VR rendering (based on FreeCamera)
  50170. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50171. */
  50172. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50173. /**
  50174. * Creates a new VRDeviceOrientationFreeCamera
  50175. * @param name defines camera name
  50176. * @param position defines the start position of the camera
  50177. * @param scene defines the scene the camera belongs to
  50178. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50179. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50180. */
  50181. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50182. /**
  50183. * Gets camera class name
  50184. * @returns VRDeviceOrientationFreeCamera
  50185. */
  50186. getClassName(): string;
  50187. }
  50188. }
  50189. declare module BABYLON {
  50190. /**
  50191. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50192. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50193. */
  50194. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50195. /**
  50196. * Creates a new VRDeviceOrientationGamepadCamera
  50197. * @param name defines camera name
  50198. * @param position defines the start position of the camera
  50199. * @param scene defines the scene the camera belongs to
  50200. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50201. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50202. */
  50203. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50204. /**
  50205. * Gets camera class name
  50206. * @returns VRDeviceOrientationGamepadCamera
  50207. */
  50208. getClassName(): string;
  50209. }
  50210. }
  50211. declare module BABYLON {
  50212. /**
  50213. * A class extending Texture allowing drawing on a texture
  50214. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50215. */
  50216. export class DynamicTexture extends Texture {
  50217. private _generateMipMaps;
  50218. private _canvas;
  50219. private _context;
  50220. /**
  50221. * Creates a DynamicTexture
  50222. * @param name defines the name of the texture
  50223. * @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
  50224. * @param scene defines the scene where you want the texture
  50225. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50226. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50227. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50228. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50229. */
  50230. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50231. /**
  50232. * Get the current class name of the texture useful for serialization or dynamic coding.
  50233. * @returns "DynamicTexture"
  50234. */
  50235. getClassName(): string;
  50236. /**
  50237. * Gets the current state of canRescale
  50238. */
  50239. get canRescale(): boolean;
  50240. private _recreate;
  50241. /**
  50242. * Scales the texture
  50243. * @param ratio the scale factor to apply to both width and height
  50244. */
  50245. scale(ratio: number): void;
  50246. /**
  50247. * Resizes the texture
  50248. * @param width the new width
  50249. * @param height the new height
  50250. */
  50251. scaleTo(width: number, height: number): void;
  50252. /**
  50253. * Gets the context of the canvas used by the texture
  50254. * @returns the canvas context of the dynamic texture
  50255. */
  50256. getContext(): CanvasRenderingContext2D;
  50257. /**
  50258. * Clears the texture
  50259. */
  50260. clear(): void;
  50261. /**
  50262. * Updates the texture
  50263. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50264. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50265. */
  50266. update(invertY?: boolean, premulAlpha?: boolean): void;
  50267. /**
  50268. * Draws text onto the texture
  50269. * @param text defines the text to be drawn
  50270. * @param x defines the placement of the text from the left
  50271. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50272. * @param font defines the font to be used with font-style, font-size, font-name
  50273. * @param color defines the color used for the text
  50274. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50275. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50276. * @param update defines whether texture is immediately update (default is true)
  50277. */
  50278. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50279. /**
  50280. * Clones the texture
  50281. * @returns the clone of the texture.
  50282. */
  50283. clone(): DynamicTexture;
  50284. /**
  50285. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50286. * @returns a serialized dynamic texture object
  50287. */
  50288. serialize(): any;
  50289. private _IsCanvasElement;
  50290. /** @hidden */
  50291. _rebuild(): void;
  50292. }
  50293. }
  50294. declare module BABYLON {
  50295. /**
  50296. * Class containing static functions to help procedurally build meshes
  50297. */
  50298. export class GroundBuilder {
  50299. /**
  50300. * Creates a ground mesh
  50301. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50302. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50304. * @param name defines the name of the mesh
  50305. * @param options defines the options used to create the mesh
  50306. * @param scene defines the hosting scene
  50307. * @returns the ground mesh
  50308. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50309. */
  50310. static CreateGround(name: string, options: {
  50311. width?: number;
  50312. height?: number;
  50313. subdivisions?: number;
  50314. subdivisionsX?: number;
  50315. subdivisionsY?: number;
  50316. updatable?: boolean;
  50317. }, scene: any): Mesh;
  50318. /**
  50319. * Creates a tiled ground mesh
  50320. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50321. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50322. * * 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
  50323. * * 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
  50324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50325. * @param name defines the name of the mesh
  50326. * @param options defines the options used to create the mesh
  50327. * @param scene defines the hosting scene
  50328. * @returns the tiled ground mesh
  50329. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50330. */
  50331. static CreateTiledGround(name: string, options: {
  50332. xmin: number;
  50333. zmin: number;
  50334. xmax: number;
  50335. zmax: number;
  50336. subdivisions?: {
  50337. w: number;
  50338. h: number;
  50339. };
  50340. precision?: {
  50341. w: number;
  50342. h: number;
  50343. };
  50344. updatable?: boolean;
  50345. }, scene?: Nullable<Scene>): Mesh;
  50346. /**
  50347. * Creates a ground mesh from a height map
  50348. * * The parameter `url` sets the URL of the height map image resource.
  50349. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50350. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50351. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50352. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50353. * * 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.
  50354. * * 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).
  50355. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50357. * @param name defines the name of the mesh
  50358. * @param url defines the url to the height map
  50359. * @param options defines the options used to create the mesh
  50360. * @param scene defines the hosting scene
  50361. * @returns the ground mesh
  50362. * @see https://doc.babylonjs.com/babylon101/height_map
  50363. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50364. */
  50365. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50366. width?: number;
  50367. height?: number;
  50368. subdivisions?: number;
  50369. minHeight?: number;
  50370. maxHeight?: number;
  50371. colorFilter?: Color3;
  50372. alphaFilter?: number;
  50373. updatable?: boolean;
  50374. onReady?: (mesh: GroundMesh) => void;
  50375. }, scene?: Nullable<Scene>): GroundMesh;
  50376. }
  50377. }
  50378. declare module BABYLON {
  50379. /**
  50380. * Class containing static functions to help procedurally build meshes
  50381. */
  50382. export class TorusBuilder {
  50383. /**
  50384. * Creates a torus mesh
  50385. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50386. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50387. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50389. * * 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
  50390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50391. * @param name defines the name of the mesh
  50392. * @param options defines the options used to create the mesh
  50393. * @param scene defines the hosting scene
  50394. * @returns the torus mesh
  50395. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50396. */
  50397. static CreateTorus(name: string, options: {
  50398. diameter?: number;
  50399. thickness?: number;
  50400. tessellation?: number;
  50401. updatable?: boolean;
  50402. sideOrientation?: number;
  50403. frontUVs?: Vector4;
  50404. backUVs?: Vector4;
  50405. }, scene: any): Mesh;
  50406. }
  50407. }
  50408. declare module BABYLON {
  50409. /**
  50410. * Class containing static functions to help procedurally build meshes
  50411. */
  50412. export class CylinderBuilder {
  50413. /**
  50414. * Creates a cylinder or a cone mesh
  50415. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50416. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50417. * * 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.
  50418. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50419. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50420. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50421. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50422. * * 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).
  50423. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50424. * * 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).
  50425. * * 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
  50426. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50427. * * 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
  50428. * * 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.
  50429. * * If `enclose` is false, a ring surface is one element.
  50430. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50431. * * 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
  50432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50433. * * 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
  50434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50435. * @param name defines the name of the mesh
  50436. * @param options defines the options used to create the mesh
  50437. * @param scene defines the hosting scene
  50438. * @returns the cylinder mesh
  50439. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50440. */
  50441. static CreateCylinder(name: string, options: {
  50442. height?: number;
  50443. diameterTop?: number;
  50444. diameterBottom?: number;
  50445. diameter?: number;
  50446. tessellation?: number;
  50447. subdivisions?: number;
  50448. arc?: number;
  50449. faceColors?: Color4[];
  50450. faceUV?: Vector4[];
  50451. updatable?: boolean;
  50452. hasRings?: boolean;
  50453. enclose?: boolean;
  50454. cap?: number;
  50455. sideOrientation?: number;
  50456. frontUVs?: Vector4;
  50457. backUVs?: Vector4;
  50458. }, scene: any): Mesh;
  50459. }
  50460. }
  50461. declare module BABYLON {
  50462. /**
  50463. * States of the webXR experience
  50464. */
  50465. export enum WebXRState {
  50466. /**
  50467. * Transitioning to being in XR mode
  50468. */
  50469. ENTERING_XR = 0,
  50470. /**
  50471. * Transitioning to non XR mode
  50472. */
  50473. EXITING_XR = 1,
  50474. /**
  50475. * In XR mode and presenting
  50476. */
  50477. IN_XR = 2,
  50478. /**
  50479. * Not entered XR mode
  50480. */
  50481. NOT_IN_XR = 3
  50482. }
  50483. /**
  50484. * The state of the XR camera's tracking
  50485. */
  50486. export enum WebXRTrackingState {
  50487. /**
  50488. * No transformation received, device is not being tracked
  50489. */
  50490. NOT_TRACKING = 0,
  50491. /**
  50492. * Tracking lost - using emulated position
  50493. */
  50494. TRACKING_LOST = 1,
  50495. /**
  50496. * Transformation tracking works normally
  50497. */
  50498. TRACKING = 2
  50499. }
  50500. /**
  50501. * Abstraction of the XR render target
  50502. */
  50503. export interface WebXRRenderTarget extends IDisposable {
  50504. /**
  50505. * xrpresent context of the canvas which can be used to display/mirror xr content
  50506. */
  50507. canvasContext: WebGLRenderingContext;
  50508. /**
  50509. * xr layer for the canvas
  50510. */
  50511. xrLayer: Nullable<XRWebGLLayer>;
  50512. /**
  50513. * Initializes the xr layer for the session
  50514. * @param xrSession xr session
  50515. * @returns a promise that will resolve once the XR Layer has been created
  50516. */
  50517. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50518. }
  50519. }
  50520. declare module BABYLON {
  50521. /**
  50522. * COnfiguration object for WebXR output canvas
  50523. */
  50524. export class WebXRManagedOutputCanvasOptions {
  50525. /**
  50526. * An optional canvas in case you wish to create it yourself and provide it here.
  50527. * If not provided, a new canvas will be created
  50528. */
  50529. canvasElement?: HTMLCanvasElement;
  50530. /**
  50531. * Options for this XR Layer output
  50532. */
  50533. canvasOptions?: XRWebGLLayerInit;
  50534. /**
  50535. * CSS styling for a newly created canvas (if not provided)
  50536. */
  50537. newCanvasCssStyle?: string;
  50538. /**
  50539. * Get the default values of the configuration object
  50540. * @param engine defines the engine to use (can be null)
  50541. * @returns default values of this configuration object
  50542. */
  50543. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50544. }
  50545. /**
  50546. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50547. */
  50548. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50549. private _options;
  50550. private _canvas;
  50551. private _engine;
  50552. private _originalCanvasSize;
  50553. /**
  50554. * Rendering context of the canvas which can be used to display/mirror xr content
  50555. */
  50556. canvasContext: WebGLRenderingContext;
  50557. /**
  50558. * xr layer for the canvas
  50559. */
  50560. xrLayer: Nullable<XRWebGLLayer>;
  50561. /**
  50562. * Obseervers registered here will be triggered when the xr layer was initialized
  50563. */
  50564. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50565. /**
  50566. * Initializes the canvas to be added/removed upon entering/exiting xr
  50567. * @param _xrSessionManager The XR Session manager
  50568. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50569. */
  50570. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50571. /**
  50572. * Disposes of the object
  50573. */
  50574. dispose(): void;
  50575. /**
  50576. * Initializes the xr layer for the session
  50577. * @param xrSession xr session
  50578. * @returns a promise that will resolve once the XR Layer has been created
  50579. */
  50580. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50581. private _addCanvas;
  50582. private _removeCanvas;
  50583. private _setCanvasSize;
  50584. private _setManagedOutputCanvas;
  50585. }
  50586. }
  50587. declare module BABYLON {
  50588. /**
  50589. * Manages an XRSession to work with Babylon's engine
  50590. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50591. */
  50592. export class WebXRSessionManager implements IDisposable {
  50593. /** The scene which the session should be created for */
  50594. scene: Scene;
  50595. private _referenceSpace;
  50596. private _rttProvider;
  50597. private _sessionEnded;
  50598. private _xrNavigator;
  50599. private baseLayer;
  50600. /**
  50601. * The base reference space from which the session started. good if you want to reset your
  50602. * reference space
  50603. */
  50604. baseReferenceSpace: XRReferenceSpace;
  50605. /**
  50606. * Current XR frame
  50607. */
  50608. currentFrame: Nullable<XRFrame>;
  50609. /** WebXR timestamp updated every frame */
  50610. currentTimestamp: number;
  50611. /**
  50612. * Used just in case of a failure to initialize an immersive session.
  50613. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50614. */
  50615. defaultHeightCompensation: number;
  50616. /**
  50617. * Fires every time a new xrFrame arrives which can be used to update the camera
  50618. */
  50619. onXRFrameObservable: Observable<XRFrame>;
  50620. /**
  50621. * Fires when the reference space changed
  50622. */
  50623. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50624. /**
  50625. * Fires when the xr session is ended either by the device or manually done
  50626. */
  50627. onXRSessionEnded: Observable<any>;
  50628. /**
  50629. * Fires when the xr session is ended either by the device or manually done
  50630. */
  50631. onXRSessionInit: Observable<XRSession>;
  50632. /**
  50633. * Underlying xr session
  50634. */
  50635. session: XRSession;
  50636. /**
  50637. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50638. * or get the offset the player is currently at.
  50639. */
  50640. viewerReferenceSpace: XRReferenceSpace;
  50641. /**
  50642. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50643. * @param scene The scene which the session should be created for
  50644. */
  50645. constructor(
  50646. /** The scene which the session should be created for */
  50647. scene: Scene);
  50648. /**
  50649. * The current reference space used in this session. This reference space can constantly change!
  50650. * It is mainly used to offset the camera's position.
  50651. */
  50652. get referenceSpace(): XRReferenceSpace;
  50653. /**
  50654. * Set a new reference space and triggers the observable
  50655. */
  50656. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50657. /**
  50658. * Disposes of the session manager
  50659. */
  50660. dispose(): void;
  50661. /**
  50662. * Stops the xrSession and restores the render loop
  50663. * @returns Promise which resolves after it exits XR
  50664. */
  50665. exitXRAsync(): Promise<void>;
  50666. /**
  50667. * Gets the correct render target texture to be rendered this frame for this eye
  50668. * @param eye the eye for which to get the render target
  50669. * @returns the render target for the specified eye
  50670. */
  50671. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50672. /**
  50673. * Creates a WebXRRenderTarget object for the XR session
  50674. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50675. * @param options optional options to provide when creating a new render target
  50676. * @returns a WebXR render target to which the session can render
  50677. */
  50678. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50679. /**
  50680. * Initializes the manager
  50681. * After initialization enterXR can be called to start an XR session
  50682. * @returns Promise which resolves after it is initialized
  50683. */
  50684. initializeAsync(): Promise<void>;
  50685. /**
  50686. * Initializes an xr session
  50687. * @param xrSessionMode mode to initialize
  50688. * @param xrSessionInit defines optional and required values to pass to the session builder
  50689. * @returns a promise which will resolve once the session has been initialized
  50690. */
  50691. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50692. /**
  50693. * Checks if a session would be supported for the creation options specified
  50694. * @param sessionMode session mode to check if supported eg. immersive-vr
  50695. * @returns A Promise that resolves to true if supported and false if not
  50696. */
  50697. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50698. /**
  50699. * Resets the reference space to the one started the session
  50700. */
  50701. resetReferenceSpace(): void;
  50702. /**
  50703. * Starts rendering to the xr layer
  50704. */
  50705. runXRRenderLoop(): void;
  50706. /**
  50707. * Sets the reference space on the xr session
  50708. * @param referenceSpaceType space to set
  50709. * @returns a promise that will resolve once the reference space has been set
  50710. */
  50711. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50712. /**
  50713. * Updates the render state of the session
  50714. * @param state state to set
  50715. * @returns a promise that resolves once the render state has been updated
  50716. */
  50717. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50718. /**
  50719. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50720. * @param sessionMode defines the session to test
  50721. * @returns a promise with boolean as final value
  50722. */
  50723. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50724. private _createRenderTargetTexture;
  50725. }
  50726. }
  50727. declare module BABYLON {
  50728. /**
  50729. * WebXR Camera which holds the views for the xrSession
  50730. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50731. */
  50732. export class WebXRCamera extends FreeCamera {
  50733. private _xrSessionManager;
  50734. private _firstFrame;
  50735. private _referenceQuaternion;
  50736. private _referencedPosition;
  50737. private _xrInvPositionCache;
  50738. private _xrInvQuaternionCache;
  50739. private _trackingState;
  50740. /**
  50741. * Observable raised before camera teleportation
  50742. */
  50743. onBeforeCameraTeleport: Observable<Vector3>;
  50744. /**
  50745. * Observable raised after camera teleportation
  50746. */
  50747. onAfterCameraTeleport: Observable<Vector3>;
  50748. /**
  50749. * Notifies when the camera's tracking state has changed.
  50750. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50751. */
  50752. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50753. /**
  50754. * Should position compensation execute on first frame.
  50755. * This is used when copying the position from a native (non XR) camera
  50756. */
  50757. compensateOnFirstFrame: boolean;
  50758. /**
  50759. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50760. * @param name the name of the camera
  50761. * @param scene the scene to add the camera to
  50762. * @param _xrSessionManager a constructed xr session manager
  50763. */
  50764. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50765. /**
  50766. * Get the current XR tracking state of the camera
  50767. */
  50768. get trackingState(): WebXRTrackingState;
  50769. private _setTrackingState;
  50770. /**
  50771. * Return the user's height, unrelated to the current ground.
  50772. * This will be the y position of this camera, when ground level is 0.
  50773. */
  50774. get realWorldHeight(): number;
  50775. /** @hidden */
  50776. _updateForDualEyeDebugging(): void;
  50777. /**
  50778. * Sets this camera's transformation based on a non-vr camera
  50779. * @param otherCamera the non-vr camera to copy the transformation from
  50780. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50781. */
  50782. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50783. /**
  50784. * Gets the current instance class name ("WebXRCamera").
  50785. * @returns the class name
  50786. */
  50787. getClassName(): string;
  50788. private _rotate180;
  50789. private _updateFromXRSession;
  50790. private _updateNumberOfRigCameras;
  50791. private _updateReferenceSpace;
  50792. private _updateReferenceSpaceOffset;
  50793. }
  50794. }
  50795. declare module BABYLON {
  50796. /**
  50797. * Defining the interface required for a (webxr) feature
  50798. */
  50799. export interface IWebXRFeature extends IDisposable {
  50800. /**
  50801. * Is this feature attached
  50802. */
  50803. attached: boolean;
  50804. /**
  50805. * Should auto-attach be disabled?
  50806. */
  50807. disableAutoAttach: boolean;
  50808. /**
  50809. * Attach the feature to the session
  50810. * Will usually be called by the features manager
  50811. *
  50812. * @param force should attachment be forced (even when already attached)
  50813. * @returns true if successful.
  50814. */
  50815. attach(force?: boolean): boolean;
  50816. /**
  50817. * Detach the feature from the session
  50818. * Will usually be called by the features manager
  50819. *
  50820. * @returns true if successful.
  50821. */
  50822. detach(): boolean;
  50823. /**
  50824. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50825. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50826. *
  50827. * @returns whether or not the feature is compatible in this environment
  50828. */
  50829. isCompatible(): boolean;
  50830. /**
  50831. * Was this feature disposed;
  50832. */
  50833. isDisposed: boolean;
  50834. /**
  50835. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50836. */
  50837. xrNativeFeatureName?: string;
  50838. /**
  50839. * A list of (Babylon WebXR) features this feature depends on
  50840. */
  50841. dependsOn?: string[];
  50842. }
  50843. /**
  50844. * A list of the currently available features without referencing them
  50845. */
  50846. export class WebXRFeatureName {
  50847. /**
  50848. * The name of the anchor system feature
  50849. */
  50850. static readonly ANCHOR_SYSTEM: string;
  50851. /**
  50852. * The name of the background remover feature
  50853. */
  50854. static readonly BACKGROUND_REMOVER: string;
  50855. /**
  50856. * The name of the hit test feature
  50857. */
  50858. static readonly HIT_TEST: string;
  50859. /**
  50860. * physics impostors for xr controllers feature
  50861. */
  50862. static readonly PHYSICS_CONTROLLERS: string;
  50863. /**
  50864. * The name of the plane detection feature
  50865. */
  50866. static readonly PLANE_DETECTION: string;
  50867. /**
  50868. * The name of the pointer selection feature
  50869. */
  50870. static readonly POINTER_SELECTION: string;
  50871. /**
  50872. * The name of the teleportation feature
  50873. */
  50874. static readonly TELEPORTATION: string;
  50875. /**
  50876. * The name of the feature points feature.
  50877. */
  50878. static readonly FEATURE_POINTS: string;
  50879. /**
  50880. * The name of the hand tracking feature.
  50881. */
  50882. static readonly HAND_TRACKING: string;
  50883. }
  50884. /**
  50885. * Defining the constructor of a feature. Used to register the modules.
  50886. */
  50887. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50888. /**
  50889. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50890. * It is mainly used in AR sessions.
  50891. *
  50892. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50893. */
  50894. export class WebXRFeaturesManager implements IDisposable {
  50895. private _xrSessionManager;
  50896. private static readonly _AvailableFeatures;
  50897. private _features;
  50898. /**
  50899. * constructs a new features manages.
  50900. *
  50901. * @param _xrSessionManager an instance of WebXRSessionManager
  50902. */
  50903. constructor(_xrSessionManager: WebXRSessionManager);
  50904. /**
  50905. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50906. * Mainly used internally.
  50907. *
  50908. * @param featureName the name of the feature to register
  50909. * @param constructorFunction the function used to construct the module
  50910. * @param version the (babylon) version of the module
  50911. * @param stable is that a stable version of this module
  50912. */
  50913. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50914. /**
  50915. * Returns a constructor of a specific feature.
  50916. *
  50917. * @param featureName the name of the feature to construct
  50918. * @param version the version of the feature to load
  50919. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50920. * @param options optional options provided to the module.
  50921. * @returns a function that, when called, will return a new instance of this feature
  50922. */
  50923. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50924. /**
  50925. * Can be used to return the list of features currently registered
  50926. *
  50927. * @returns an Array of available features
  50928. */
  50929. static GetAvailableFeatures(): string[];
  50930. /**
  50931. * Gets the versions available for a specific feature
  50932. * @param featureName the name of the feature
  50933. * @returns an array with the available versions
  50934. */
  50935. static GetAvailableVersions(featureName: string): string[];
  50936. /**
  50937. * Return the latest unstable version of this feature
  50938. * @param featureName the name of the feature to search
  50939. * @returns the version number. if not found will return -1
  50940. */
  50941. static GetLatestVersionOfFeature(featureName: string): number;
  50942. /**
  50943. * Return the latest stable version of this feature
  50944. * @param featureName the name of the feature to search
  50945. * @returns the version number. if not found will return -1
  50946. */
  50947. static GetStableVersionOfFeature(featureName: string): number;
  50948. /**
  50949. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50950. * Can be used during a session to start a feature
  50951. * @param featureName the name of feature to attach
  50952. */
  50953. attachFeature(featureName: string): void;
  50954. /**
  50955. * Can be used inside a session or when the session ends to detach a specific feature
  50956. * @param featureName the name of the feature to detach
  50957. */
  50958. detachFeature(featureName: string): void;
  50959. /**
  50960. * Used to disable an already-enabled feature
  50961. * The feature will be disposed and will be recreated once enabled.
  50962. * @param featureName the feature to disable
  50963. * @returns true if disable was successful
  50964. */
  50965. disableFeature(featureName: string | {
  50966. Name: string;
  50967. }): boolean;
  50968. /**
  50969. * dispose this features manager
  50970. */
  50971. dispose(): void;
  50972. /**
  50973. * 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.
  50974. * 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.
  50975. *
  50976. * @param featureName the name of the feature to load or the class of the feature
  50977. * @param version optional version to load. if not provided the latest version will be enabled
  50978. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50979. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50980. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50981. * @returns a new constructed feature or throws an error if feature not found.
  50982. */
  50983. enableFeature(featureName: string | {
  50984. Name: string;
  50985. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50986. /**
  50987. * get the implementation of an enabled feature.
  50988. * @param featureName the name of the feature to load
  50989. * @returns the feature class, if found
  50990. */
  50991. getEnabledFeature(featureName: string): IWebXRFeature;
  50992. /**
  50993. * Get the list of enabled features
  50994. * @returns an array of enabled features
  50995. */
  50996. getEnabledFeatures(): string[];
  50997. /**
  50998. * This function will exten the session creation configuration object with enabled features.
  50999. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  51000. * according to the defined "required" variable, provided during enableFeature call
  51001. * @param xrSessionInit the xr Session init object to extend
  51002. *
  51003. * @returns an extended XRSessionInit object
  51004. */
  51005. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51006. }
  51007. }
  51008. declare module BABYLON {
  51009. /**
  51010. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51011. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51012. */
  51013. export class WebXRExperienceHelper implements IDisposable {
  51014. private scene;
  51015. private _nonVRCamera;
  51016. private _originalSceneAutoClear;
  51017. private _supported;
  51018. /**
  51019. * Camera used to render xr content
  51020. */
  51021. camera: WebXRCamera;
  51022. /** A features manager for this xr session */
  51023. featuresManager: WebXRFeaturesManager;
  51024. /**
  51025. * Observers registered here will be triggered after the camera's initial transformation is set
  51026. * This can be used to set a different ground level or an extra rotation.
  51027. *
  51028. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51029. * to the position set after this observable is done executing.
  51030. */
  51031. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51032. /**
  51033. * Fires when the state of the experience helper has changed
  51034. */
  51035. onStateChangedObservable: Observable<WebXRState>;
  51036. /** Session manager used to keep track of xr session */
  51037. sessionManager: WebXRSessionManager;
  51038. /**
  51039. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51040. */
  51041. state: WebXRState;
  51042. /**
  51043. * Creates a WebXRExperienceHelper
  51044. * @param scene The scene the helper should be created in
  51045. */
  51046. private constructor();
  51047. /**
  51048. * Creates the experience helper
  51049. * @param scene the scene to attach the experience helper to
  51050. * @returns a promise for the experience helper
  51051. */
  51052. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51053. /**
  51054. * Disposes of the experience helper
  51055. */
  51056. dispose(): void;
  51057. /**
  51058. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51059. * @param sessionMode options for the XR session
  51060. * @param referenceSpaceType frame of reference of the XR session
  51061. * @param renderTarget the output canvas that will be used to enter XR mode
  51062. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51063. * @returns promise that resolves after xr mode has entered
  51064. */
  51065. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51066. /**
  51067. * Exits XR mode and returns the scene to its original state
  51068. * @returns promise that resolves after xr mode has exited
  51069. */
  51070. exitXRAsync(): Promise<void>;
  51071. private _nonXRToXRCamera;
  51072. private _setState;
  51073. }
  51074. }
  51075. declare module BABYLON {
  51076. /**
  51077. * X-Y values for axes in WebXR
  51078. */
  51079. export interface IWebXRMotionControllerAxesValue {
  51080. /**
  51081. * The value of the x axis
  51082. */
  51083. x: number;
  51084. /**
  51085. * The value of the y-axis
  51086. */
  51087. y: number;
  51088. }
  51089. /**
  51090. * changed / previous values for the values of this component
  51091. */
  51092. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51093. /**
  51094. * current (this frame) value
  51095. */
  51096. current: T;
  51097. /**
  51098. * previous (last change) value
  51099. */
  51100. previous: T;
  51101. }
  51102. /**
  51103. * Represents changes in the component between current frame and last values recorded
  51104. */
  51105. export interface IWebXRMotionControllerComponentChanges {
  51106. /**
  51107. * will be populated with previous and current values if axes changed
  51108. */
  51109. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51110. /**
  51111. * will be populated with previous and current values if pressed changed
  51112. */
  51113. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51114. /**
  51115. * will be populated with previous and current values if touched changed
  51116. */
  51117. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51118. /**
  51119. * will be populated with previous and current values if value changed
  51120. */
  51121. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51122. }
  51123. /**
  51124. * This class represents a single component (for example button or thumbstick) of a motion controller
  51125. */
  51126. export class WebXRControllerComponent implements IDisposable {
  51127. /**
  51128. * the id of this component
  51129. */
  51130. id: string;
  51131. /**
  51132. * the type of the component
  51133. */
  51134. type: MotionControllerComponentType;
  51135. private _buttonIndex;
  51136. private _axesIndices;
  51137. private _axes;
  51138. private _changes;
  51139. private _currentValue;
  51140. private _hasChanges;
  51141. private _pressed;
  51142. private _touched;
  51143. /**
  51144. * button component type
  51145. */
  51146. static BUTTON_TYPE: MotionControllerComponentType;
  51147. /**
  51148. * squeeze component type
  51149. */
  51150. static SQUEEZE_TYPE: MotionControllerComponentType;
  51151. /**
  51152. * Thumbstick component type
  51153. */
  51154. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51155. /**
  51156. * Touchpad component type
  51157. */
  51158. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51159. /**
  51160. * trigger component type
  51161. */
  51162. static TRIGGER_TYPE: MotionControllerComponentType;
  51163. /**
  51164. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51165. * the axes data changes
  51166. */
  51167. onAxisValueChangedObservable: Observable<{
  51168. x: number;
  51169. y: number;
  51170. }>;
  51171. /**
  51172. * Observers registered here will be triggered when the state of a button changes
  51173. * State change is either pressed / touched / value
  51174. */
  51175. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51176. /**
  51177. * Creates a new component for a motion controller.
  51178. * It is created by the motion controller itself
  51179. *
  51180. * @param id the id of this component
  51181. * @param type the type of the component
  51182. * @param _buttonIndex index in the buttons array of the gamepad
  51183. * @param _axesIndices indices of the values in the axes array of the gamepad
  51184. */
  51185. constructor(
  51186. /**
  51187. * the id of this component
  51188. */
  51189. id: string,
  51190. /**
  51191. * the type of the component
  51192. */
  51193. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51194. /**
  51195. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51196. */
  51197. get axes(): IWebXRMotionControllerAxesValue;
  51198. /**
  51199. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51200. */
  51201. get changes(): IWebXRMotionControllerComponentChanges;
  51202. /**
  51203. * Return whether or not the component changed the last frame
  51204. */
  51205. get hasChanges(): boolean;
  51206. /**
  51207. * is the button currently pressed
  51208. */
  51209. get pressed(): boolean;
  51210. /**
  51211. * is the button currently touched
  51212. */
  51213. get touched(): boolean;
  51214. /**
  51215. * Get the current value of this component
  51216. */
  51217. get value(): number;
  51218. /**
  51219. * Dispose this component
  51220. */
  51221. dispose(): void;
  51222. /**
  51223. * Are there axes correlating to this component
  51224. * @return true is axes data is available
  51225. */
  51226. isAxes(): boolean;
  51227. /**
  51228. * Is this component a button (hence - pressable)
  51229. * @returns true if can be pressed
  51230. */
  51231. isButton(): boolean;
  51232. /**
  51233. * update this component using the gamepad object it is in. Called on every frame
  51234. * @param nativeController the native gamepad controller object
  51235. */
  51236. update(nativeController: IMinimalMotionControllerObject): void;
  51237. }
  51238. }
  51239. declare module BABYLON {
  51240. /**
  51241. * Type used for the success callback of ImportMesh
  51242. */
  51243. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51244. /**
  51245. * Interface used for the result of ImportMeshAsync
  51246. */
  51247. export interface ISceneLoaderAsyncResult {
  51248. /**
  51249. * The array of loaded meshes
  51250. */
  51251. readonly meshes: AbstractMesh[];
  51252. /**
  51253. * The array of loaded particle systems
  51254. */
  51255. readonly particleSystems: IParticleSystem[];
  51256. /**
  51257. * The array of loaded skeletons
  51258. */
  51259. readonly skeletons: Skeleton[];
  51260. /**
  51261. * The array of loaded animation groups
  51262. */
  51263. readonly animationGroups: AnimationGroup[];
  51264. /**
  51265. * The array of loaded transform nodes
  51266. */
  51267. readonly transformNodes: TransformNode[];
  51268. /**
  51269. * The array of loaded geometries
  51270. */
  51271. readonly geometries: Geometry[];
  51272. /**
  51273. * The array of loaded lights
  51274. */
  51275. readonly lights: Light[];
  51276. }
  51277. /**
  51278. * Interface used to represent data loading progression
  51279. */
  51280. export interface ISceneLoaderProgressEvent {
  51281. /**
  51282. * Defines if data length to load can be evaluated
  51283. */
  51284. readonly lengthComputable: boolean;
  51285. /**
  51286. * Defines the loaded data length
  51287. */
  51288. readonly loaded: number;
  51289. /**
  51290. * Defines the data length to load
  51291. */
  51292. readonly total: number;
  51293. }
  51294. /**
  51295. * Interface used by SceneLoader plugins to define supported file extensions
  51296. */
  51297. export interface ISceneLoaderPluginExtensions {
  51298. /**
  51299. * Defines the list of supported extensions
  51300. */
  51301. [extension: string]: {
  51302. isBinary: boolean;
  51303. };
  51304. }
  51305. /**
  51306. * Interface used by SceneLoader plugin factory
  51307. */
  51308. export interface ISceneLoaderPluginFactory {
  51309. /**
  51310. * Defines the name of the factory
  51311. */
  51312. name: string;
  51313. /**
  51314. * Function called to create a new plugin
  51315. * @return the new plugin
  51316. */
  51317. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51318. /**
  51319. * The callback that returns true if the data can be directly loaded.
  51320. * @param data string containing the file data
  51321. * @returns if the data can be loaded directly
  51322. */
  51323. canDirectLoad?(data: string): boolean;
  51324. }
  51325. /**
  51326. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51327. */
  51328. export interface ISceneLoaderPluginBase {
  51329. /**
  51330. * The friendly name of this plugin.
  51331. */
  51332. name: string;
  51333. /**
  51334. * The file extensions supported by this plugin.
  51335. */
  51336. extensions: string | ISceneLoaderPluginExtensions;
  51337. /**
  51338. * The callback called when loading from a url.
  51339. * @param scene scene loading this url
  51340. * @param url url to load
  51341. * @param onSuccess callback called when the file successfully loads
  51342. * @param onProgress callback called while file is loading (if the server supports this mode)
  51343. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51344. * @param onError callback called when the file fails to load
  51345. * @returns a file request object
  51346. */
  51347. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51348. /**
  51349. * The callback called when loading from a file object.
  51350. * @param scene scene loading this file
  51351. * @param file defines the file to load
  51352. * @param onSuccess defines the callback to call when data is loaded
  51353. * @param onProgress defines the callback to call during loading process
  51354. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51355. * @param onError defines the callback to call when an error occurs
  51356. * @returns a file request object
  51357. */
  51358. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51359. /**
  51360. * The callback that returns true if the data can be directly loaded.
  51361. * @param data string containing the file data
  51362. * @returns if the data can be loaded directly
  51363. */
  51364. canDirectLoad?(data: string): boolean;
  51365. /**
  51366. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51367. * @param scene scene loading this data
  51368. * @param data string containing the data
  51369. * @returns data to pass to the plugin
  51370. */
  51371. directLoad?(scene: Scene, data: string): any;
  51372. /**
  51373. * The callback that allows custom handling of the root url based on the response url.
  51374. * @param rootUrl the original root url
  51375. * @param responseURL the response url if available
  51376. * @returns the new root url
  51377. */
  51378. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51379. }
  51380. /**
  51381. * Interface used to define a SceneLoader plugin
  51382. */
  51383. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51384. /**
  51385. * Import meshes into a scene.
  51386. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51387. * @param scene The scene to import into
  51388. * @param data The data to import
  51389. * @param rootUrl The root url for scene and resources
  51390. * @param meshes The meshes array to import into
  51391. * @param particleSystems The particle systems array to import into
  51392. * @param skeletons The skeletons array to import into
  51393. * @param onError The callback when import fails
  51394. * @returns True if successful or false otherwise
  51395. */
  51396. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51397. /**
  51398. * Load into a scene.
  51399. * @param scene The scene to load into
  51400. * @param data The data to import
  51401. * @param rootUrl The root url for scene and resources
  51402. * @param onError The callback when import fails
  51403. * @returns True if successful or false otherwise
  51404. */
  51405. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51406. /**
  51407. * Load into an asset container.
  51408. * @param scene The scene to load into
  51409. * @param data The data to import
  51410. * @param rootUrl The root url for scene and resources
  51411. * @param onError The callback when import fails
  51412. * @returns The loaded asset container
  51413. */
  51414. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51415. }
  51416. /**
  51417. * Interface used to define an async SceneLoader plugin
  51418. */
  51419. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51420. /**
  51421. * Import meshes into a scene.
  51422. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51423. * @param scene The scene to import into
  51424. * @param data The data to import
  51425. * @param rootUrl The root url for scene and resources
  51426. * @param onProgress The callback when the load progresses
  51427. * @param fileName Defines the name of the file to load
  51428. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51429. */
  51430. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51431. /**
  51432. * Load into a scene.
  51433. * @param scene The scene to load into
  51434. * @param data The data to import
  51435. * @param rootUrl The root url for scene and resources
  51436. * @param onProgress The callback when the load progresses
  51437. * @param fileName Defines the name of the file to load
  51438. * @returns Nothing
  51439. */
  51440. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51441. /**
  51442. * Load into an asset container.
  51443. * @param scene The scene to load into
  51444. * @param data The data to import
  51445. * @param rootUrl The root url for scene and resources
  51446. * @param onProgress The callback when the load progresses
  51447. * @param fileName Defines the name of the file to load
  51448. * @returns The loaded asset container
  51449. */
  51450. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51451. }
  51452. /**
  51453. * Mode that determines how to handle old animation groups before loading new ones.
  51454. */
  51455. export enum SceneLoaderAnimationGroupLoadingMode {
  51456. /**
  51457. * Reset all old animations to initial state then dispose them.
  51458. */
  51459. Clean = 0,
  51460. /**
  51461. * Stop all old animations.
  51462. */
  51463. Stop = 1,
  51464. /**
  51465. * Restart old animations from first frame.
  51466. */
  51467. Sync = 2,
  51468. /**
  51469. * Old animations remains untouched.
  51470. */
  51471. NoSync = 3
  51472. }
  51473. /**
  51474. * Defines a plugin registered by the SceneLoader
  51475. */
  51476. interface IRegisteredPlugin {
  51477. /**
  51478. * Defines the plugin to use
  51479. */
  51480. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51481. /**
  51482. * Defines if the plugin supports binary data
  51483. */
  51484. isBinary: boolean;
  51485. }
  51486. /**
  51487. * Class used to load scene from various file formats using registered plugins
  51488. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51489. */
  51490. export class SceneLoader {
  51491. /**
  51492. * No logging while loading
  51493. */
  51494. static readonly NO_LOGGING: number;
  51495. /**
  51496. * Minimal logging while loading
  51497. */
  51498. static readonly MINIMAL_LOGGING: number;
  51499. /**
  51500. * Summary logging while loading
  51501. */
  51502. static readonly SUMMARY_LOGGING: number;
  51503. /**
  51504. * Detailled logging while loading
  51505. */
  51506. static readonly DETAILED_LOGGING: number;
  51507. /**
  51508. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51509. */
  51510. static get ForceFullSceneLoadingForIncremental(): boolean;
  51511. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51512. /**
  51513. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51514. */
  51515. static get ShowLoadingScreen(): boolean;
  51516. static set ShowLoadingScreen(value: boolean);
  51517. /**
  51518. * Defines the current logging level (while loading the scene)
  51519. * @ignorenaming
  51520. */
  51521. static get loggingLevel(): number;
  51522. static set loggingLevel(value: number);
  51523. /**
  51524. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51525. */
  51526. static get CleanBoneMatrixWeights(): boolean;
  51527. static set CleanBoneMatrixWeights(value: boolean);
  51528. /**
  51529. * Event raised when a plugin is used to load a scene
  51530. */
  51531. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51532. private static _registeredPlugins;
  51533. private static _showingLoadingScreen;
  51534. /**
  51535. * Gets the default plugin (used to load Babylon files)
  51536. * @returns the .babylon plugin
  51537. */
  51538. static GetDefaultPlugin(): IRegisteredPlugin;
  51539. private static _GetPluginForExtension;
  51540. private static _GetPluginForDirectLoad;
  51541. private static _GetPluginForFilename;
  51542. private static _GetDirectLoad;
  51543. private static _LoadData;
  51544. private static _GetFileInfo;
  51545. /**
  51546. * Gets a plugin that can load the given extension
  51547. * @param extension defines the extension to load
  51548. * @returns a plugin or null if none works
  51549. */
  51550. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51551. /**
  51552. * Gets a boolean indicating that the given extension can be loaded
  51553. * @param extension defines the extension to load
  51554. * @returns true if the extension is supported
  51555. */
  51556. static IsPluginForExtensionAvailable(extension: string): boolean;
  51557. /**
  51558. * Adds a new plugin to the list of registered plugins
  51559. * @param plugin defines the plugin to add
  51560. */
  51561. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51562. /**
  51563. * Import meshes into a scene
  51564. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51565. * @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)
  51566. * @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)
  51567. * @param scene the instance of BABYLON.Scene to append to
  51568. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51569. * @param onProgress a callback with a progress event for each file being loaded
  51570. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51571. * @param pluginExtension the extension used to determine the plugin
  51572. * @returns The loaded plugin
  51573. */
  51574. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51575. /**
  51576. * Import meshes into a scene
  51577. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51578. * @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)
  51579. * @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)
  51580. * @param scene the instance of BABYLON.Scene to append to
  51581. * @param onProgress a callback with a progress event for each file being loaded
  51582. * @param pluginExtension the extension used to determine the plugin
  51583. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51584. */
  51585. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51586. /**
  51587. * Load a scene
  51588. * @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)
  51589. * @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)
  51590. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51591. * @param onSuccess a callback with the scene when import succeeds
  51592. * @param onProgress a callback with a progress event for each file being loaded
  51593. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51594. * @param pluginExtension the extension used to determine the plugin
  51595. * @returns The loaded plugin
  51596. */
  51597. 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>;
  51598. /**
  51599. * Load a scene
  51600. * @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)
  51601. * @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)
  51602. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51603. * @param onProgress a callback with a progress event for each file being loaded
  51604. * @param pluginExtension the extension used to determine the plugin
  51605. * @returns The loaded scene
  51606. */
  51607. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51608. /**
  51609. * Append a scene
  51610. * @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)
  51611. * @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)
  51612. * @param scene is the instance of BABYLON.Scene to append to
  51613. * @param onSuccess a callback with the scene when import succeeds
  51614. * @param onProgress a callback with a progress event for each file being loaded
  51615. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51616. * @param pluginExtension the extension used to determine the plugin
  51617. * @returns The loaded plugin
  51618. */
  51619. 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>;
  51620. /**
  51621. * Append a scene
  51622. * @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)
  51623. * @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)
  51624. * @param scene is the instance of BABYLON.Scene to append to
  51625. * @param onProgress a callback with a progress event for each file being loaded
  51626. * @param pluginExtension the extension used to determine the plugin
  51627. * @returns The given scene
  51628. */
  51629. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51630. /**
  51631. * Load a scene into an asset container
  51632. * @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)
  51633. * @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)
  51634. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51635. * @param onSuccess a callback with the scene when import succeeds
  51636. * @param onProgress a callback with a progress event for each file being loaded
  51637. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51638. * @param pluginExtension the extension used to determine the plugin
  51639. * @returns The loaded plugin
  51640. */
  51641. 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>;
  51642. /**
  51643. * Load a scene into an asset container
  51644. * @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)
  51645. * @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)
  51646. * @param scene is the instance of Scene to append to
  51647. * @param onProgress a callback with a progress event for each file being loaded
  51648. * @param pluginExtension the extension used to determine the plugin
  51649. * @returns The loaded asset container
  51650. */
  51651. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51652. /**
  51653. * Import animations from a file into a scene
  51654. * @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)
  51655. * @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)
  51656. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51657. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51658. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51659. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51660. * @param onSuccess a callback with the scene when import succeeds
  51661. * @param onProgress a callback with a progress event for each file being loaded
  51662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51663. * @param pluginExtension the extension used to determine the plugin
  51664. */
  51665. 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;
  51666. /**
  51667. * Import animations from a file into a scene
  51668. * @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)
  51669. * @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)
  51670. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51671. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51672. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51673. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51674. * @param onSuccess a callback with the scene when import succeeds
  51675. * @param onProgress a callback with a progress event for each file being loaded
  51676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51677. * @param pluginExtension the extension used to determine the plugin
  51678. * @returns the updated scene with imported animations
  51679. */
  51680. 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>;
  51681. }
  51682. }
  51683. declare module BABYLON {
  51684. /**
  51685. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51686. */
  51687. export type MotionControllerHandedness = "none" | "left" | "right";
  51688. /**
  51689. * The type of components available in motion controllers.
  51690. * This is not the name of the component.
  51691. */
  51692. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51693. /**
  51694. * The state of a controller component
  51695. */
  51696. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51697. /**
  51698. * The schema of motion controller layout.
  51699. * No object will be initialized using this interface
  51700. * This is used just to define the profile.
  51701. */
  51702. export interface IMotionControllerLayout {
  51703. /**
  51704. * Path to load the assets. Usually relative to the base path
  51705. */
  51706. assetPath: string;
  51707. /**
  51708. * Available components (unsorted)
  51709. */
  51710. components: {
  51711. /**
  51712. * A map of component Ids
  51713. */
  51714. [componentId: string]: {
  51715. /**
  51716. * The type of input the component outputs
  51717. */
  51718. type: MotionControllerComponentType;
  51719. /**
  51720. * The indices of this component in the gamepad object
  51721. */
  51722. gamepadIndices: {
  51723. /**
  51724. * Index of button
  51725. */
  51726. button?: number;
  51727. /**
  51728. * If available, index of x-axis
  51729. */
  51730. xAxis?: number;
  51731. /**
  51732. * If available, index of y-axis
  51733. */
  51734. yAxis?: number;
  51735. };
  51736. /**
  51737. * The mesh's root node name
  51738. */
  51739. rootNodeName: string;
  51740. /**
  51741. * Animation definitions for this model
  51742. */
  51743. visualResponses: {
  51744. [stateKey: string]: {
  51745. /**
  51746. * What property will be animated
  51747. */
  51748. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51749. /**
  51750. * What states influence this visual response
  51751. */
  51752. states: MotionControllerComponentStateType[];
  51753. /**
  51754. * Type of animation - movement or visibility
  51755. */
  51756. valueNodeProperty: "transform" | "visibility";
  51757. /**
  51758. * Base node name to move. Its position will be calculated according to the min and max nodes
  51759. */
  51760. valueNodeName?: string;
  51761. /**
  51762. * Minimum movement node
  51763. */
  51764. minNodeName?: string;
  51765. /**
  51766. * Max movement node
  51767. */
  51768. maxNodeName?: string;
  51769. };
  51770. };
  51771. /**
  51772. * If touch enabled, what is the name of node to display user feedback
  51773. */
  51774. touchPointNodeName?: string;
  51775. };
  51776. };
  51777. /**
  51778. * Is it xr standard mapping or not
  51779. */
  51780. gamepadMapping: "" | "xr-standard";
  51781. /**
  51782. * Base root node of this entire model
  51783. */
  51784. rootNodeName: string;
  51785. /**
  51786. * Defines the main button component id
  51787. */
  51788. selectComponentId: string;
  51789. }
  51790. /**
  51791. * A definition for the layout map in the input profile
  51792. */
  51793. export interface IMotionControllerLayoutMap {
  51794. /**
  51795. * Layouts with handedness type as a key
  51796. */
  51797. [handedness: string]: IMotionControllerLayout;
  51798. }
  51799. /**
  51800. * The XR Input profile schema
  51801. * Profiles can be found here:
  51802. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51803. */
  51804. export interface IMotionControllerProfile {
  51805. /**
  51806. * fallback profiles for this profileId
  51807. */
  51808. fallbackProfileIds: string[];
  51809. /**
  51810. * The layout map, with handedness as key
  51811. */
  51812. layouts: IMotionControllerLayoutMap;
  51813. /**
  51814. * The id of this profile
  51815. * correlates to the profile(s) in the xrInput.profiles array
  51816. */
  51817. profileId: string;
  51818. }
  51819. /**
  51820. * A helper-interface for the 3 meshes needed for controller button animation
  51821. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51822. */
  51823. export interface IMotionControllerButtonMeshMap {
  51824. /**
  51825. * the mesh that defines the pressed value mesh position.
  51826. * This is used to find the max-position of this button
  51827. */
  51828. pressedMesh: AbstractMesh;
  51829. /**
  51830. * the mesh that defines the unpressed value mesh position.
  51831. * This is used to find the min (or initial) position of this button
  51832. */
  51833. unpressedMesh: AbstractMesh;
  51834. /**
  51835. * The mesh that will be changed when value changes
  51836. */
  51837. valueMesh: AbstractMesh;
  51838. }
  51839. /**
  51840. * A helper-interface for the 3 meshes needed for controller axis animation.
  51841. * This will be expanded when touchpad animations are fully supported
  51842. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51843. */
  51844. export interface IMotionControllerMeshMap {
  51845. /**
  51846. * the mesh that defines the maximum value mesh position.
  51847. */
  51848. maxMesh?: AbstractMesh;
  51849. /**
  51850. * the mesh that defines the minimum value mesh position.
  51851. */
  51852. minMesh?: AbstractMesh;
  51853. /**
  51854. * The mesh that will be changed when axis value changes
  51855. */
  51856. valueMesh?: AbstractMesh;
  51857. }
  51858. /**
  51859. * The elements needed for change-detection of the gamepad objects in motion controllers
  51860. */
  51861. export interface IMinimalMotionControllerObject {
  51862. /**
  51863. * Available axes of this controller
  51864. */
  51865. axes: number[];
  51866. /**
  51867. * An array of available buttons
  51868. */
  51869. buttons: Array<{
  51870. /**
  51871. * Value of the button/trigger
  51872. */
  51873. value: number;
  51874. /**
  51875. * If the button/trigger is currently touched
  51876. */
  51877. touched: boolean;
  51878. /**
  51879. * If the button/trigger is currently pressed
  51880. */
  51881. pressed: boolean;
  51882. }>;
  51883. /**
  51884. * EXPERIMENTAL haptic support.
  51885. */
  51886. hapticActuators?: Array<{
  51887. pulse: (value: number, duration: number) => Promise<boolean>;
  51888. }>;
  51889. }
  51890. /**
  51891. * An Abstract Motion controller
  51892. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51893. * Each component has an observable to check for changes in value and state
  51894. */
  51895. export abstract class WebXRAbstractMotionController implements IDisposable {
  51896. protected scene: Scene;
  51897. protected layout: IMotionControllerLayout;
  51898. /**
  51899. * The gamepad object correlating to this controller
  51900. */
  51901. gamepadObject: IMinimalMotionControllerObject;
  51902. /**
  51903. * handedness (left/right/none) of this controller
  51904. */
  51905. handedness: MotionControllerHandedness;
  51906. private _initComponent;
  51907. private _modelReady;
  51908. /**
  51909. * A map of components (WebXRControllerComponent) in this motion controller
  51910. * Components have a ComponentType and can also have both button and axis definitions
  51911. */
  51912. readonly components: {
  51913. [id: string]: WebXRControllerComponent;
  51914. };
  51915. /**
  51916. * Disable the model's animation. Can be set at any time.
  51917. */
  51918. disableAnimation: boolean;
  51919. /**
  51920. * Observers registered here will be triggered when the model of this controller is done loading
  51921. */
  51922. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51923. /**
  51924. * The profile id of this motion controller
  51925. */
  51926. abstract profileId: string;
  51927. /**
  51928. * The root mesh of the model. It is null if the model was not yet initialized
  51929. */
  51930. rootMesh: Nullable<AbstractMesh>;
  51931. /**
  51932. * constructs a new abstract motion controller
  51933. * @param scene the scene to which the model of the controller will be added
  51934. * @param layout The profile layout to load
  51935. * @param gamepadObject The gamepad object correlating to this controller
  51936. * @param handedness handedness (left/right/none) of this controller
  51937. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51938. */
  51939. constructor(scene: Scene, layout: IMotionControllerLayout,
  51940. /**
  51941. * The gamepad object correlating to this controller
  51942. */
  51943. gamepadObject: IMinimalMotionControllerObject,
  51944. /**
  51945. * handedness (left/right/none) of this controller
  51946. */
  51947. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51948. /**
  51949. * Dispose this controller, the model mesh and all its components
  51950. */
  51951. dispose(): void;
  51952. /**
  51953. * Returns all components of specific type
  51954. * @param type the type to search for
  51955. * @return an array of components with this type
  51956. */
  51957. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51958. /**
  51959. * get a component based an its component id as defined in layout.components
  51960. * @param id the id of the component
  51961. * @returns the component correlates to the id or undefined if not found
  51962. */
  51963. getComponent(id: string): WebXRControllerComponent;
  51964. /**
  51965. * Get the list of components available in this motion controller
  51966. * @returns an array of strings correlating to available components
  51967. */
  51968. getComponentIds(): string[];
  51969. /**
  51970. * Get the first component of specific type
  51971. * @param type type of component to find
  51972. * @return a controller component or null if not found
  51973. */
  51974. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51975. /**
  51976. * Get the main (Select) component of this controller as defined in the layout
  51977. * @returns the main component of this controller
  51978. */
  51979. getMainComponent(): WebXRControllerComponent;
  51980. /**
  51981. * Loads the model correlating to this controller
  51982. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51983. * @returns A promise fulfilled with the result of the model loading
  51984. */
  51985. loadModel(): Promise<boolean>;
  51986. /**
  51987. * Update this model using the current XRFrame
  51988. * @param xrFrame the current xr frame to use and update the model
  51989. */
  51990. updateFromXRFrame(xrFrame: XRFrame): void;
  51991. /**
  51992. * Backwards compatibility due to a deeply-integrated typo
  51993. */
  51994. get handness(): XREye;
  51995. /**
  51996. * Pulse (vibrate) this controller
  51997. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51998. * Consecutive calls to this function will cancel the last pulse call
  51999. *
  52000. * @param value the strength of the pulse in 0.0...1.0 range
  52001. * @param duration Duration of the pulse in milliseconds
  52002. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52003. * @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
  52004. */
  52005. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52006. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52007. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52008. /**
  52009. * Moves the axis on the controller mesh based on its current state
  52010. * @param axis the index of the axis
  52011. * @param axisValue the value of the axis which determines the meshes new position
  52012. * @hidden
  52013. */
  52014. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52015. /**
  52016. * Update the model itself with the current frame data
  52017. * @param xrFrame the frame to use for updating the model mesh
  52018. */
  52019. protected updateModel(xrFrame: XRFrame): void;
  52020. /**
  52021. * Get the filename and path for this controller's model
  52022. * @returns a map of filename and path
  52023. */
  52024. protected abstract _getFilenameAndPath(): {
  52025. filename: string;
  52026. path: string;
  52027. };
  52028. /**
  52029. * This function is called before the mesh is loaded. It checks for loading constraints.
  52030. * For example, this function can check if the GLB loader is available
  52031. * If this function returns false, the generic controller will be loaded instead
  52032. * @returns Is the client ready to load the mesh
  52033. */
  52034. protected abstract _getModelLoadingConstraints(): boolean;
  52035. /**
  52036. * This function will be called after the model was successfully loaded and can be used
  52037. * for mesh transformations before it is available for the user
  52038. * @param meshes the loaded meshes
  52039. */
  52040. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52041. /**
  52042. * Set the root mesh for this controller. Important for the WebXR controller class
  52043. * @param meshes the loaded meshes
  52044. */
  52045. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52046. /**
  52047. * A function executed each frame that updates the mesh (if needed)
  52048. * @param xrFrame the current xrFrame
  52049. */
  52050. protected abstract _updateModel(xrFrame: XRFrame): void;
  52051. private _getGenericFilenameAndPath;
  52052. private _getGenericParentMesh;
  52053. }
  52054. }
  52055. declare module BABYLON {
  52056. /**
  52057. * A generic trigger-only motion controller for WebXR
  52058. */
  52059. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52060. /**
  52061. * Static version of the profile id of this controller
  52062. */
  52063. static ProfileId: string;
  52064. profileId: string;
  52065. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52066. protected _getFilenameAndPath(): {
  52067. filename: string;
  52068. path: string;
  52069. };
  52070. protected _getModelLoadingConstraints(): boolean;
  52071. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52072. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52073. protected _updateModel(): void;
  52074. }
  52075. }
  52076. declare module BABYLON {
  52077. /**
  52078. * Class containing static functions to help procedurally build meshes
  52079. */
  52080. export class SphereBuilder {
  52081. /**
  52082. * Creates a sphere mesh
  52083. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52084. * * 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`)
  52085. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52086. * * 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
  52087. * * 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)
  52088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52089. * * 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
  52090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52091. * @param name defines the name of the mesh
  52092. * @param options defines the options used to create the mesh
  52093. * @param scene defines the hosting scene
  52094. * @returns the sphere mesh
  52095. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52096. */
  52097. static CreateSphere(name: string, options: {
  52098. segments?: number;
  52099. diameter?: number;
  52100. diameterX?: number;
  52101. diameterY?: number;
  52102. diameterZ?: number;
  52103. arc?: number;
  52104. slice?: number;
  52105. sideOrientation?: number;
  52106. frontUVs?: Vector4;
  52107. backUVs?: Vector4;
  52108. updatable?: boolean;
  52109. }, scene?: Nullable<Scene>): Mesh;
  52110. }
  52111. }
  52112. declare module BABYLON {
  52113. /**
  52114. * A profiled motion controller has its profile loaded from an online repository.
  52115. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52116. */
  52117. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52118. private _repositoryUrl;
  52119. private _buttonMeshMapping;
  52120. private _touchDots;
  52121. /**
  52122. * The profile ID of this controller. Will be populated when the controller initializes.
  52123. */
  52124. profileId: string;
  52125. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52126. dispose(): void;
  52127. protected _getFilenameAndPath(): {
  52128. filename: string;
  52129. path: string;
  52130. };
  52131. protected _getModelLoadingConstraints(): boolean;
  52132. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52133. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52134. protected _updateModel(_xrFrame: XRFrame): void;
  52135. }
  52136. }
  52137. declare module BABYLON {
  52138. /**
  52139. * A construction function type to create a new controller based on an xrInput object
  52140. */
  52141. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52142. /**
  52143. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52144. *
  52145. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52146. * it should be replaced with auto-loaded controllers.
  52147. *
  52148. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52149. */
  52150. export class WebXRMotionControllerManager {
  52151. private static _AvailableControllers;
  52152. private static _Fallbacks;
  52153. private static _ProfileLoadingPromises;
  52154. private static _ProfilesList;
  52155. /**
  52156. * The base URL of the online controller repository. Can be changed at any time.
  52157. */
  52158. static BaseRepositoryUrl: string;
  52159. /**
  52160. * Which repository gets priority - local or online
  52161. */
  52162. static PrioritizeOnlineRepository: boolean;
  52163. /**
  52164. * Use the online repository, or use only locally-defined controllers
  52165. */
  52166. static UseOnlineRepository: boolean;
  52167. /**
  52168. * Clear the cache used for profile loading and reload when requested again
  52169. */
  52170. static ClearProfilesCache(): void;
  52171. /**
  52172. * Register the default fallbacks.
  52173. * This function is called automatically when this file is imported.
  52174. */
  52175. static DefaultFallbacks(): void;
  52176. /**
  52177. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52178. * @param profileId the profile to which a fallback needs to be found
  52179. * @return an array with corresponding fallback profiles
  52180. */
  52181. static FindFallbackWithProfileId(profileId: string): string[];
  52182. /**
  52183. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52184. * The order of search:
  52185. *
  52186. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52187. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52188. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52189. * 4) return the generic trigger controller if none were found
  52190. *
  52191. * @param xrInput the xrInput to which a new controller is initialized
  52192. * @param scene the scene to which the model will be added
  52193. * @param forceProfile force a certain profile for this controller
  52194. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52195. */
  52196. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52197. /**
  52198. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52199. *
  52200. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52201. *
  52202. * @param type the profile type to register
  52203. * @param constructFunction the function to be called when loading this profile
  52204. */
  52205. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52206. /**
  52207. * Register a fallback to a specific profile.
  52208. * @param profileId the profileId that will receive the fallbacks
  52209. * @param fallbacks A list of fallback profiles
  52210. */
  52211. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52212. /**
  52213. * Will update the list of profiles available in the repository
  52214. * @return a promise that resolves to a map of profiles available online
  52215. */
  52216. static UpdateProfilesList(): Promise<{
  52217. [profile: string]: string;
  52218. }>;
  52219. private static _LoadProfileFromRepository;
  52220. private static _LoadProfilesFromAvailableControllers;
  52221. }
  52222. }
  52223. declare module BABYLON {
  52224. /**
  52225. * Configuration options for the WebXR controller creation
  52226. */
  52227. export interface IWebXRControllerOptions {
  52228. /**
  52229. * Should the controller mesh be animated when a user interacts with it
  52230. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52231. */
  52232. disableMotionControllerAnimation?: boolean;
  52233. /**
  52234. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52235. */
  52236. doNotLoadControllerMesh?: boolean;
  52237. /**
  52238. * Force a specific controller type for this controller.
  52239. * This can be used when creating your own profile or when testing different controllers
  52240. */
  52241. forceControllerProfile?: string;
  52242. /**
  52243. * Defines a rendering group ID for meshes that will be loaded.
  52244. * This is for the default controllers only.
  52245. */
  52246. renderingGroupId?: number;
  52247. }
  52248. /**
  52249. * Represents an XR controller
  52250. */
  52251. export class WebXRInputSource {
  52252. private _scene;
  52253. /** The underlying input source for the controller */
  52254. inputSource: XRInputSource;
  52255. private _options;
  52256. private _tmpVector;
  52257. private _uniqueId;
  52258. private _disposed;
  52259. /**
  52260. * 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
  52261. */
  52262. grip?: AbstractMesh;
  52263. /**
  52264. * If available, this is the gamepad object related to this controller.
  52265. * Using this object it is possible to get click events and trackpad changes of the
  52266. * webxr controller that is currently being used.
  52267. */
  52268. motionController?: WebXRAbstractMotionController;
  52269. /**
  52270. * Event that fires when the controller is removed/disposed.
  52271. * The object provided as event data is this controller, after associated assets were disposed.
  52272. * uniqueId is still available.
  52273. */
  52274. onDisposeObservable: Observable<WebXRInputSource>;
  52275. /**
  52276. * Will be triggered when the mesh associated with the motion controller is done loading.
  52277. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52278. * A shortened version of controller -> motion controller -> on mesh loaded.
  52279. */
  52280. onMeshLoadedObservable: Observable<AbstractMesh>;
  52281. /**
  52282. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52283. */
  52284. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52285. /**
  52286. * Pointer which can be used to select objects or attach a visible laser to
  52287. */
  52288. pointer: AbstractMesh;
  52289. /**
  52290. * Creates the input source object
  52291. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52292. * @param _scene the scene which the controller should be associated to
  52293. * @param inputSource the underlying input source for the controller
  52294. * @param _options options for this controller creation
  52295. */
  52296. constructor(_scene: Scene,
  52297. /** The underlying input source for the controller */
  52298. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52299. /**
  52300. * Get this controllers unique id
  52301. */
  52302. get uniqueId(): string;
  52303. /**
  52304. * Disposes of the object
  52305. */
  52306. dispose(): void;
  52307. /**
  52308. * Gets a world space ray coming from the pointer or grip
  52309. * @param result the resulting ray
  52310. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52311. */
  52312. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52313. /**
  52314. * Updates the controller pose based on the given XRFrame
  52315. * @param xrFrame xr frame to update the pose with
  52316. * @param referenceSpace reference space to use
  52317. */
  52318. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52319. }
  52320. }
  52321. declare module BABYLON {
  52322. /**
  52323. * The schema for initialization options of the XR Input class
  52324. */
  52325. export interface IWebXRInputOptions {
  52326. /**
  52327. * If set to true no model will be automatically loaded
  52328. */
  52329. doNotLoadControllerMeshes?: boolean;
  52330. /**
  52331. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52332. * If not found, the xr input profile data will be used.
  52333. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52334. */
  52335. forceInputProfile?: string;
  52336. /**
  52337. * Do not send a request to the controller repository to load the profile.
  52338. *
  52339. * Instead, use the controllers available in babylon itself.
  52340. */
  52341. disableOnlineControllerRepository?: boolean;
  52342. /**
  52343. * A custom URL for the controllers repository
  52344. */
  52345. customControllersRepositoryURL?: string;
  52346. /**
  52347. * Should the controller model's components not move according to the user input
  52348. */
  52349. disableControllerAnimation?: boolean;
  52350. /**
  52351. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52352. */
  52353. controllerOptions?: IWebXRControllerOptions;
  52354. }
  52355. /**
  52356. * XR input used to track XR inputs such as controllers/rays
  52357. */
  52358. export class WebXRInput implements IDisposable {
  52359. /**
  52360. * the xr session manager for this session
  52361. */
  52362. xrSessionManager: WebXRSessionManager;
  52363. /**
  52364. * the WebXR camera for this session. Mainly used for teleportation
  52365. */
  52366. xrCamera: WebXRCamera;
  52367. private readonly options;
  52368. /**
  52369. * XR controllers being tracked
  52370. */
  52371. controllers: Array<WebXRInputSource>;
  52372. private _frameObserver;
  52373. private _sessionEndedObserver;
  52374. private _sessionInitObserver;
  52375. /**
  52376. * Event when a controller has been connected/added
  52377. */
  52378. onControllerAddedObservable: Observable<WebXRInputSource>;
  52379. /**
  52380. * Event when a controller has been removed/disconnected
  52381. */
  52382. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52383. /**
  52384. * Initializes the WebXRInput
  52385. * @param xrSessionManager the xr session manager for this session
  52386. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52387. * @param options = initialization options for this xr input
  52388. */
  52389. constructor(
  52390. /**
  52391. * the xr session manager for this session
  52392. */
  52393. xrSessionManager: WebXRSessionManager,
  52394. /**
  52395. * the WebXR camera for this session. Mainly used for teleportation
  52396. */
  52397. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52398. private _onInputSourcesChange;
  52399. private _addAndRemoveControllers;
  52400. /**
  52401. * Disposes of the object
  52402. */
  52403. dispose(): void;
  52404. }
  52405. }
  52406. declare module BABYLON {
  52407. /**
  52408. * This is the base class for all WebXR features.
  52409. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52410. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52411. */
  52412. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52413. protected _xrSessionManager: WebXRSessionManager;
  52414. private _attached;
  52415. private _removeOnDetach;
  52416. /**
  52417. * Is this feature disposed?
  52418. */
  52419. isDisposed: boolean;
  52420. /**
  52421. * Should auto-attach be disabled?
  52422. */
  52423. disableAutoAttach: boolean;
  52424. /**
  52425. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52426. */
  52427. xrNativeFeatureName: string;
  52428. /**
  52429. * Construct a new (abstract) WebXR feature
  52430. * @param _xrSessionManager the xr session manager for this feature
  52431. */
  52432. constructor(_xrSessionManager: WebXRSessionManager);
  52433. /**
  52434. * Is this feature attached
  52435. */
  52436. get attached(): boolean;
  52437. /**
  52438. * attach this feature
  52439. *
  52440. * @param force should attachment be forced (even when already attached)
  52441. * @returns true if successful, false is failed or already attached
  52442. */
  52443. attach(force?: boolean): boolean;
  52444. /**
  52445. * detach this feature.
  52446. *
  52447. * @returns true if successful, false if failed or already detached
  52448. */
  52449. detach(): boolean;
  52450. /**
  52451. * Dispose this feature and all of the resources attached
  52452. */
  52453. dispose(): void;
  52454. /**
  52455. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52456. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52457. *
  52458. * @returns whether or not the feature is compatible in this environment
  52459. */
  52460. isCompatible(): boolean;
  52461. /**
  52462. * This is used to register callbacks that will automatically be removed when detach is called.
  52463. * @param observable the observable to which the observer will be attached
  52464. * @param callback the callback to register
  52465. */
  52466. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52467. /**
  52468. * Code in this function will be executed on each xrFrame received from the browser.
  52469. * This function will not execute after the feature is detached.
  52470. * @param _xrFrame the current frame
  52471. */
  52472. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /**
  52477. * Renders a layer on top of an existing scene
  52478. */
  52479. export class UtilityLayerRenderer implements IDisposable {
  52480. /** the original scene that will be rendered on top of */
  52481. originalScene: Scene;
  52482. private _pointerCaptures;
  52483. private _lastPointerEvents;
  52484. private static _DefaultUtilityLayer;
  52485. private static _DefaultKeepDepthUtilityLayer;
  52486. private _sharedGizmoLight;
  52487. private _renderCamera;
  52488. /**
  52489. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52490. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52491. * @returns the camera that is used when rendering the utility layer
  52492. */
  52493. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52494. /**
  52495. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52496. * @param cam the camera that should be used when rendering the utility layer
  52497. */
  52498. setRenderCamera(cam: Nullable<Camera>): void;
  52499. /**
  52500. * @hidden
  52501. * Light which used by gizmos to get light shading
  52502. */
  52503. _getSharedGizmoLight(): HemisphericLight;
  52504. /**
  52505. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52506. */
  52507. pickUtilitySceneFirst: boolean;
  52508. /**
  52509. * 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)
  52510. */
  52511. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52512. /**
  52513. * 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)
  52514. */
  52515. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52516. /**
  52517. * The scene that is rendered on top of the original scene
  52518. */
  52519. utilityLayerScene: Scene;
  52520. /**
  52521. * If the utility layer should automatically be rendered on top of existing scene
  52522. */
  52523. shouldRender: boolean;
  52524. /**
  52525. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52526. */
  52527. onlyCheckPointerDownEvents: boolean;
  52528. /**
  52529. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52530. */
  52531. processAllEvents: boolean;
  52532. /**
  52533. * Observable raised when the pointer move from the utility layer scene to the main scene
  52534. */
  52535. onPointerOutObservable: Observable<number>;
  52536. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52537. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52538. private _afterRenderObserver;
  52539. private _sceneDisposeObserver;
  52540. private _originalPointerObserver;
  52541. /**
  52542. * Instantiates a UtilityLayerRenderer
  52543. * @param originalScene the original scene that will be rendered on top of
  52544. * @param handleEvents boolean indicating if the utility layer should handle events
  52545. */
  52546. constructor(
  52547. /** the original scene that will be rendered on top of */
  52548. originalScene: Scene, handleEvents?: boolean);
  52549. private _notifyObservers;
  52550. /**
  52551. * Renders the utility layers scene on top of the original scene
  52552. */
  52553. render(): void;
  52554. /**
  52555. * Disposes of the renderer
  52556. */
  52557. dispose(): void;
  52558. private _updateCamera;
  52559. }
  52560. }
  52561. declare module BABYLON {
  52562. /**
  52563. * Options interface for the pointer selection module
  52564. */
  52565. export interface IWebXRControllerPointerSelectionOptions {
  52566. /**
  52567. * if provided, this scene will be used to render meshes.
  52568. */
  52569. customUtilityLayerScene?: Scene;
  52570. /**
  52571. * 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)
  52572. * If not disabled, the last picked point will be used to execute a pointer up event
  52573. * If disabled, pointer up event will be triggered right after the pointer down event.
  52574. * Used in screen and gaze target ray mode only
  52575. */
  52576. disablePointerUpOnTouchOut: boolean;
  52577. /**
  52578. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52579. */
  52580. forceGazeMode: boolean;
  52581. /**
  52582. * 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
  52583. * to start a new countdown to the pointer down event.
  52584. * Defaults to 1.
  52585. */
  52586. gazeModePointerMovedFactor?: number;
  52587. /**
  52588. * Different button type to use instead of the main component
  52589. */
  52590. overrideButtonId?: string;
  52591. /**
  52592. * use this rendering group id for the meshes (optional)
  52593. */
  52594. renderingGroupId?: number;
  52595. /**
  52596. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52597. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52598. * 3000 means 3 seconds between pointing at something and selecting it
  52599. */
  52600. timeToSelect?: number;
  52601. /**
  52602. * Should meshes created here be added to a utility layer or the main scene
  52603. */
  52604. useUtilityLayer?: boolean;
  52605. /**
  52606. * Optional WebXR camera to be used for gaze selection
  52607. */
  52608. gazeCamera?: WebXRCamera;
  52609. /**
  52610. * the xr input to use with this pointer selection
  52611. */
  52612. xrInput: WebXRInput;
  52613. /**
  52614. * Should the scene pointerX and pointerY update be disabled
  52615. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52616. * Disable in VR, if not needed.
  52617. * The first rig camera (left eye) will be used to calculate the projection
  52618. */
  52619. disableScenePointerVectorUpdate: boolean;
  52620. /**
  52621. * Enable pointer selection on all controllers instead of switching between them
  52622. */
  52623. enablePointerSelectionOnAllControllers?: boolean;
  52624. /**
  52625. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52626. * If switch is enabled, it will still allow the user to switch between the different controllers
  52627. */
  52628. preferredHandedness?: XRHandedness;
  52629. /**
  52630. * Disable switching the pointer selection from one controller to the other.
  52631. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52632. */
  52633. disableSwitchOnClick?: boolean;
  52634. /**
  52635. * The maximum distance of the pointer selection feature. Defaults to 100.
  52636. */
  52637. maxPointerDistance?: number;
  52638. }
  52639. /**
  52640. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52641. */
  52642. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52643. private readonly _options;
  52644. private static _idCounter;
  52645. private _attachController;
  52646. private _controllers;
  52647. private _scene;
  52648. private _tmpVectorForPickCompare;
  52649. private _attachedController;
  52650. /**
  52651. * The module's name
  52652. */
  52653. static readonly Name: string;
  52654. /**
  52655. * The (Babylon) version of this module.
  52656. * This is an integer representing the implementation version.
  52657. * This number does not correspond to the WebXR specs version
  52658. */
  52659. static readonly Version: number;
  52660. /**
  52661. * Disable lighting on the laser pointer (so it will always be visible)
  52662. */
  52663. disablePointerLighting: boolean;
  52664. /**
  52665. * Disable lighting on the selection mesh (so it will always be visible)
  52666. */
  52667. disableSelectionMeshLighting: boolean;
  52668. /**
  52669. * Should the laser pointer be displayed
  52670. */
  52671. displayLaserPointer: boolean;
  52672. /**
  52673. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52674. */
  52675. displaySelectionMesh: boolean;
  52676. /**
  52677. * This color will be set to the laser pointer when selection is triggered
  52678. */
  52679. laserPointerPickedColor: Color3;
  52680. /**
  52681. * Default color of the laser pointer
  52682. */
  52683. laserPointerDefaultColor: Color3;
  52684. /**
  52685. * default color of the selection ring
  52686. */
  52687. selectionMeshDefaultColor: Color3;
  52688. /**
  52689. * This color will be applied to the selection ring when selection is triggered
  52690. */
  52691. selectionMeshPickedColor: Color3;
  52692. /**
  52693. * Optional filter to be used for ray selection. This predicate shares behavior with
  52694. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52695. */
  52696. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52697. /**
  52698. * constructs a new background remover module
  52699. * @param _xrSessionManager the session manager for this module
  52700. * @param _options read-only options to be used in this module
  52701. */
  52702. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52703. /**
  52704. * attach this feature
  52705. * Will usually be called by the features manager
  52706. *
  52707. * @returns true if successful.
  52708. */
  52709. attach(): boolean;
  52710. /**
  52711. * detach this feature.
  52712. * Will usually be called by the features manager
  52713. *
  52714. * @returns true if successful.
  52715. */
  52716. detach(): boolean;
  52717. /**
  52718. * Will get the mesh under a specific pointer.
  52719. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52720. * @param controllerId the controllerId to check
  52721. * @returns The mesh under pointer or null if no mesh is under the pointer
  52722. */
  52723. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52724. /**
  52725. * Get the xr controller that correlates to the pointer id in the pointer event
  52726. *
  52727. * @param id the pointer id to search for
  52728. * @returns the controller that correlates to this id or null if not found
  52729. */
  52730. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52731. private _identityMatrix;
  52732. private _screenCoordinatesRef;
  52733. private _viewportRef;
  52734. protected _onXRFrame(_xrFrame: XRFrame): void;
  52735. private _attachGazeMode;
  52736. private _attachScreenRayMode;
  52737. private _attachTrackedPointerRayMode;
  52738. private _convertNormalToDirectionOfRay;
  52739. private _detachController;
  52740. private _generateNewMeshPair;
  52741. private _pickingMoved;
  52742. private _updatePointerDistance;
  52743. /** @hidden */
  52744. get lasterPointerDefaultColor(): Color3;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /**
  52749. * Button which can be used to enter a different mode of XR
  52750. */
  52751. export class WebXREnterExitUIButton {
  52752. /** button element */
  52753. element: HTMLElement;
  52754. /** XR initialization options for the button */
  52755. sessionMode: XRSessionMode;
  52756. /** Reference space type */
  52757. referenceSpaceType: XRReferenceSpaceType;
  52758. /**
  52759. * Creates a WebXREnterExitUIButton
  52760. * @param element button element
  52761. * @param sessionMode XR initialization session mode
  52762. * @param referenceSpaceType the type of reference space to be used
  52763. */
  52764. constructor(
  52765. /** button element */
  52766. element: HTMLElement,
  52767. /** XR initialization options for the button */
  52768. sessionMode: XRSessionMode,
  52769. /** Reference space type */
  52770. referenceSpaceType: XRReferenceSpaceType);
  52771. /**
  52772. * Extendable function which can be used to update the button's visuals when the state changes
  52773. * @param activeButton the current active button in the UI
  52774. */
  52775. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52776. }
  52777. /**
  52778. * Options to create the webXR UI
  52779. */
  52780. export class WebXREnterExitUIOptions {
  52781. /**
  52782. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52783. */
  52784. customButtons?: Array<WebXREnterExitUIButton>;
  52785. /**
  52786. * A reference space type to use when creating the default button.
  52787. * Default is local-floor
  52788. */
  52789. referenceSpaceType?: XRReferenceSpaceType;
  52790. /**
  52791. * Context to enter xr with
  52792. */
  52793. renderTarget?: Nullable<WebXRRenderTarget>;
  52794. /**
  52795. * A session mode to use when creating the default button.
  52796. * Default is immersive-vr
  52797. */
  52798. sessionMode?: XRSessionMode;
  52799. /**
  52800. * A list of optional features to init the session with
  52801. */
  52802. optionalFeatures?: string[];
  52803. /**
  52804. * A list of optional features to init the session with
  52805. */
  52806. requiredFeatures?: string[];
  52807. /**
  52808. * If defined, this function will be executed if the UI encounters an error when entering XR
  52809. */
  52810. onError?: (error: any) => void;
  52811. }
  52812. /**
  52813. * UI to allow the user to enter/exit XR mode
  52814. */
  52815. export class WebXREnterExitUI implements IDisposable {
  52816. private scene;
  52817. /** version of the options passed to this UI */
  52818. options: WebXREnterExitUIOptions;
  52819. private _activeButton;
  52820. private _buttons;
  52821. /**
  52822. * The HTML Div Element to which buttons are added.
  52823. */
  52824. readonly overlay: HTMLDivElement;
  52825. /**
  52826. * Fired every time the active button is changed.
  52827. *
  52828. * When xr is entered via a button that launches xr that button will be the callback parameter
  52829. *
  52830. * When exiting xr the callback parameter will be null)
  52831. */
  52832. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52833. /**
  52834. *
  52835. * @param scene babylon scene object to use
  52836. * @param options (read-only) version of the options passed to this UI
  52837. */
  52838. private constructor();
  52839. /**
  52840. * Creates UI to allow the user to enter/exit XR mode
  52841. * @param scene the scene to add the ui to
  52842. * @param helper the xr experience helper to enter/exit xr with
  52843. * @param options options to configure the UI
  52844. * @returns the created ui
  52845. */
  52846. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52847. /**
  52848. * Disposes of the XR UI component
  52849. */
  52850. dispose(): void;
  52851. private _updateButtons;
  52852. }
  52853. }
  52854. declare module BABYLON {
  52855. /**
  52856. * Class containing static functions to help procedurally build meshes
  52857. */
  52858. export class LinesBuilder {
  52859. /**
  52860. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52861. * * 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
  52862. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52863. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52864. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52865. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52866. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52867. * * 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
  52868. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52871. * @param name defines the name of the new line system
  52872. * @param options defines the options used to create the line system
  52873. * @param scene defines the hosting scene
  52874. * @returns a new line system mesh
  52875. */
  52876. static CreateLineSystem(name: string, options: {
  52877. lines: Vector3[][];
  52878. updatable?: boolean;
  52879. instance?: Nullable<LinesMesh>;
  52880. colors?: Nullable<Color4[][]>;
  52881. useVertexAlpha?: boolean;
  52882. }, scene: Nullable<Scene>): LinesMesh;
  52883. /**
  52884. * Creates a line mesh
  52885. * 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
  52886. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52887. * * The parameter `points` is an array successive Vector3
  52888. * * 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
  52889. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52890. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52891. * * When updating an instance, remember that only point positions can change, not the number of points
  52892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52894. * @param name defines the name of the new line system
  52895. * @param options defines the options used to create the line system
  52896. * @param scene defines the hosting scene
  52897. * @returns a new line mesh
  52898. */
  52899. static CreateLines(name: string, options: {
  52900. points: Vector3[];
  52901. updatable?: boolean;
  52902. instance?: Nullable<LinesMesh>;
  52903. colors?: Color4[];
  52904. useVertexAlpha?: boolean;
  52905. }, scene?: Nullable<Scene>): LinesMesh;
  52906. /**
  52907. * Creates a dashed line mesh
  52908. * * 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
  52909. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52910. * * The parameter `points` is an array successive Vector3
  52911. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52912. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52913. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52914. * * 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
  52915. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52916. * * When updating an instance, remember that only point positions can change, not the number of points
  52917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52918. * @param name defines the name of the mesh
  52919. * @param options defines the options used to create the mesh
  52920. * @param scene defines the hosting scene
  52921. * @returns the dashed line mesh
  52922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52923. */
  52924. static CreateDashedLines(name: string, options: {
  52925. points: Vector3[];
  52926. dashSize?: number;
  52927. gapSize?: number;
  52928. dashNb?: number;
  52929. updatable?: boolean;
  52930. instance?: LinesMesh;
  52931. useVertexAlpha?: boolean;
  52932. }, scene?: Nullable<Scene>): LinesMesh;
  52933. }
  52934. }
  52935. declare module BABYLON {
  52936. /**
  52937. * Construction options for a timer
  52938. */
  52939. export interface ITimerOptions<T> {
  52940. /**
  52941. * Time-to-end
  52942. */
  52943. timeout: number;
  52944. /**
  52945. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52946. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52947. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52948. */
  52949. contextObservable: Observable<T>;
  52950. /**
  52951. * Optional parameters when adding an observer to the observable
  52952. */
  52953. observableParameters?: {
  52954. mask?: number;
  52955. insertFirst?: boolean;
  52956. scope?: any;
  52957. };
  52958. /**
  52959. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52960. */
  52961. breakCondition?: (data?: ITimerData<T>) => boolean;
  52962. /**
  52963. * Will be triggered when the time condition has met
  52964. */
  52965. onEnded?: (data: ITimerData<any>) => void;
  52966. /**
  52967. * Will be triggered when the break condition has met (prematurely ended)
  52968. */
  52969. onAborted?: (data: ITimerData<any>) => void;
  52970. /**
  52971. * Optional function to execute on each tick (or count)
  52972. */
  52973. onTick?: (data: ITimerData<any>) => void;
  52974. }
  52975. /**
  52976. * An interface defining the data sent by the timer
  52977. */
  52978. export interface ITimerData<T> {
  52979. /**
  52980. * When did it start
  52981. */
  52982. startTime: number;
  52983. /**
  52984. * Time now
  52985. */
  52986. currentTime: number;
  52987. /**
  52988. * Time passed since started
  52989. */
  52990. deltaTime: number;
  52991. /**
  52992. * How much is completed, in [0.0...1.0].
  52993. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52994. */
  52995. completeRate: number;
  52996. /**
  52997. * What the registered observable sent in the last count
  52998. */
  52999. payload: T;
  53000. }
  53001. /**
  53002. * The current state of the timer
  53003. */
  53004. export enum TimerState {
  53005. /**
  53006. * Timer initialized, not yet started
  53007. */
  53008. INIT = 0,
  53009. /**
  53010. * Timer started and counting
  53011. */
  53012. STARTED = 1,
  53013. /**
  53014. * Timer ended (whether aborted or time reached)
  53015. */
  53016. ENDED = 2
  53017. }
  53018. /**
  53019. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53020. *
  53021. * @param options options with which to initialize this timer
  53022. */
  53023. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53024. /**
  53025. * An advanced implementation of a timer class
  53026. */
  53027. export class AdvancedTimer<T = any> implements IDisposable {
  53028. /**
  53029. * Will notify each time the timer calculates the remaining time
  53030. */
  53031. onEachCountObservable: Observable<ITimerData<T>>;
  53032. /**
  53033. * Will trigger when the timer was aborted due to the break condition
  53034. */
  53035. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53036. /**
  53037. * Will trigger when the timer ended successfully
  53038. */
  53039. onTimerEndedObservable: Observable<ITimerData<T>>;
  53040. /**
  53041. * Will trigger when the timer state has changed
  53042. */
  53043. onStateChangedObservable: Observable<TimerState>;
  53044. private _observer;
  53045. private _contextObservable;
  53046. private _observableParameters;
  53047. private _startTime;
  53048. private _timer;
  53049. private _state;
  53050. private _breakCondition;
  53051. private _timeToEnd;
  53052. private _breakOnNextTick;
  53053. /**
  53054. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53055. * @param options construction options for this advanced timer
  53056. */
  53057. constructor(options: ITimerOptions<T>);
  53058. /**
  53059. * set a breaking condition for this timer. Default is to never break during count
  53060. * @param predicate the new break condition. Returns true to break, false otherwise
  53061. */
  53062. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53063. /**
  53064. * Reset ALL associated observables in this advanced timer
  53065. */
  53066. clearObservables(): void;
  53067. /**
  53068. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53069. *
  53070. * @param timeToEnd how much time to measure until timer ended
  53071. */
  53072. start(timeToEnd?: number): void;
  53073. /**
  53074. * Will force a stop on the next tick.
  53075. */
  53076. stop(): void;
  53077. /**
  53078. * Dispose this timer, clearing all resources
  53079. */
  53080. dispose(): void;
  53081. private _setState;
  53082. private _tick;
  53083. private _stop;
  53084. }
  53085. }
  53086. declare module BABYLON {
  53087. /**
  53088. * The options container for the teleportation module
  53089. */
  53090. export interface IWebXRTeleportationOptions {
  53091. /**
  53092. * if provided, this scene will be used to render meshes.
  53093. */
  53094. customUtilityLayerScene?: Scene;
  53095. /**
  53096. * Values to configure the default target mesh
  53097. */
  53098. defaultTargetMeshOptions?: {
  53099. /**
  53100. * Fill color of the teleportation area
  53101. */
  53102. teleportationFillColor?: string;
  53103. /**
  53104. * Border color for the teleportation area
  53105. */
  53106. teleportationBorderColor?: string;
  53107. /**
  53108. * Disable the mesh's animation sequence
  53109. */
  53110. disableAnimation?: boolean;
  53111. /**
  53112. * Disable lighting on the material or the ring and arrow
  53113. */
  53114. disableLighting?: boolean;
  53115. /**
  53116. * Override the default material of the torus and arrow
  53117. */
  53118. torusArrowMaterial?: Material;
  53119. };
  53120. /**
  53121. * A list of meshes to use as floor meshes.
  53122. * Meshes can be added and removed after initializing the feature using the
  53123. * addFloorMesh and removeFloorMesh functions
  53124. * If empty, rotation will still work
  53125. */
  53126. floorMeshes?: AbstractMesh[];
  53127. /**
  53128. * use this rendering group id for the meshes (optional)
  53129. */
  53130. renderingGroupId?: number;
  53131. /**
  53132. * Should teleportation move only to snap points
  53133. */
  53134. snapPointsOnly?: boolean;
  53135. /**
  53136. * An array of points to which the teleportation will snap to.
  53137. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53138. */
  53139. snapPositions?: Vector3[];
  53140. /**
  53141. * How close should the teleportation ray be in order to snap to position.
  53142. * Default to 0.8 units (meters)
  53143. */
  53144. snapToPositionRadius?: number;
  53145. /**
  53146. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53147. * If you want to support rotation, make sure your mesh has a direction indicator.
  53148. *
  53149. * When left untouched, the default mesh will be initialized.
  53150. */
  53151. teleportationTargetMesh?: AbstractMesh;
  53152. /**
  53153. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53154. */
  53155. timeToTeleport?: number;
  53156. /**
  53157. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53158. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53159. */
  53160. useMainComponentOnly?: boolean;
  53161. /**
  53162. * Should meshes created here be added to a utility layer or the main scene
  53163. */
  53164. useUtilityLayer?: boolean;
  53165. /**
  53166. * Babylon XR Input class for controller
  53167. */
  53168. xrInput: WebXRInput;
  53169. /**
  53170. * Meshes that the teleportation ray cannot go through
  53171. */
  53172. pickBlockerMeshes?: AbstractMesh[];
  53173. /**
  53174. * Should teleport work only on a specific hand?
  53175. */
  53176. forceHandedness?: XRHandedness;
  53177. /**
  53178. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53179. */
  53180. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53181. }
  53182. /**
  53183. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53184. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53185. * the input of the attached controllers.
  53186. */
  53187. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53188. private _options;
  53189. private _controllers;
  53190. private _currentTeleportationControllerId;
  53191. private _floorMeshes;
  53192. private _quadraticBezierCurve;
  53193. private _selectionFeature;
  53194. private _snapToPositions;
  53195. private _snappedToPoint;
  53196. private _teleportationRingMaterial?;
  53197. private _tmpRay;
  53198. private _tmpVector;
  53199. private _tmpQuaternion;
  53200. /**
  53201. * The module's name
  53202. */
  53203. static readonly Name: string;
  53204. /**
  53205. * The (Babylon) version of this module.
  53206. * This is an integer representing the implementation version.
  53207. * This number does not correspond to the webxr specs version
  53208. */
  53209. static readonly Version: number;
  53210. /**
  53211. * Is movement backwards enabled
  53212. */
  53213. backwardsMovementEnabled: boolean;
  53214. /**
  53215. * Distance to travel when moving backwards
  53216. */
  53217. backwardsTeleportationDistance: number;
  53218. /**
  53219. * The distance from the user to the inspection point in the direction of the controller
  53220. * A higher number will allow the user to move further
  53221. * defaults to 5 (meters, in xr units)
  53222. */
  53223. parabolicCheckRadius: number;
  53224. /**
  53225. * Should the module support parabolic ray on top of direct ray
  53226. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53227. * Very helpful when moving between floors / different heights
  53228. */
  53229. parabolicRayEnabled: boolean;
  53230. /**
  53231. * The second type of ray - straight line.
  53232. * Should it be enabled or should the parabolic line be the only one.
  53233. */
  53234. straightRayEnabled: boolean;
  53235. /**
  53236. * How much rotation should be applied when rotating right and left
  53237. */
  53238. rotationAngle: number;
  53239. private _rotationEnabled;
  53240. /**
  53241. * Is rotation enabled when moving forward?
  53242. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53243. */
  53244. get rotationEnabled(): boolean;
  53245. /**
  53246. * Sets wether rotation is enabled or not
  53247. * @param enabled is rotation enabled when teleportation is shown
  53248. */
  53249. set rotationEnabled(enabled: boolean);
  53250. /**
  53251. * Exposes the currently set teleportation target mesh.
  53252. */
  53253. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53254. /**
  53255. * constructs a new anchor system
  53256. * @param _xrSessionManager an instance of WebXRSessionManager
  53257. * @param _options configuration object for this feature
  53258. */
  53259. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53260. /**
  53261. * Get the snapPointsOnly flag
  53262. */
  53263. get snapPointsOnly(): boolean;
  53264. /**
  53265. * Sets the snapPointsOnly flag
  53266. * @param snapToPoints should teleportation be exclusively to snap points
  53267. */
  53268. set snapPointsOnly(snapToPoints: boolean);
  53269. /**
  53270. * Add a new mesh to the floor meshes array
  53271. * @param mesh the mesh to use as floor mesh
  53272. */
  53273. addFloorMesh(mesh: AbstractMesh): void;
  53274. /**
  53275. * Add a new snap-to point to fix teleportation to this position
  53276. * @param newSnapPoint The new Snap-To point
  53277. */
  53278. addSnapPoint(newSnapPoint: Vector3): void;
  53279. attach(): boolean;
  53280. detach(): boolean;
  53281. dispose(): void;
  53282. /**
  53283. * Remove a mesh from the floor meshes array
  53284. * @param mesh the mesh to remove
  53285. */
  53286. removeFloorMesh(mesh: AbstractMesh): void;
  53287. /**
  53288. * Remove a mesh from the floor meshes array using its name
  53289. * @param name the mesh name to remove
  53290. */
  53291. removeFloorMeshByName(name: string): void;
  53292. /**
  53293. * 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
  53294. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53295. * @returns was the point found and removed or not
  53296. */
  53297. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53298. /**
  53299. * This function sets a selection feature that will be disabled when
  53300. * the forward ray is shown and will be reattached when hidden.
  53301. * This is used to remove the selection rays when moving.
  53302. * @param selectionFeature the feature to disable when forward movement is enabled
  53303. */
  53304. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53305. protected _onXRFrame(_xrFrame: XRFrame): void;
  53306. private _attachController;
  53307. private _createDefaultTargetMesh;
  53308. private _detachController;
  53309. private _findClosestSnapPointWithRadius;
  53310. private _setTargetMeshPosition;
  53311. private _setTargetMeshVisibility;
  53312. private _showParabolicPath;
  53313. private _teleportForward;
  53314. }
  53315. }
  53316. declare module BABYLON {
  53317. /**
  53318. * Options for the default xr helper
  53319. */
  53320. export class WebXRDefaultExperienceOptions {
  53321. /**
  53322. * Enable or disable default UI to enter XR
  53323. */
  53324. disableDefaultUI?: boolean;
  53325. /**
  53326. * Should teleportation not initialize. defaults to false.
  53327. */
  53328. disableTeleportation?: boolean;
  53329. /**
  53330. * Floor meshes that will be used for teleport
  53331. */
  53332. floorMeshes?: Array<AbstractMesh>;
  53333. /**
  53334. * If set to true, the first frame will not be used to reset position
  53335. * The first frame is mainly used when copying transformation from the old camera
  53336. * Mainly used in AR
  53337. */
  53338. ignoreNativeCameraTransformation?: boolean;
  53339. /**
  53340. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53341. */
  53342. inputOptions?: IWebXRInputOptions;
  53343. /**
  53344. * optional configuration for the output canvas
  53345. */
  53346. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53347. /**
  53348. * optional UI options. This can be used among other to change session mode and reference space type
  53349. */
  53350. uiOptions?: WebXREnterExitUIOptions;
  53351. /**
  53352. * When loading teleportation and pointer select, use stable versions instead of latest.
  53353. */
  53354. useStablePlugins?: boolean;
  53355. /**
  53356. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53357. */
  53358. renderingGroupId?: number;
  53359. /**
  53360. * A list of optional features to init the session with
  53361. * If set to true, all features we support will be added
  53362. */
  53363. optionalFeatures?: boolean | string[];
  53364. }
  53365. /**
  53366. * Default experience which provides a similar setup to the previous webVRExperience
  53367. */
  53368. export class WebXRDefaultExperience {
  53369. /**
  53370. * Base experience
  53371. */
  53372. baseExperience: WebXRExperienceHelper;
  53373. /**
  53374. * Enables ui for entering/exiting xr
  53375. */
  53376. enterExitUI: WebXREnterExitUI;
  53377. /**
  53378. * Input experience extension
  53379. */
  53380. input: WebXRInput;
  53381. /**
  53382. * Enables laser pointer and selection
  53383. */
  53384. pointerSelection: WebXRControllerPointerSelection;
  53385. /**
  53386. * Default target xr should render to
  53387. */
  53388. renderTarget: WebXRRenderTarget;
  53389. /**
  53390. * Enables teleportation
  53391. */
  53392. teleportation: WebXRMotionControllerTeleportation;
  53393. private constructor();
  53394. /**
  53395. * Creates the default xr experience
  53396. * @param scene scene
  53397. * @param options options for basic configuration
  53398. * @returns resulting WebXRDefaultExperience
  53399. */
  53400. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53401. /**
  53402. * DIsposes of the experience helper
  53403. */
  53404. dispose(): void;
  53405. }
  53406. }
  53407. declare module BABYLON {
  53408. /**
  53409. * Options to modify the vr teleportation behavior.
  53410. */
  53411. export interface VRTeleportationOptions {
  53412. /**
  53413. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53414. */
  53415. floorMeshName?: string;
  53416. /**
  53417. * A list of meshes to be used as the teleportation floor. (default: empty)
  53418. */
  53419. floorMeshes?: Mesh[];
  53420. /**
  53421. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53422. */
  53423. teleportationMode?: number;
  53424. /**
  53425. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53426. */
  53427. teleportationTime?: number;
  53428. /**
  53429. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53430. */
  53431. teleportationSpeed?: number;
  53432. /**
  53433. * The easing function used in the animation or null for Linear. (default CircleEase)
  53434. */
  53435. easingFunction?: EasingFunction;
  53436. }
  53437. /**
  53438. * Options to modify the vr experience helper's behavior.
  53439. */
  53440. export interface VRExperienceHelperOptions extends WebVROptions {
  53441. /**
  53442. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53443. */
  53444. createDeviceOrientationCamera?: boolean;
  53445. /**
  53446. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53447. */
  53448. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53449. /**
  53450. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53451. */
  53452. laserToggle?: boolean;
  53453. /**
  53454. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53455. */
  53456. floorMeshes?: Mesh[];
  53457. /**
  53458. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53459. */
  53460. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53461. /**
  53462. * Defines if WebXR should be used instead of WebVR (if available)
  53463. */
  53464. useXR?: boolean;
  53465. }
  53466. /**
  53467. * Event containing information after VR has been entered
  53468. */
  53469. export class OnAfterEnteringVRObservableEvent {
  53470. /**
  53471. * If entering vr was successful
  53472. */
  53473. success: boolean;
  53474. }
  53475. /**
  53476. * Helps to quickly add VR support to an existing scene.
  53477. * See https://doc.babylonjs.com/how_to/webvr_helper
  53478. */
  53479. export class VRExperienceHelper {
  53480. /** Options to modify the vr experience helper's behavior. */
  53481. webVROptions: VRExperienceHelperOptions;
  53482. private _scene;
  53483. private _position;
  53484. private _btnVR;
  53485. private _btnVRDisplayed;
  53486. private _webVRsupported;
  53487. private _webVRready;
  53488. private _webVRrequesting;
  53489. private _webVRpresenting;
  53490. private _hasEnteredVR;
  53491. private _fullscreenVRpresenting;
  53492. private _inputElement;
  53493. private _webVRCamera;
  53494. private _vrDeviceOrientationCamera;
  53495. private _deviceOrientationCamera;
  53496. private _existingCamera;
  53497. private _onKeyDown;
  53498. private _onVrDisplayPresentChange;
  53499. private _onVRDisplayChanged;
  53500. private _onVRRequestPresentStart;
  53501. private _onVRRequestPresentComplete;
  53502. /**
  53503. * 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)
  53504. */
  53505. enableGazeEvenWhenNoPointerLock: boolean;
  53506. /**
  53507. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53508. */
  53509. exitVROnDoubleTap: boolean;
  53510. /**
  53511. * Observable raised right before entering VR.
  53512. */
  53513. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53514. /**
  53515. * Observable raised when entering VR has completed.
  53516. */
  53517. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53518. /**
  53519. * Observable raised when exiting VR.
  53520. */
  53521. onExitingVRObservable: Observable<VRExperienceHelper>;
  53522. /**
  53523. * Observable raised when controller mesh is loaded.
  53524. */
  53525. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53526. /** Return this.onEnteringVRObservable
  53527. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53528. */
  53529. get onEnteringVR(): Observable<VRExperienceHelper>;
  53530. /** Return this.onExitingVRObservable
  53531. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53532. */
  53533. get onExitingVR(): Observable<VRExperienceHelper>;
  53534. /** Return this.onControllerMeshLoadedObservable
  53535. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53536. */
  53537. get onControllerMeshLoaded(): Observable<WebVRController>;
  53538. private _rayLength;
  53539. private _useCustomVRButton;
  53540. private _teleportationRequested;
  53541. private _teleportActive;
  53542. private _floorMeshName;
  53543. private _floorMeshesCollection;
  53544. private _teleportationMode;
  53545. private _teleportationTime;
  53546. private _teleportationSpeed;
  53547. private _teleportationEasing;
  53548. private _rotationAllowed;
  53549. private _teleportBackwardsVector;
  53550. private _teleportationTarget;
  53551. private _isDefaultTeleportationTarget;
  53552. private _postProcessMove;
  53553. private _teleportationFillColor;
  53554. private _teleportationBorderColor;
  53555. private _rotationAngle;
  53556. private _haloCenter;
  53557. private _cameraGazer;
  53558. private _padSensibilityUp;
  53559. private _padSensibilityDown;
  53560. private _leftController;
  53561. private _rightController;
  53562. private _gazeColor;
  53563. private _laserColor;
  53564. private _pickedLaserColor;
  53565. private _pickedGazeColor;
  53566. /**
  53567. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53568. */
  53569. onNewMeshSelected: Observable<AbstractMesh>;
  53570. /**
  53571. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53572. * This observable will provide the mesh and the controller used to select the mesh
  53573. */
  53574. onMeshSelectedWithController: Observable<{
  53575. mesh: AbstractMesh;
  53576. controller: WebVRController;
  53577. }>;
  53578. /**
  53579. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53580. */
  53581. onNewMeshPicked: Observable<PickingInfo>;
  53582. private _circleEase;
  53583. /**
  53584. * Observable raised before camera teleportation
  53585. */
  53586. onBeforeCameraTeleport: Observable<Vector3>;
  53587. /**
  53588. * Observable raised after camera teleportation
  53589. */
  53590. onAfterCameraTeleport: Observable<Vector3>;
  53591. /**
  53592. * Observable raised when current selected mesh gets unselected
  53593. */
  53594. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53595. private _raySelectionPredicate;
  53596. /**
  53597. * To be optionaly changed by user to define custom ray selection
  53598. */
  53599. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53600. /**
  53601. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53602. */
  53603. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53604. /**
  53605. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53606. */
  53607. teleportationEnabled: boolean;
  53608. private _defaultHeight;
  53609. private _teleportationInitialized;
  53610. private _interactionsEnabled;
  53611. private _interactionsRequested;
  53612. private _displayGaze;
  53613. private _displayLaserPointer;
  53614. /**
  53615. * The mesh used to display where the user is going to teleport.
  53616. */
  53617. get teleportationTarget(): Mesh;
  53618. /**
  53619. * Sets the mesh to be used to display where the user is going to teleport.
  53620. */
  53621. set teleportationTarget(value: Mesh);
  53622. /**
  53623. * 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
  53624. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53625. * See https://doc.babylonjs.com/resources/baking_transformations
  53626. */
  53627. get gazeTrackerMesh(): Mesh;
  53628. set gazeTrackerMesh(value: Mesh);
  53629. /**
  53630. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53631. */
  53632. updateGazeTrackerScale: boolean;
  53633. /**
  53634. * If the gaze trackers color should be updated when selecting meshes
  53635. */
  53636. updateGazeTrackerColor: boolean;
  53637. /**
  53638. * If the controller laser color should be updated when selecting meshes
  53639. */
  53640. updateControllerLaserColor: boolean;
  53641. /**
  53642. * The gaze tracking mesh corresponding to the left controller
  53643. */
  53644. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53645. /**
  53646. * The gaze tracking mesh corresponding to the right controller
  53647. */
  53648. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53649. /**
  53650. * If the ray of the gaze should be displayed.
  53651. */
  53652. get displayGaze(): boolean;
  53653. /**
  53654. * Sets if the ray of the gaze should be displayed.
  53655. */
  53656. set displayGaze(value: boolean);
  53657. /**
  53658. * If the ray of the LaserPointer should be displayed.
  53659. */
  53660. get displayLaserPointer(): boolean;
  53661. /**
  53662. * Sets if the ray of the LaserPointer should be displayed.
  53663. */
  53664. set displayLaserPointer(value: boolean);
  53665. /**
  53666. * The deviceOrientationCamera used as the camera when not in VR.
  53667. */
  53668. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53669. /**
  53670. * Based on the current WebVR support, returns the current VR camera used.
  53671. */
  53672. get currentVRCamera(): Nullable<Camera>;
  53673. /**
  53674. * The webVRCamera which is used when in VR.
  53675. */
  53676. get webVRCamera(): WebVRFreeCamera;
  53677. /**
  53678. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53679. */
  53680. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53681. /**
  53682. * The html button that is used to trigger entering into VR.
  53683. */
  53684. get vrButton(): Nullable<HTMLButtonElement>;
  53685. private get _teleportationRequestInitiated();
  53686. /**
  53687. * Defines whether or not Pointer lock should be requested when switching to
  53688. * full screen.
  53689. */
  53690. requestPointerLockOnFullScreen: boolean;
  53691. /**
  53692. * If asking to force XR, this will be populated with the default xr experience
  53693. */
  53694. xr: WebXRDefaultExperience;
  53695. /**
  53696. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53697. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53698. */
  53699. xrTestDone: boolean;
  53700. /**
  53701. * Instantiates a VRExperienceHelper.
  53702. * Helps to quickly add VR support to an existing scene.
  53703. * @param scene The scene the VRExperienceHelper belongs to.
  53704. * @param webVROptions Options to modify the vr experience helper's behavior.
  53705. */
  53706. constructor(scene: Scene,
  53707. /** Options to modify the vr experience helper's behavior. */
  53708. webVROptions?: VRExperienceHelperOptions);
  53709. private completeVRInit;
  53710. private _onDefaultMeshLoaded;
  53711. private _onResize;
  53712. private _onFullscreenChange;
  53713. /**
  53714. * Gets a value indicating if we are currently in VR mode.
  53715. */
  53716. get isInVRMode(): boolean;
  53717. private onVrDisplayPresentChange;
  53718. private onVRDisplayChanged;
  53719. private moveButtonToBottomRight;
  53720. private displayVRButton;
  53721. private updateButtonVisibility;
  53722. private _cachedAngularSensibility;
  53723. /**
  53724. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53725. * Otherwise, will use the fullscreen API.
  53726. */
  53727. enterVR(): void;
  53728. /**
  53729. * Attempt to exit VR, or fullscreen.
  53730. */
  53731. exitVR(): void;
  53732. /**
  53733. * The position of the vr experience helper.
  53734. */
  53735. get position(): Vector3;
  53736. /**
  53737. * Sets the position of the vr experience helper.
  53738. */
  53739. set position(value: Vector3);
  53740. /**
  53741. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53742. */
  53743. enableInteractions(): void;
  53744. private get _noControllerIsActive();
  53745. private beforeRender;
  53746. private _isTeleportationFloor;
  53747. /**
  53748. * Adds a floor mesh to be used for teleportation.
  53749. * @param floorMesh the mesh to be used for teleportation.
  53750. */
  53751. addFloorMesh(floorMesh: Mesh): void;
  53752. /**
  53753. * Removes a floor mesh from being used for teleportation.
  53754. * @param floorMesh the mesh to be removed.
  53755. */
  53756. removeFloorMesh(floorMesh: Mesh): void;
  53757. /**
  53758. * Enables interactions and teleportation using the VR controllers and gaze.
  53759. * @param vrTeleportationOptions options to modify teleportation behavior.
  53760. */
  53761. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53762. private _onNewGamepadConnected;
  53763. private _tryEnableInteractionOnController;
  53764. private _onNewGamepadDisconnected;
  53765. private _enableInteractionOnController;
  53766. private _checkTeleportWithRay;
  53767. private _checkRotate;
  53768. private _checkTeleportBackwards;
  53769. private _enableTeleportationOnController;
  53770. private _createTeleportationCircles;
  53771. private _displayTeleportationTarget;
  53772. private _hideTeleportationTarget;
  53773. private _rotateCamera;
  53774. private _moveTeleportationSelectorTo;
  53775. private _workingVector;
  53776. private _workingQuaternion;
  53777. private _workingMatrix;
  53778. /**
  53779. * Time Constant Teleportation Mode
  53780. */
  53781. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53782. /**
  53783. * Speed Constant Teleportation Mode
  53784. */
  53785. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53786. /**
  53787. * Teleports the users feet to the desired location
  53788. * @param location The location where the user's feet should be placed
  53789. */
  53790. teleportCamera(location: Vector3): void;
  53791. private _convertNormalToDirectionOfRay;
  53792. private _castRayAndSelectObject;
  53793. private _notifySelectedMeshUnselected;
  53794. /**
  53795. * Permanently set new colors for the laser pointer
  53796. * @param color the new laser color
  53797. * @param pickedColor the new laser color when picked mesh detected
  53798. */
  53799. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53800. /**
  53801. * Set lighting enabled / disabled on the laser pointer of both controllers
  53802. * @param enabled should the lighting be enabled on the laser pointer
  53803. */
  53804. setLaserLightingState(enabled?: boolean): void;
  53805. /**
  53806. * Permanently set new colors for the gaze pointer
  53807. * @param color the new gaze color
  53808. * @param pickedColor the new gaze color when picked mesh detected
  53809. */
  53810. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53811. /**
  53812. * Sets the color of the laser ray from the vr controllers.
  53813. * @param color new color for the ray.
  53814. */
  53815. changeLaserColor(color: Color3): void;
  53816. /**
  53817. * Sets the color of the ray from the vr headsets gaze.
  53818. * @param color new color for the ray.
  53819. */
  53820. changeGazeColor(color: Color3): void;
  53821. /**
  53822. * Exits VR and disposes of the vr experience helper
  53823. */
  53824. dispose(): void;
  53825. /**
  53826. * Gets the name of the VRExperienceHelper class
  53827. * @returns "VRExperienceHelper"
  53828. */
  53829. getClassName(): string;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. /**
  53834. * Contains an array of blocks representing the octree
  53835. */
  53836. export interface IOctreeContainer<T> {
  53837. /**
  53838. * Blocks within the octree
  53839. */
  53840. blocks: Array<OctreeBlock<T>>;
  53841. }
  53842. /**
  53843. * Class used to store a cell in an octree
  53844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53845. */
  53846. export class OctreeBlock<T> {
  53847. /**
  53848. * Gets the content of the current block
  53849. */
  53850. entries: T[];
  53851. /**
  53852. * Gets the list of block children
  53853. */
  53854. blocks: Array<OctreeBlock<T>>;
  53855. private _depth;
  53856. private _maxDepth;
  53857. private _capacity;
  53858. private _minPoint;
  53859. private _maxPoint;
  53860. private _boundingVectors;
  53861. private _creationFunc;
  53862. /**
  53863. * Creates a new block
  53864. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53865. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53866. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53867. * @param depth defines the current depth of this block in the octree
  53868. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53869. * @param creationFunc defines a callback to call when an element is added to the block
  53870. */
  53871. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53872. /**
  53873. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53874. */
  53875. get capacity(): number;
  53876. /**
  53877. * Gets the minimum vector (in world space) of the block's bounding box
  53878. */
  53879. get minPoint(): Vector3;
  53880. /**
  53881. * Gets the maximum vector (in world space) of the block's bounding box
  53882. */
  53883. get maxPoint(): Vector3;
  53884. /**
  53885. * Add a new element to this block
  53886. * @param entry defines the element to add
  53887. */
  53888. addEntry(entry: T): void;
  53889. /**
  53890. * Remove an element from this block
  53891. * @param entry defines the element to remove
  53892. */
  53893. removeEntry(entry: T): void;
  53894. /**
  53895. * Add an array of elements to this block
  53896. * @param entries defines the array of elements to add
  53897. */
  53898. addEntries(entries: T[]): void;
  53899. /**
  53900. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53901. * @param frustumPlanes defines the frustum planes to test
  53902. * @param selection defines the array to store current content if selection is positive
  53903. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53904. */
  53905. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53906. /**
  53907. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53908. * @param sphereCenter defines the bounding sphere center
  53909. * @param sphereRadius defines the bounding sphere radius
  53910. * @param selection defines the array to store current content if selection is positive
  53911. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53912. */
  53913. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53914. /**
  53915. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53916. * @param ray defines the ray to test with
  53917. * @param selection defines the array to store current content if selection is positive
  53918. */
  53919. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53920. /**
  53921. * Subdivide the content into child blocks (this block will then be empty)
  53922. */
  53923. createInnerBlocks(): void;
  53924. /**
  53925. * @hidden
  53926. */
  53927. 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;
  53928. }
  53929. }
  53930. declare module BABYLON {
  53931. /**
  53932. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53933. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53934. */
  53935. export class Octree<T> {
  53936. /** 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.) */
  53937. maxDepth: number;
  53938. /**
  53939. * Blocks within the octree containing objects
  53940. */
  53941. blocks: Array<OctreeBlock<T>>;
  53942. /**
  53943. * Content stored in the octree
  53944. */
  53945. dynamicContent: T[];
  53946. private _maxBlockCapacity;
  53947. private _selectionContent;
  53948. private _creationFunc;
  53949. /**
  53950. * Creates a octree
  53951. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53952. * @param creationFunc function to be used to instatiate the octree
  53953. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53954. * @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.)
  53955. */
  53956. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53957. /** 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.) */
  53958. maxDepth?: number);
  53959. /**
  53960. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53961. * @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);
  53962. * @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);
  53963. * @param entries meshes to be added to the octree blocks
  53964. */
  53965. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53966. /**
  53967. * Adds a mesh to the octree
  53968. * @param entry Mesh to add to the octree
  53969. */
  53970. addMesh(entry: T): void;
  53971. /**
  53972. * Remove an element from the octree
  53973. * @param entry defines the element to remove
  53974. */
  53975. removeMesh(entry: T): void;
  53976. /**
  53977. * Selects an array of meshes within the frustum
  53978. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53979. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53980. * @returns array of meshes within the frustum
  53981. */
  53982. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53983. /**
  53984. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53985. * @param sphereCenter defines the bounding sphere center
  53986. * @param sphereRadius defines the bounding sphere radius
  53987. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53988. * @returns an array of objects that intersect the sphere
  53989. */
  53990. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53991. /**
  53992. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53993. * @param ray defines the ray to test with
  53994. * @returns array of intersected objects
  53995. */
  53996. intersectsRay(ray: Ray): SmartArray<T>;
  53997. /**
  53998. * Adds a mesh into the octree block if it intersects the block
  53999. */
  54000. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  54001. /**
  54002. * Adds a submesh into the octree block if it intersects the block
  54003. */
  54004. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54005. }
  54006. }
  54007. declare module BABYLON {
  54008. interface Scene {
  54009. /**
  54010. * @hidden
  54011. * Backing Filed
  54012. */
  54013. _selectionOctree: Octree<AbstractMesh>;
  54014. /**
  54015. * Gets the octree used to boost mesh selection (picking)
  54016. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54017. */
  54018. selectionOctree: Octree<AbstractMesh>;
  54019. /**
  54020. * Creates or updates the octree used to boost selection (picking)
  54021. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54022. * @param maxCapacity defines the maximum capacity per leaf
  54023. * @param maxDepth defines the maximum depth of the octree
  54024. * @returns an octree of AbstractMesh
  54025. */
  54026. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54027. }
  54028. interface AbstractMesh {
  54029. /**
  54030. * @hidden
  54031. * Backing Field
  54032. */
  54033. _submeshesOctree: Octree<SubMesh>;
  54034. /**
  54035. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54036. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54037. * @param maxCapacity defines the maximum size of each block (64 by default)
  54038. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54039. * @returns the new octree
  54040. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54041. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54042. */
  54043. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54044. }
  54045. /**
  54046. * Defines the octree scene component responsible to manage any octrees
  54047. * in a given scene.
  54048. */
  54049. export class OctreeSceneComponent {
  54050. /**
  54051. * The component name help to identify the component in the list of scene components.
  54052. */
  54053. readonly name: string;
  54054. /**
  54055. * The scene the component belongs to.
  54056. */
  54057. scene: Scene;
  54058. /**
  54059. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54060. */
  54061. readonly checksIsEnabled: boolean;
  54062. /**
  54063. * Creates a new instance of the component for the given scene
  54064. * @param scene Defines the scene to register the component in
  54065. */
  54066. constructor(scene: Scene);
  54067. /**
  54068. * Registers the component in a given scene
  54069. */
  54070. register(): void;
  54071. /**
  54072. * Return the list of active meshes
  54073. * @returns the list of active meshes
  54074. */
  54075. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54076. /**
  54077. * Return the list of active sub meshes
  54078. * @param mesh The mesh to get the candidates sub meshes from
  54079. * @returns the list of active sub meshes
  54080. */
  54081. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54082. private _tempRay;
  54083. /**
  54084. * Return the list of sub meshes intersecting with a given local ray
  54085. * @param mesh defines the mesh to find the submesh for
  54086. * @param localRay defines the ray in local space
  54087. * @returns the list of intersecting sub meshes
  54088. */
  54089. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54090. /**
  54091. * Return the list of sub meshes colliding with a collider
  54092. * @param mesh defines the mesh to find the submesh for
  54093. * @param collider defines the collider to evaluate the collision against
  54094. * @returns the list of colliding sub meshes
  54095. */
  54096. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54097. /**
  54098. * Rebuilds the elements related to this component in case of
  54099. * context lost for instance.
  54100. */
  54101. rebuild(): void;
  54102. /**
  54103. * Disposes the component and the associated ressources.
  54104. */
  54105. dispose(): void;
  54106. }
  54107. }
  54108. declare module BABYLON {
  54109. /**
  54110. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54111. */
  54112. export interface GizmoAxisCache {
  54113. /** Mesh used to runder the Gizmo */
  54114. gizmoMeshes: Mesh[];
  54115. /** Mesh used to detect user interaction with Gizmo */
  54116. colliderMeshes: Mesh[];
  54117. /** Material used to inicate color of gizmo mesh */
  54118. material: StandardMaterial;
  54119. /** Material used to inicate hover state of the Gizmo */
  54120. hoverMaterial: StandardMaterial;
  54121. /** Material used to inicate disabled state of the Gizmo */
  54122. disableMaterial: StandardMaterial;
  54123. /** Used to indicate Active state of the Gizmo */
  54124. active: boolean;
  54125. }
  54126. /**
  54127. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54128. */
  54129. export class Gizmo implements IDisposable {
  54130. /** The utility layer the gizmo will be added to */
  54131. gizmoLayer: UtilityLayerRenderer;
  54132. /**
  54133. * The root mesh of the gizmo
  54134. */
  54135. _rootMesh: Mesh;
  54136. private _attachedMesh;
  54137. private _attachedNode;
  54138. /**
  54139. * Ratio for the scale of the gizmo (Default: 1)
  54140. */
  54141. protected _scaleRatio: number;
  54142. /**
  54143. * boolean updated by pointermove when a gizmo mesh is hovered
  54144. */
  54145. protected _isHovered: boolean;
  54146. /**
  54147. * Ratio for the scale of the gizmo (Default: 1)
  54148. */
  54149. set scaleRatio(value: number);
  54150. get scaleRatio(): number;
  54151. /**
  54152. * True when the mouse pointer is hovered a gizmo mesh
  54153. */
  54154. get isHovered(): boolean;
  54155. /**
  54156. * If a custom mesh has been set (Default: false)
  54157. */
  54158. protected _customMeshSet: boolean;
  54159. /**
  54160. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54161. * * When set, interactions will be enabled
  54162. */
  54163. get attachedMesh(): Nullable<AbstractMesh>;
  54164. set attachedMesh(value: Nullable<AbstractMesh>);
  54165. /**
  54166. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54167. * * When set, interactions will be enabled
  54168. */
  54169. get attachedNode(): Nullable<Node>;
  54170. set attachedNode(value: Nullable<Node>);
  54171. /**
  54172. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54173. * @param mesh The mesh to replace the default mesh of the gizmo
  54174. */
  54175. setCustomMesh(mesh: Mesh): void;
  54176. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54177. /**
  54178. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54179. */
  54180. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54181. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54182. /**
  54183. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54184. */
  54185. updateGizmoPositionToMatchAttachedMesh: boolean;
  54186. /**
  54187. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54188. */
  54189. updateScale: boolean;
  54190. protected _interactionsEnabled: boolean;
  54191. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54192. private _beforeRenderObserver;
  54193. private _tempQuaternion;
  54194. private _tempVector;
  54195. private _tempVector2;
  54196. private _tempMatrix1;
  54197. private _tempMatrix2;
  54198. private _rightHandtoLeftHandMatrix;
  54199. /**
  54200. * Creates a gizmo
  54201. * @param gizmoLayer The utility layer the gizmo will be added to
  54202. */
  54203. constructor(
  54204. /** The utility layer the gizmo will be added to */
  54205. gizmoLayer?: UtilityLayerRenderer);
  54206. /**
  54207. * Updates the gizmo to match the attached mesh's position/rotation
  54208. */
  54209. protected _update(): void;
  54210. /**
  54211. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54212. * @param value Node, TransformNode or mesh
  54213. */
  54214. protected _matrixChanged(): void;
  54215. /**
  54216. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54217. * @param gizmoLayer The utility layer the gizmo will be added to
  54218. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54219. * @returns {Observer<PointerInfo>} pointerObserver
  54220. */
  54221. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54222. /**
  54223. * Disposes of the gizmo
  54224. */
  54225. dispose(): void;
  54226. }
  54227. }
  54228. declare module BABYLON {
  54229. /**
  54230. * Single plane drag gizmo
  54231. */
  54232. export class PlaneDragGizmo extends Gizmo {
  54233. /**
  54234. * Drag behavior responsible for the gizmos dragging interactions
  54235. */
  54236. dragBehavior: PointerDragBehavior;
  54237. private _pointerObserver;
  54238. /**
  54239. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54240. */
  54241. snapDistance: number;
  54242. /**
  54243. * Event that fires each time the gizmo snaps to a new location.
  54244. * * snapDistance is the the change in distance
  54245. */
  54246. onSnapObservable: Observable<{
  54247. snapDistance: number;
  54248. }>;
  54249. private _gizmoMesh;
  54250. private _coloredMaterial;
  54251. private _hoverMaterial;
  54252. private _disableMaterial;
  54253. private _isEnabled;
  54254. private _parent;
  54255. private _dragging;
  54256. /** @hidden */
  54257. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54258. /**
  54259. * Creates a PlaneDragGizmo
  54260. * @param gizmoLayer The utility layer the gizmo will be added to
  54261. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54262. * @param color The color of the gizmo
  54263. */
  54264. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54265. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54266. /**
  54267. * If the gizmo is enabled
  54268. */
  54269. set isEnabled(value: boolean);
  54270. get isEnabled(): boolean;
  54271. /**
  54272. * Disposes of the gizmo
  54273. */
  54274. dispose(): void;
  54275. }
  54276. }
  54277. declare module BABYLON {
  54278. /**
  54279. * Single plane rotation gizmo
  54280. */
  54281. export class PlaneRotationGizmo extends Gizmo {
  54282. /**
  54283. * Drag behavior responsible for the gizmos dragging interactions
  54284. */
  54285. dragBehavior: PointerDragBehavior;
  54286. private _pointerObserver;
  54287. /**
  54288. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54289. */
  54290. snapDistance: number;
  54291. /**
  54292. * Event that fires each time the gizmo snaps to a new location.
  54293. * * snapDistance is the the change in distance
  54294. */
  54295. onSnapObservable: Observable<{
  54296. snapDistance: number;
  54297. }>;
  54298. private _isEnabled;
  54299. private _parent;
  54300. private _coloredMaterial;
  54301. private _hoverMaterial;
  54302. private _disableMaterial;
  54303. private _gizmoMesh;
  54304. private _rotationCircle;
  54305. private _dragging;
  54306. private static _CircleConstants;
  54307. /**
  54308. * Creates a PlaneRotationGizmo
  54309. * @param gizmoLayer The utility layer the gizmo will be added to
  54310. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54311. * @param color The color of the gizmo
  54312. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54313. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54314. * @param thickness display gizmo axis thickness
  54315. */
  54316. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54317. /** Create Geometry for Gizmo */
  54318. private _createGizmoMesh;
  54319. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54320. private setupRotationCircle;
  54321. private updateRotationPath;
  54322. private updateRotationCircle;
  54323. /**
  54324. * If the gizmo is enabled
  54325. */
  54326. set isEnabled(value: boolean);
  54327. get isEnabled(): boolean;
  54328. /**
  54329. * Disposes of the gizmo
  54330. */
  54331. dispose(): void;
  54332. }
  54333. }
  54334. declare module BABYLON {
  54335. /**
  54336. * Gizmo that enables rotating a mesh along 3 axis
  54337. */
  54338. export class RotationGizmo extends Gizmo {
  54339. /**
  54340. * Internal gizmo used for interactions on the x axis
  54341. */
  54342. xGizmo: PlaneRotationGizmo;
  54343. /**
  54344. * Internal gizmo used for interactions on the y axis
  54345. */
  54346. yGizmo: PlaneRotationGizmo;
  54347. /**
  54348. * Internal gizmo used for interactions on the z axis
  54349. */
  54350. zGizmo: PlaneRotationGizmo;
  54351. /** Fires an event when any of it's sub gizmos are dragged */
  54352. onDragStartObservable: Observable<unknown>;
  54353. /** Fires an event when any of it's sub gizmos are released from dragging */
  54354. onDragEndObservable: Observable<unknown>;
  54355. private _meshAttached;
  54356. private _nodeAttached;
  54357. private _observables;
  54358. /** Node Caching for quick lookup */
  54359. private _gizmoAxisCache;
  54360. get attachedMesh(): Nullable<AbstractMesh>;
  54361. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54362. get attachedNode(): Nullable<Node>;
  54363. set attachedNode(node: Nullable<Node>);
  54364. protected _checkBillboardTransform(): void;
  54365. /**
  54366. * True when the mouse pointer is hovering a gizmo mesh
  54367. */
  54368. get isHovered(): boolean;
  54369. /**
  54370. * Creates a RotationGizmo
  54371. * @param gizmoLayer The utility layer the gizmo will be added to
  54372. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54373. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54374. * @param thickness display gizmo axis thickness
  54375. */
  54376. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54377. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54378. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54379. /**
  54380. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54381. */
  54382. set snapDistance(value: number);
  54383. get snapDistance(): number;
  54384. /**
  54385. * Ratio for the scale of the gizmo (Default: 1)
  54386. */
  54387. set scaleRatio(value: number);
  54388. get scaleRatio(): number;
  54389. /**
  54390. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54391. * @param mesh Axis gizmo mesh
  54392. * @param cache Gizmo axis definition used for reactive gizmo UI
  54393. */
  54394. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54395. /**
  54396. * Disposes of the gizmo
  54397. */
  54398. dispose(): void;
  54399. /**
  54400. * CustomMeshes are not supported by this gizmo
  54401. * @param mesh The mesh to replace the default mesh of the gizmo
  54402. */
  54403. setCustomMesh(mesh: Mesh): void;
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * Class containing static functions to help procedurally build meshes
  54409. */
  54410. export class PolyhedronBuilder {
  54411. /**
  54412. * Creates a polyhedron mesh
  54413. * * 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
  54414. * * The parameter `size` (positive float, default 1) sets the polygon size
  54415. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54416. * * 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`
  54417. * * 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
  54418. * * 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)`)
  54419. * * 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
  54420. * * 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
  54421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54422. * * 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
  54423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54424. * @param name defines the name of the mesh
  54425. * @param options defines the options used to create the mesh
  54426. * @param scene defines the hosting scene
  54427. * @returns the polyhedron mesh
  54428. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54429. */
  54430. static CreatePolyhedron(name: string, options: {
  54431. type?: number;
  54432. size?: number;
  54433. sizeX?: number;
  54434. sizeY?: number;
  54435. sizeZ?: number;
  54436. custom?: any;
  54437. faceUV?: Vector4[];
  54438. faceColors?: Color4[];
  54439. flat?: boolean;
  54440. updatable?: boolean;
  54441. sideOrientation?: number;
  54442. frontUVs?: Vector4;
  54443. backUVs?: Vector4;
  54444. }, scene?: Nullable<Scene>): Mesh;
  54445. }
  54446. }
  54447. declare module BABYLON {
  54448. /**
  54449. * Class containing static functions to help procedurally build meshes
  54450. */
  54451. export class BoxBuilder {
  54452. /**
  54453. * Creates a box mesh
  54454. * * The parameter `size` sets the size (float) of each box side (default 1)
  54455. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54456. * * 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)
  54457. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54459. * * 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
  54460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54461. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54462. * @param name defines the name of the mesh
  54463. * @param options defines the options used to create the mesh
  54464. * @param scene defines the hosting scene
  54465. * @returns the box mesh
  54466. */
  54467. static CreateBox(name: string, options: {
  54468. size?: number;
  54469. width?: number;
  54470. height?: number;
  54471. depth?: number;
  54472. faceUV?: Vector4[];
  54473. faceColors?: Color4[];
  54474. sideOrientation?: number;
  54475. frontUVs?: Vector4;
  54476. backUVs?: Vector4;
  54477. wrap?: boolean;
  54478. topBaseAt?: number;
  54479. bottomBaseAt?: number;
  54480. updatable?: boolean;
  54481. }, scene?: Nullable<Scene>): Mesh;
  54482. }
  54483. }
  54484. declare module BABYLON {
  54485. /**
  54486. * Single axis scale gizmo
  54487. */
  54488. export class AxisScaleGizmo extends Gizmo {
  54489. /**
  54490. * Drag behavior responsible for the gizmos dragging interactions
  54491. */
  54492. dragBehavior: PointerDragBehavior;
  54493. private _pointerObserver;
  54494. /**
  54495. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54496. */
  54497. snapDistance: number;
  54498. /**
  54499. * Event that fires each time the gizmo snaps to a new location.
  54500. * * snapDistance is the the change in distance
  54501. */
  54502. onSnapObservable: Observable<{
  54503. snapDistance: number;
  54504. }>;
  54505. /**
  54506. * If the scaling operation should be done on all axis (default: false)
  54507. */
  54508. uniformScaling: boolean;
  54509. /**
  54510. * Custom sensitivity value for the drag strength
  54511. */
  54512. sensitivity: number;
  54513. private _isEnabled;
  54514. private _parent;
  54515. private _gizmoMesh;
  54516. private _coloredMaterial;
  54517. private _hoverMaterial;
  54518. private _disableMaterial;
  54519. private _dragging;
  54520. private _tmpVector;
  54521. private _tmpMatrix;
  54522. private _tmpMatrix2;
  54523. /**
  54524. * Creates an AxisScaleGizmo
  54525. * @param gizmoLayer The utility layer the gizmo will be added to
  54526. * @param dragAxis The axis which the gizmo will be able to scale on
  54527. * @param color The color of the gizmo
  54528. * @param thickness display gizmo axis thickness
  54529. */
  54530. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54531. /** Create Geometry for Gizmo */
  54532. private _createGizmoMesh;
  54533. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54534. /**
  54535. * If the gizmo is enabled
  54536. */
  54537. set isEnabled(value: boolean);
  54538. get isEnabled(): boolean;
  54539. /**
  54540. * Disposes of the gizmo
  54541. */
  54542. dispose(): void;
  54543. /**
  54544. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54545. * @param mesh The mesh to replace the default mesh of the gizmo
  54546. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54547. */
  54548. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54549. }
  54550. }
  54551. declare module BABYLON {
  54552. /**
  54553. * Gizmo that enables scaling a mesh along 3 axis
  54554. */
  54555. export class ScaleGizmo extends Gizmo {
  54556. /**
  54557. * Internal gizmo used for interactions on the x axis
  54558. */
  54559. xGizmo: AxisScaleGizmo;
  54560. /**
  54561. * Internal gizmo used for interactions on the y axis
  54562. */
  54563. yGizmo: AxisScaleGizmo;
  54564. /**
  54565. * Internal gizmo used for interactions on the z axis
  54566. */
  54567. zGizmo: AxisScaleGizmo;
  54568. /**
  54569. * Internal gizmo used to scale all axis equally
  54570. */
  54571. uniformScaleGizmo: AxisScaleGizmo;
  54572. private _meshAttached;
  54573. private _nodeAttached;
  54574. private _snapDistance;
  54575. private _uniformScalingMesh;
  54576. private _octahedron;
  54577. private _sensitivity;
  54578. private _coloredMaterial;
  54579. private _hoverMaterial;
  54580. private _disableMaterial;
  54581. private _observables;
  54582. /** Node Caching for quick lookup */
  54583. private _gizmoAxisCache;
  54584. /** Fires an event when any of it's sub gizmos are dragged */
  54585. onDragStartObservable: Observable<unknown>;
  54586. /** Fires an event when any of it's sub gizmos are released from dragging */
  54587. onDragEndObservable: Observable<unknown>;
  54588. get attachedMesh(): Nullable<AbstractMesh>;
  54589. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54590. get attachedNode(): Nullable<Node>;
  54591. set attachedNode(node: Nullable<Node>);
  54592. /**
  54593. * True when the mouse pointer is hovering a gizmo mesh
  54594. */
  54595. get isHovered(): boolean;
  54596. /**
  54597. * Creates a ScaleGizmo
  54598. * @param gizmoLayer The utility layer the gizmo will be added to
  54599. * @param thickness display gizmo axis thickness
  54600. */
  54601. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54602. /** Create Geometry for Gizmo */
  54603. private _createUniformScaleMesh;
  54604. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54605. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54606. /**
  54607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54608. */
  54609. set snapDistance(value: number);
  54610. get snapDistance(): number;
  54611. /**
  54612. * Ratio for the scale of the gizmo (Default: 1)
  54613. */
  54614. set scaleRatio(value: number);
  54615. get scaleRatio(): number;
  54616. /**
  54617. * Sensitivity factor for dragging (Default: 1)
  54618. */
  54619. set sensitivity(value: number);
  54620. get sensitivity(): number;
  54621. /**
  54622. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54623. * @param mesh Axis gizmo mesh
  54624. * @param cache Gizmo axis definition used for reactive gizmo UI
  54625. */
  54626. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54627. /**
  54628. * Disposes of the gizmo
  54629. */
  54630. dispose(): void;
  54631. }
  54632. }
  54633. declare module BABYLON {
  54634. /**
  54635. * Bounding box gizmo
  54636. */
  54637. export class BoundingBoxGizmo extends Gizmo {
  54638. private _lineBoundingBox;
  54639. private _rotateSpheresParent;
  54640. private _scaleBoxesParent;
  54641. private _boundingDimensions;
  54642. private _renderObserver;
  54643. private _pointerObserver;
  54644. private _scaleDragSpeed;
  54645. private _tmpQuaternion;
  54646. private _tmpVector;
  54647. private _tmpRotationMatrix;
  54648. /**
  54649. * 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)
  54650. */
  54651. ignoreChildren: boolean;
  54652. /**
  54653. * 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)
  54654. */
  54655. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54656. /**
  54657. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54658. */
  54659. rotationSphereSize: number;
  54660. /**
  54661. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54662. */
  54663. scaleBoxSize: number;
  54664. /**
  54665. * 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)
  54666. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54667. */
  54668. fixedDragMeshScreenSize: boolean;
  54669. /**
  54670. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54671. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54672. */
  54673. fixedDragMeshBoundsSize: boolean;
  54674. /**
  54675. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54676. */
  54677. fixedDragMeshScreenSizeDistanceFactor: number;
  54678. /**
  54679. * Fired when a rotation sphere or scale box is dragged
  54680. */
  54681. onDragStartObservable: Observable<{}>;
  54682. /**
  54683. * Fired when a scale box is dragged
  54684. */
  54685. onScaleBoxDragObservable: Observable<{}>;
  54686. /**
  54687. * Fired when a scale box drag is ended
  54688. */
  54689. onScaleBoxDragEndObservable: Observable<{}>;
  54690. /**
  54691. * Fired when a rotation sphere is dragged
  54692. */
  54693. onRotationSphereDragObservable: Observable<{}>;
  54694. /**
  54695. * Fired when a rotation sphere drag is ended
  54696. */
  54697. onRotationSphereDragEndObservable: Observable<{}>;
  54698. /**
  54699. * 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)
  54700. */
  54701. scalePivot: Nullable<Vector3>;
  54702. /**
  54703. * Mesh used as a pivot to rotate the attached node
  54704. */
  54705. private _anchorMesh;
  54706. private _existingMeshScale;
  54707. private _dragMesh;
  54708. private pointerDragBehavior;
  54709. private coloredMaterial;
  54710. private hoverColoredMaterial;
  54711. /**
  54712. * Sets the color of the bounding box gizmo
  54713. * @param color the color to set
  54714. */
  54715. setColor(color: Color3): void;
  54716. /**
  54717. * Creates an BoundingBoxGizmo
  54718. * @param gizmoLayer The utility layer the gizmo will be added to
  54719. * @param color The color of the gizmo
  54720. */
  54721. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54722. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54723. private _selectNode;
  54724. /**
  54725. * Updates the bounding box information for the Gizmo
  54726. */
  54727. updateBoundingBox(): void;
  54728. private _updateRotationSpheres;
  54729. private _updateScaleBoxes;
  54730. /**
  54731. * Enables rotation on the specified axis and disables rotation on the others
  54732. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54733. */
  54734. setEnabledRotationAxis(axis: string): void;
  54735. /**
  54736. * Enables/disables scaling
  54737. * @param enable if scaling should be enabled
  54738. * @param homogeneousScaling defines if scaling should only be homogeneous
  54739. */
  54740. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54741. private _updateDummy;
  54742. /**
  54743. * Enables a pointer drag behavior on the bounding box of the gizmo
  54744. */
  54745. enableDragBehavior(): void;
  54746. /**
  54747. * Disposes of the gizmo
  54748. */
  54749. dispose(): void;
  54750. /**
  54751. * 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)
  54752. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54753. * @returns the bounding box mesh with the passed in mesh as a child
  54754. */
  54755. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54756. /**
  54757. * CustomMeshes are not supported by this gizmo
  54758. * @param mesh The mesh to replace the default mesh of the gizmo
  54759. */
  54760. setCustomMesh(mesh: Mesh): void;
  54761. }
  54762. }
  54763. declare module BABYLON {
  54764. /**
  54765. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54766. */
  54767. export class GizmoManager implements IDisposable {
  54768. private scene;
  54769. /**
  54770. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54771. */
  54772. gizmos: {
  54773. positionGizmo: Nullable<PositionGizmo>;
  54774. rotationGizmo: Nullable<RotationGizmo>;
  54775. scaleGizmo: Nullable<ScaleGizmo>;
  54776. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54777. };
  54778. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54779. clearGizmoOnEmptyPointerEvent: boolean;
  54780. /** Fires an event when the manager is attached to a mesh */
  54781. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54782. /** Fires an event when the manager is attached to a node */
  54783. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54784. private _gizmosEnabled;
  54785. private _pointerObservers;
  54786. private _attachedMesh;
  54787. private _attachedNode;
  54788. private _boundingBoxColor;
  54789. private _defaultUtilityLayer;
  54790. private _defaultKeepDepthUtilityLayer;
  54791. private _thickness;
  54792. /** Node Caching for quick lookup */
  54793. private _gizmoAxisCache;
  54794. /**
  54795. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54796. */
  54797. boundingBoxDragBehavior: SixDofDragBehavior;
  54798. /**
  54799. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54800. */
  54801. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54802. /**
  54803. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54804. */
  54805. attachableNodes: Nullable<Array<Node>>;
  54806. /**
  54807. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54808. */
  54809. usePointerToAttachGizmos: boolean;
  54810. /**
  54811. * Utility layer that the bounding box gizmo belongs to
  54812. */
  54813. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54814. /**
  54815. * Utility layer that all gizmos besides bounding box belong to
  54816. */
  54817. get utilityLayer(): UtilityLayerRenderer;
  54818. /**
  54819. * True when the mouse pointer is hovering a gizmo mesh
  54820. */
  54821. get isHovered(): boolean;
  54822. /**
  54823. * Instatiates a gizmo manager
  54824. * @param scene the scene to overlay the gizmos on top of
  54825. * @param thickness display gizmo axis thickness
  54826. * @param utilityLayer the layer where gizmos are rendered
  54827. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54828. */
  54829. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54830. /**
  54831. * Subscribes to pointer down events, for attaching and detaching mesh
  54832. * @param scene The sceme layer the observer will be added to
  54833. */
  54834. private _attachToMeshPointerObserver;
  54835. /**
  54836. * Attaches a set of gizmos to the specified mesh
  54837. * @param mesh The mesh the gizmo's should be attached to
  54838. */
  54839. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54840. /**
  54841. * Attaches a set of gizmos to the specified node
  54842. * @param node The node the gizmo's should be attached to
  54843. */
  54844. attachToNode(node: Nullable<Node>): void;
  54845. /**
  54846. * If the position gizmo is enabled
  54847. */
  54848. set positionGizmoEnabled(value: boolean);
  54849. get positionGizmoEnabled(): boolean;
  54850. /**
  54851. * If the rotation gizmo is enabled
  54852. */
  54853. set rotationGizmoEnabled(value: boolean);
  54854. get rotationGizmoEnabled(): boolean;
  54855. /**
  54856. * If the scale gizmo is enabled
  54857. */
  54858. set scaleGizmoEnabled(value: boolean);
  54859. get scaleGizmoEnabled(): boolean;
  54860. /**
  54861. * If the boundingBox gizmo is enabled
  54862. */
  54863. set boundingBoxGizmoEnabled(value: boolean);
  54864. get boundingBoxGizmoEnabled(): boolean;
  54865. /**
  54866. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54867. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54868. */
  54869. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54870. /**
  54871. * Disposes of the gizmo manager
  54872. */
  54873. dispose(): void;
  54874. }
  54875. }
  54876. declare module BABYLON {
  54877. /**
  54878. * Gizmo that enables dragging a mesh along 3 axis
  54879. */
  54880. export class PositionGizmo extends Gizmo {
  54881. /**
  54882. * Internal gizmo used for interactions on the x axis
  54883. */
  54884. xGizmo: AxisDragGizmo;
  54885. /**
  54886. * Internal gizmo used for interactions on the y axis
  54887. */
  54888. yGizmo: AxisDragGizmo;
  54889. /**
  54890. * Internal gizmo used for interactions on the z axis
  54891. */
  54892. zGizmo: AxisDragGizmo;
  54893. /**
  54894. * Internal gizmo used for interactions on the yz plane
  54895. */
  54896. xPlaneGizmo: PlaneDragGizmo;
  54897. /**
  54898. * Internal gizmo used for interactions on the xz plane
  54899. */
  54900. yPlaneGizmo: PlaneDragGizmo;
  54901. /**
  54902. * Internal gizmo used for interactions on the xy plane
  54903. */
  54904. zPlaneGizmo: PlaneDragGizmo;
  54905. /**
  54906. * private variables
  54907. */
  54908. private _meshAttached;
  54909. private _nodeAttached;
  54910. private _snapDistance;
  54911. private _observables;
  54912. /** Node Caching for quick lookup */
  54913. private _gizmoAxisCache;
  54914. /** Fires an event when any of it's sub gizmos are dragged */
  54915. onDragStartObservable: Observable<unknown>;
  54916. /** Fires an event when any of it's sub gizmos are released from dragging */
  54917. onDragEndObservable: Observable<unknown>;
  54918. /**
  54919. * If set to true, planar drag is enabled
  54920. */
  54921. private _planarGizmoEnabled;
  54922. get attachedMesh(): Nullable<AbstractMesh>;
  54923. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54924. get attachedNode(): Nullable<Node>;
  54925. set attachedNode(node: Nullable<Node>);
  54926. /**
  54927. * True when the mouse pointer is hovering a gizmo mesh
  54928. */
  54929. get isHovered(): boolean;
  54930. /**
  54931. * Creates a PositionGizmo
  54932. * @param gizmoLayer The utility layer the gizmo will be added to
  54933. @param thickness display gizmo axis thickness
  54934. */
  54935. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54936. /**
  54937. * If the planar drag gizmo is enabled
  54938. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54939. */
  54940. set planarGizmoEnabled(value: boolean);
  54941. get planarGizmoEnabled(): boolean;
  54942. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54943. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54944. /**
  54945. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54946. */
  54947. set snapDistance(value: number);
  54948. get snapDistance(): number;
  54949. /**
  54950. * Ratio for the scale of the gizmo (Default: 1)
  54951. */
  54952. set scaleRatio(value: number);
  54953. get scaleRatio(): number;
  54954. /**
  54955. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54956. * @param mesh Axis gizmo mesh
  54957. * @param cache Gizmo axis definition used for reactive gizmo UI
  54958. */
  54959. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54960. /**
  54961. * Disposes of the gizmo
  54962. */
  54963. dispose(): void;
  54964. /**
  54965. * CustomMeshes are not supported by this gizmo
  54966. * @param mesh The mesh to replace the default mesh of the gizmo
  54967. */
  54968. setCustomMesh(mesh: Mesh): void;
  54969. }
  54970. }
  54971. declare module BABYLON {
  54972. /**
  54973. * Single axis drag gizmo
  54974. */
  54975. export class AxisDragGizmo extends Gizmo {
  54976. /**
  54977. * Drag behavior responsible for the gizmos dragging interactions
  54978. */
  54979. dragBehavior: PointerDragBehavior;
  54980. private _pointerObserver;
  54981. /**
  54982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54983. */
  54984. snapDistance: number;
  54985. /**
  54986. * Event that fires each time the gizmo snaps to a new location.
  54987. * * snapDistance is the the change in distance
  54988. */
  54989. onSnapObservable: Observable<{
  54990. snapDistance: number;
  54991. }>;
  54992. private _isEnabled;
  54993. private _parent;
  54994. private _gizmoMesh;
  54995. private _coloredMaterial;
  54996. private _hoverMaterial;
  54997. private _disableMaterial;
  54998. private _dragging;
  54999. /** @hidden */
  55000. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  55001. /** @hidden */
  55002. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55003. /**
  55004. * Creates an AxisDragGizmo
  55005. * @param gizmoLayer The utility layer the gizmo will be added to
  55006. * @param dragAxis The axis which the gizmo will be able to drag on
  55007. * @param color The color of the gizmo
  55008. * @param thickness display gizmo axis thickness
  55009. */
  55010. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55011. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55012. /**
  55013. * If the gizmo is enabled
  55014. */
  55015. set isEnabled(value: boolean);
  55016. get isEnabled(): boolean;
  55017. /**
  55018. * Disposes of the gizmo
  55019. */
  55020. dispose(): void;
  55021. }
  55022. }
  55023. declare module BABYLON.Debug {
  55024. /**
  55025. * The Axes viewer will show 3 axes in a specific point in space
  55026. */
  55027. export class AxesViewer {
  55028. private _xAxis;
  55029. private _yAxis;
  55030. private _zAxis;
  55031. private _scaleLinesFactor;
  55032. private _instanced;
  55033. /**
  55034. * Gets the hosting scene
  55035. */
  55036. scene: Nullable<Scene>;
  55037. /**
  55038. * Gets or sets a number used to scale line length
  55039. */
  55040. scaleLines: number;
  55041. /** Gets the node hierarchy used to render x-axis */
  55042. get xAxis(): TransformNode;
  55043. /** Gets the node hierarchy used to render y-axis */
  55044. get yAxis(): TransformNode;
  55045. /** Gets the node hierarchy used to render z-axis */
  55046. get zAxis(): TransformNode;
  55047. /**
  55048. * Creates a new AxesViewer
  55049. * @param scene defines the hosting scene
  55050. * @param scaleLines defines a number used to scale line length (1 by default)
  55051. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55052. * @param xAxis defines the node hierarchy used to render the x-axis
  55053. * @param yAxis defines the node hierarchy used to render the y-axis
  55054. * @param zAxis defines the node hierarchy used to render the z-axis
  55055. */
  55056. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55057. /**
  55058. * Force the viewer to update
  55059. * @param position defines the position of the viewer
  55060. * @param xaxis defines the x axis of the viewer
  55061. * @param yaxis defines the y axis of the viewer
  55062. * @param zaxis defines the z axis of the viewer
  55063. */
  55064. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55065. /**
  55066. * Creates an instance of this axes viewer.
  55067. * @returns a new axes viewer with instanced meshes
  55068. */
  55069. createInstance(): AxesViewer;
  55070. /** Releases resources */
  55071. dispose(): void;
  55072. private static _SetRenderingGroupId;
  55073. }
  55074. }
  55075. declare module BABYLON.Debug {
  55076. /**
  55077. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55078. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55079. */
  55080. export class BoneAxesViewer extends AxesViewer {
  55081. /**
  55082. * Gets or sets the target mesh where to display the axes viewer
  55083. */
  55084. mesh: Nullable<Mesh>;
  55085. /**
  55086. * Gets or sets the target bone where to display the axes viewer
  55087. */
  55088. bone: Nullable<Bone>;
  55089. /** Gets current position */
  55090. pos: Vector3;
  55091. /** Gets direction of X axis */
  55092. xaxis: Vector3;
  55093. /** Gets direction of Y axis */
  55094. yaxis: Vector3;
  55095. /** Gets direction of Z axis */
  55096. zaxis: Vector3;
  55097. /**
  55098. * Creates a new BoneAxesViewer
  55099. * @param scene defines the hosting scene
  55100. * @param bone defines the target bone
  55101. * @param mesh defines the target mesh
  55102. * @param scaleLines defines a scaling factor for line length (1 by default)
  55103. */
  55104. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55105. /**
  55106. * Force the viewer to update
  55107. */
  55108. update(): void;
  55109. /** Releases resources */
  55110. dispose(): void;
  55111. }
  55112. }
  55113. declare module BABYLON {
  55114. /**
  55115. * Interface used to define scene explorer extensibility option
  55116. */
  55117. export interface IExplorerExtensibilityOption {
  55118. /**
  55119. * Define the option label
  55120. */
  55121. label: string;
  55122. /**
  55123. * Defines the action to execute on click
  55124. */
  55125. action: (entity: any) => void;
  55126. }
  55127. /**
  55128. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55129. */
  55130. export interface IExplorerExtensibilityGroup {
  55131. /**
  55132. * Defines a predicate to test if a given type mut be extended
  55133. */
  55134. predicate: (entity: any) => boolean;
  55135. /**
  55136. * Gets the list of options added to a type
  55137. */
  55138. entries: IExplorerExtensibilityOption[];
  55139. }
  55140. /**
  55141. * Interface used to define the options to use to create the Inspector
  55142. */
  55143. export interface IInspectorOptions {
  55144. /**
  55145. * Display in overlay mode (default: false)
  55146. */
  55147. overlay?: boolean;
  55148. /**
  55149. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55150. */
  55151. globalRoot?: HTMLElement;
  55152. /**
  55153. * Display the Scene explorer
  55154. */
  55155. showExplorer?: boolean;
  55156. /**
  55157. * Display the property inspector
  55158. */
  55159. showInspector?: boolean;
  55160. /**
  55161. * Display in embed mode (both panes on the right)
  55162. */
  55163. embedMode?: boolean;
  55164. /**
  55165. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55166. */
  55167. handleResize?: boolean;
  55168. /**
  55169. * Allow the panes to popup (default: true)
  55170. */
  55171. enablePopup?: boolean;
  55172. /**
  55173. * Allow the panes to be closed by users (default: true)
  55174. */
  55175. enableClose?: boolean;
  55176. /**
  55177. * Optional list of extensibility entries
  55178. */
  55179. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55180. /**
  55181. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55182. */
  55183. inspectorURL?: string;
  55184. /**
  55185. * Optional initial tab (default to DebugLayerTab.Properties)
  55186. */
  55187. initialTab?: DebugLayerTab;
  55188. }
  55189. interface Scene {
  55190. /**
  55191. * @hidden
  55192. * Backing field
  55193. */
  55194. _debugLayer: DebugLayer;
  55195. /**
  55196. * Gets the debug layer (aka Inspector) associated with the scene
  55197. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55198. */
  55199. debugLayer: DebugLayer;
  55200. }
  55201. /**
  55202. * Enum of inspector action tab
  55203. */
  55204. export enum DebugLayerTab {
  55205. /**
  55206. * Properties tag (default)
  55207. */
  55208. Properties = 0,
  55209. /**
  55210. * Debug tab
  55211. */
  55212. Debug = 1,
  55213. /**
  55214. * Statistics tab
  55215. */
  55216. Statistics = 2,
  55217. /**
  55218. * Tools tab
  55219. */
  55220. Tools = 3,
  55221. /**
  55222. * Settings tab
  55223. */
  55224. Settings = 4
  55225. }
  55226. /**
  55227. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55228. * what is happening in your scene
  55229. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55230. */
  55231. export class DebugLayer {
  55232. /**
  55233. * Define the url to get the inspector script from.
  55234. * By default it uses the babylonjs CDN.
  55235. * @ignoreNaming
  55236. */
  55237. static InspectorURL: string;
  55238. private _scene;
  55239. private BJSINSPECTOR;
  55240. private _onPropertyChangedObservable?;
  55241. /**
  55242. * Observable triggered when a property is changed through the inspector.
  55243. */
  55244. get onPropertyChangedObservable(): any;
  55245. /**
  55246. * Instantiates a new debug layer.
  55247. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55248. * what is happening in your scene
  55249. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55250. * @param scene Defines the scene to inspect
  55251. */
  55252. constructor(scene: Scene);
  55253. /** Creates the inspector window. */
  55254. private _createInspector;
  55255. /**
  55256. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55257. * @param entity defines the entity to select
  55258. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55259. */
  55260. select(entity: any, lineContainerTitles?: string | string[]): void;
  55261. /** Get the inspector from bundle or global */
  55262. private _getGlobalInspector;
  55263. /**
  55264. * Get if the inspector is visible or not.
  55265. * @returns true if visible otherwise, false
  55266. */
  55267. isVisible(): boolean;
  55268. /**
  55269. * Hide the inspector and close its window.
  55270. */
  55271. hide(): void;
  55272. /**
  55273. * Update the scene in the inspector
  55274. */
  55275. setAsActiveScene(): void;
  55276. /**
  55277. * Launch the debugLayer.
  55278. * @param config Define the configuration of the inspector
  55279. * @return a promise fulfilled when the debug layer is visible
  55280. */
  55281. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55282. }
  55283. }
  55284. declare module BABYLON.Debug {
  55285. /**
  55286. * Used to show the physics impostor around the specific mesh
  55287. */
  55288. export class PhysicsViewer {
  55289. /** @hidden */
  55290. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55291. /** @hidden */
  55292. protected _meshes: Array<Nullable<AbstractMesh>>;
  55293. /** @hidden */
  55294. protected _scene: Nullable<Scene>;
  55295. /** @hidden */
  55296. protected _numMeshes: number;
  55297. /** @hidden */
  55298. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55299. private _renderFunction;
  55300. private _utilityLayer;
  55301. private _debugBoxMesh;
  55302. private _debugSphereMesh;
  55303. private _debugCylinderMesh;
  55304. private _debugMaterial;
  55305. private _debugMeshMeshes;
  55306. /**
  55307. * Creates a new PhysicsViewer
  55308. * @param scene defines the hosting scene
  55309. */
  55310. constructor(scene: Scene);
  55311. /** @hidden */
  55312. protected _updateDebugMeshes(): void;
  55313. /**
  55314. * Renders a specified physic impostor
  55315. * @param impostor defines the impostor to render
  55316. * @param targetMesh defines the mesh represented by the impostor
  55317. * @returns the new debug mesh used to render the impostor
  55318. */
  55319. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55320. /**
  55321. * Hides a specified physic impostor
  55322. * @param impostor defines the impostor to hide
  55323. */
  55324. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55325. private _getDebugMaterial;
  55326. private _getDebugBoxMesh;
  55327. private _getDebugSphereMesh;
  55328. private _getDebugCylinderMesh;
  55329. private _getDebugMeshMesh;
  55330. private _getDebugMesh;
  55331. /** Releases all resources */
  55332. dispose(): void;
  55333. }
  55334. }
  55335. declare module BABYLON {
  55336. /**
  55337. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55338. * in order to better appreciate the issue one might have.
  55339. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55340. */
  55341. export class RayHelper {
  55342. /**
  55343. * Defines the ray we are currently tryin to visualize.
  55344. */
  55345. ray: Nullable<Ray>;
  55346. private _renderPoints;
  55347. private _renderLine;
  55348. private _renderFunction;
  55349. private _scene;
  55350. private _onAfterRenderObserver;
  55351. private _onAfterStepObserver;
  55352. private _attachedToMesh;
  55353. private _meshSpaceDirection;
  55354. private _meshSpaceOrigin;
  55355. /**
  55356. * Helper function to create a colored helper in a scene in one line.
  55357. * @param ray Defines the ray we are currently tryin to visualize
  55358. * @param scene Defines the scene the ray is used in
  55359. * @param color Defines the color we want to see the ray in
  55360. * @returns The newly created ray helper.
  55361. */
  55362. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55363. /**
  55364. * Instantiate a new ray helper.
  55365. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55366. * in order to better appreciate the issue one might have.
  55367. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55368. * @param ray Defines the ray we are currently tryin to visualize
  55369. */
  55370. constructor(ray: Ray);
  55371. /**
  55372. * Shows the ray we are willing to debug.
  55373. * @param scene Defines the scene the ray needs to be rendered in
  55374. * @param color Defines the color the ray needs to be rendered in
  55375. */
  55376. show(scene: Scene, color?: Color3): void;
  55377. /**
  55378. * Hides the ray we are debugging.
  55379. */
  55380. hide(): void;
  55381. private _render;
  55382. /**
  55383. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55384. * @param mesh Defines the mesh we want the helper attached to
  55385. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55386. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55387. * @param length Defines the length of the ray
  55388. */
  55389. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55390. /**
  55391. * Detach the ray helper from the mesh it has previously been attached to.
  55392. */
  55393. detachFromMesh(): void;
  55394. private _updateToMesh;
  55395. /**
  55396. * Dispose the helper and release its associated resources.
  55397. */
  55398. dispose(): void;
  55399. }
  55400. }
  55401. declare module BABYLON {
  55402. /**
  55403. * Defines the options associated with the creation of a SkeletonViewer.
  55404. */
  55405. export interface ISkeletonViewerOptions {
  55406. /** Should the system pause animations before building the Viewer? */
  55407. pauseAnimations: boolean;
  55408. /** Should the system return the skeleton to rest before building? */
  55409. returnToRest: boolean;
  55410. /** public Display Mode of the Viewer */
  55411. displayMode: number;
  55412. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55413. displayOptions: ISkeletonViewerDisplayOptions;
  55414. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55415. computeBonesUsingShaders: boolean;
  55416. /** Flag ignore non weighted bones */
  55417. useAllBones: boolean;
  55418. }
  55419. /**
  55420. * Defines how to display the various bone meshes for the viewer.
  55421. */
  55422. export interface ISkeletonViewerDisplayOptions {
  55423. /** How far down to start tapering the bone spurs */
  55424. midStep?: number;
  55425. /** How big is the midStep? */
  55426. midStepFactor?: number;
  55427. /** Base for the Sphere Size */
  55428. sphereBaseSize?: number;
  55429. /** The ratio of the sphere to the longest bone in units */
  55430. sphereScaleUnit?: number;
  55431. /** Ratio for the Sphere Size */
  55432. sphereFactor?: number;
  55433. /** Whether a spur should attach its far end to the child bone position */
  55434. spurFollowsChild?: boolean;
  55435. /** Whether to show local axes or not */
  55436. showLocalAxes?: boolean;
  55437. /** Length of each local axis */
  55438. localAxesSize?: number;
  55439. }
  55440. /**
  55441. * Defines the constructor options for the BoneWeight Shader.
  55442. */
  55443. export interface IBoneWeightShaderOptions {
  55444. /** Skeleton to Map */
  55445. skeleton: Skeleton;
  55446. /** Colors for Uninfluenced bones */
  55447. colorBase?: Color3;
  55448. /** Colors for 0.0-0.25 Weight bones */
  55449. colorZero?: Color3;
  55450. /** Color for 0.25-0.5 Weight Influence */
  55451. colorQuarter?: Color3;
  55452. /** Color for 0.5-0.75 Weight Influence */
  55453. colorHalf?: Color3;
  55454. /** Color for 0.75-1 Weight Influence */
  55455. colorFull?: Color3;
  55456. /** Color for Zero Weight Influence */
  55457. targetBoneIndex?: number;
  55458. }
  55459. /**
  55460. * Simple structure of the gradient steps for the Color Map.
  55461. */
  55462. export interface ISkeletonMapShaderColorMapKnot {
  55463. /** Color of the Knot */
  55464. color: Color3;
  55465. /** Location of the Knot */
  55466. location: number;
  55467. }
  55468. /**
  55469. * Defines the constructor options for the SkeletonMap Shader.
  55470. */
  55471. export interface ISkeletonMapShaderOptions {
  55472. /** Skeleton to Map */
  55473. skeleton: Skeleton;
  55474. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55475. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55476. }
  55477. }
  55478. declare module BABYLON {
  55479. /**
  55480. * Class containing static functions to help procedurally build meshes
  55481. */
  55482. export class RibbonBuilder {
  55483. /**
  55484. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55485. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55486. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55487. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55488. * * 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
  55489. * * 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
  55490. * * 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
  55491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55492. * * 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
  55493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55494. * * 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
  55495. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55496. * * 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
  55497. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55499. * @param name defines the name of the mesh
  55500. * @param options defines the options used to create the mesh
  55501. * @param scene defines the hosting scene
  55502. * @returns the ribbon mesh
  55503. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55504. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55505. */
  55506. static CreateRibbon(name: string, options: {
  55507. pathArray: Vector3[][];
  55508. closeArray?: boolean;
  55509. closePath?: boolean;
  55510. offset?: number;
  55511. updatable?: boolean;
  55512. sideOrientation?: number;
  55513. frontUVs?: Vector4;
  55514. backUVs?: Vector4;
  55515. instance?: Mesh;
  55516. invertUV?: boolean;
  55517. uvs?: Vector2[];
  55518. colors?: Color4[];
  55519. }, scene?: Nullable<Scene>): Mesh;
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /**
  55524. * Class containing static functions to help procedurally build meshes
  55525. */
  55526. export class ShapeBuilder {
  55527. /**
  55528. * 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.
  55529. * * 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.
  55530. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55531. * * 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.
  55532. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55533. * * 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
  55534. * * 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
  55535. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55537. * * 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
  55538. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55540. * @param name defines the name of the mesh
  55541. * @param options defines the options used to create the mesh
  55542. * @param scene defines the hosting scene
  55543. * @returns the extruded shape mesh
  55544. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55545. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55546. */
  55547. static ExtrudeShape(name: string, options: {
  55548. shape: Vector3[];
  55549. path: Vector3[];
  55550. scale?: number;
  55551. rotation?: number;
  55552. cap?: number;
  55553. updatable?: boolean;
  55554. sideOrientation?: number;
  55555. frontUVs?: Vector4;
  55556. backUVs?: Vector4;
  55557. instance?: Mesh;
  55558. invertUV?: boolean;
  55559. }, scene?: Nullable<Scene>): Mesh;
  55560. /**
  55561. * Creates an custom extruded shape mesh.
  55562. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55563. * * 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.
  55564. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55565. * * 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
  55566. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55567. * * 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
  55568. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55569. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55570. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55571. * * 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
  55572. * * 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
  55573. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55575. * * 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
  55576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55578. * @param name defines the name of the mesh
  55579. * @param options defines the options used to create the mesh
  55580. * @param scene defines the hosting scene
  55581. * @returns the custom extruded shape mesh
  55582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55585. */
  55586. static ExtrudeShapeCustom(name: string, options: {
  55587. shape: Vector3[];
  55588. path: Vector3[];
  55589. scaleFunction?: any;
  55590. rotationFunction?: any;
  55591. ribbonCloseArray?: boolean;
  55592. ribbonClosePath?: boolean;
  55593. cap?: number;
  55594. updatable?: boolean;
  55595. sideOrientation?: number;
  55596. frontUVs?: Vector4;
  55597. backUVs?: Vector4;
  55598. instance?: Mesh;
  55599. invertUV?: boolean;
  55600. }, scene?: Nullable<Scene>): Mesh;
  55601. private static _ExtrudeShapeGeneric;
  55602. }
  55603. }
  55604. declare module BABYLON.Debug {
  55605. /**
  55606. * Class used to render a debug view of a given skeleton
  55607. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55608. */
  55609. export class SkeletonViewer {
  55610. /** defines the skeleton to render */
  55611. skeleton: Skeleton;
  55612. /** defines the mesh attached to the skeleton */
  55613. mesh: AbstractMesh;
  55614. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55615. autoUpdateBonesMatrices: boolean;
  55616. /** defines the rendering group id to use with the viewer */
  55617. renderingGroupId: number;
  55618. /** is the options for the viewer */
  55619. options: Partial<ISkeletonViewerOptions>;
  55620. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55621. static readonly DISPLAY_LINES: number;
  55622. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55623. static readonly DISPLAY_SPHERES: number;
  55624. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55625. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55626. /** public static method to create a BoneWeight Shader
  55627. * @param options The constructor options
  55628. * @param scene The scene that the shader is scoped to
  55629. * @returns The created ShaderMaterial
  55630. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55631. */
  55632. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55633. /** public static method to create a BoneWeight Shader
  55634. * @param options The constructor options
  55635. * @param scene The scene that the shader is scoped to
  55636. * @returns The created ShaderMaterial
  55637. */
  55638. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55639. /** private static method to create a BoneWeight Shader
  55640. * @param size The size of the buffer to create (usually the bone count)
  55641. * @param colorMap The gradient data to generate
  55642. * @param scene The scene that the shader is scoped to
  55643. * @returns an Array of floats from the color gradient values
  55644. */
  55645. private static _CreateBoneMapColorBuffer;
  55646. /** If SkeletonViewer scene scope. */
  55647. private _scene;
  55648. /** Gets or sets the color used to render the skeleton */
  55649. color: Color3;
  55650. /** Array of the points of the skeleton fo the line view. */
  55651. private _debugLines;
  55652. /** The SkeletonViewers Mesh. */
  55653. private _debugMesh;
  55654. /** The local axes Meshes. */
  55655. private _localAxes;
  55656. /** If SkeletonViewer is enabled. */
  55657. private _isEnabled;
  55658. /** If SkeletonViewer is ready. */
  55659. private _ready;
  55660. /** SkeletonViewer render observable. */
  55661. private _obs;
  55662. /** The Utility Layer to render the gizmos in. */
  55663. private _utilityLayer;
  55664. private _boneIndices;
  55665. /** Gets the Scene. */
  55666. get scene(): Scene;
  55667. /** Gets the utilityLayer. */
  55668. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55669. /** Checks Ready Status. */
  55670. get isReady(): Boolean;
  55671. /** Sets Ready Status. */
  55672. set ready(value: boolean);
  55673. /** Gets the debugMesh */
  55674. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55675. /** Sets the debugMesh */
  55676. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55677. /** Gets the displayMode */
  55678. get displayMode(): number;
  55679. /** Sets the displayMode */
  55680. set displayMode(value: number);
  55681. /**
  55682. * Creates a new SkeletonViewer
  55683. * @param skeleton defines the skeleton to render
  55684. * @param mesh defines the mesh attached to the skeleton
  55685. * @param scene defines the hosting scene
  55686. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55687. * @param renderingGroupId defines the rendering group id to use with the viewer
  55688. * @param options All of the extra constructor options for the SkeletonViewer
  55689. */
  55690. constructor(
  55691. /** defines the skeleton to render */
  55692. skeleton: Skeleton,
  55693. /** defines the mesh attached to the skeleton */
  55694. mesh: AbstractMesh,
  55695. /** The Scene scope*/
  55696. scene: Scene,
  55697. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55698. autoUpdateBonesMatrices?: boolean,
  55699. /** defines the rendering group id to use with the viewer */
  55700. renderingGroupId?: number,
  55701. /** is the options for the viewer */
  55702. options?: Partial<ISkeletonViewerOptions>);
  55703. /** The Dynamic bindings for the update functions */
  55704. private _bindObs;
  55705. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55706. update(): void;
  55707. /** Gets or sets a boolean indicating if the viewer is enabled */
  55708. set isEnabled(value: boolean);
  55709. get isEnabled(): boolean;
  55710. private _getBonePosition;
  55711. private _getLinesForBonesWithLength;
  55712. private _getLinesForBonesNoLength;
  55713. /** function to revert the mesh and scene back to the initial state. */
  55714. private _revert;
  55715. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55716. private _getAbsoluteBindPoseToRef;
  55717. /** function to build and bind sphere joint points and spur bone representations. */
  55718. private _buildSpheresAndSpurs;
  55719. private _buildLocalAxes;
  55720. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55721. private _displayLinesUpdate;
  55722. /** Changes the displayMode of the skeleton viewer
  55723. * @param mode The displayMode numerical value
  55724. */
  55725. changeDisplayMode(mode: number): void;
  55726. /** Sets a display option of the skeleton viewer
  55727. *
  55728. * | Option | Type | Default | Description |
  55729. * | ---------------- | ------- | ------- | ----------- |
  55730. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55731. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55732. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55733. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55734. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55735. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55736. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55737. *
  55738. * @param option String of the option name
  55739. * @param value The numerical option value
  55740. */
  55741. changeDisplayOptions(option: string, value: number): void;
  55742. /** Release associated resources */
  55743. dispose(): void;
  55744. }
  55745. }
  55746. declare module BABYLON {
  55747. /**
  55748. * Enum for Device Types
  55749. */
  55750. export enum DeviceType {
  55751. /** Generic */
  55752. Generic = 0,
  55753. /** Keyboard */
  55754. Keyboard = 1,
  55755. /** Mouse */
  55756. Mouse = 2,
  55757. /** Touch Pointers */
  55758. Touch = 3,
  55759. /** PS4 Dual Shock */
  55760. DualShock = 4,
  55761. /** Xbox */
  55762. Xbox = 5,
  55763. /** Switch Controller */
  55764. Switch = 6
  55765. }
  55766. /**
  55767. * Enum for All Pointers (Touch/Mouse)
  55768. */
  55769. export enum PointerInput {
  55770. /** Horizontal Axis */
  55771. Horizontal = 0,
  55772. /** Vertical Axis */
  55773. Vertical = 1,
  55774. /** Left Click or Touch */
  55775. LeftClick = 2,
  55776. /** Middle Click */
  55777. MiddleClick = 3,
  55778. /** Right Click */
  55779. RightClick = 4,
  55780. /** Browser Back */
  55781. BrowserBack = 5,
  55782. /** Browser Forward */
  55783. BrowserForward = 6
  55784. }
  55785. /**
  55786. * Enum for Dual Shock Gamepad
  55787. */
  55788. export enum DualShockInput {
  55789. /** Cross */
  55790. Cross = 0,
  55791. /** Circle */
  55792. Circle = 1,
  55793. /** Square */
  55794. Square = 2,
  55795. /** Triangle */
  55796. Triangle = 3,
  55797. /** L1 */
  55798. L1 = 4,
  55799. /** R1 */
  55800. R1 = 5,
  55801. /** L2 */
  55802. L2 = 6,
  55803. /** R2 */
  55804. R2 = 7,
  55805. /** Share */
  55806. Share = 8,
  55807. /** Options */
  55808. Options = 9,
  55809. /** L3 */
  55810. L3 = 10,
  55811. /** R3 */
  55812. R3 = 11,
  55813. /** DPadUp */
  55814. DPadUp = 12,
  55815. /** DPadDown */
  55816. DPadDown = 13,
  55817. /** DPadLeft */
  55818. DPadLeft = 14,
  55819. /** DRight */
  55820. DPadRight = 15,
  55821. /** Home */
  55822. Home = 16,
  55823. /** TouchPad */
  55824. TouchPad = 17,
  55825. /** LStickXAxis */
  55826. LStickXAxis = 18,
  55827. /** LStickYAxis */
  55828. LStickYAxis = 19,
  55829. /** RStickXAxis */
  55830. RStickXAxis = 20,
  55831. /** RStickYAxis */
  55832. RStickYAxis = 21
  55833. }
  55834. /**
  55835. * Enum for Xbox Gamepad
  55836. */
  55837. export enum XboxInput {
  55838. /** A */
  55839. A = 0,
  55840. /** B */
  55841. B = 1,
  55842. /** X */
  55843. X = 2,
  55844. /** Y */
  55845. Y = 3,
  55846. /** LB */
  55847. LB = 4,
  55848. /** RB */
  55849. RB = 5,
  55850. /** LT */
  55851. LT = 6,
  55852. /** RT */
  55853. RT = 7,
  55854. /** Back */
  55855. Back = 8,
  55856. /** Start */
  55857. Start = 9,
  55858. /** LS */
  55859. LS = 10,
  55860. /** RS */
  55861. RS = 11,
  55862. /** DPadUp */
  55863. DPadUp = 12,
  55864. /** DPadDown */
  55865. DPadDown = 13,
  55866. /** DPadLeft */
  55867. DPadLeft = 14,
  55868. /** DRight */
  55869. DPadRight = 15,
  55870. /** Home */
  55871. Home = 16,
  55872. /** LStickXAxis */
  55873. LStickXAxis = 17,
  55874. /** LStickYAxis */
  55875. LStickYAxis = 18,
  55876. /** RStickXAxis */
  55877. RStickXAxis = 19,
  55878. /** RStickYAxis */
  55879. RStickYAxis = 20
  55880. }
  55881. /**
  55882. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55883. */
  55884. export enum SwitchInput {
  55885. /** B */
  55886. B = 0,
  55887. /** A */
  55888. A = 1,
  55889. /** Y */
  55890. Y = 2,
  55891. /** X */
  55892. X = 3,
  55893. /** L */
  55894. L = 4,
  55895. /** R */
  55896. R = 5,
  55897. /** ZL */
  55898. ZL = 6,
  55899. /** ZR */
  55900. ZR = 7,
  55901. /** Minus */
  55902. Minus = 8,
  55903. /** Plus */
  55904. Plus = 9,
  55905. /** LS */
  55906. LS = 10,
  55907. /** RS */
  55908. RS = 11,
  55909. /** DPadUp */
  55910. DPadUp = 12,
  55911. /** DPadDown */
  55912. DPadDown = 13,
  55913. /** DPadLeft */
  55914. DPadLeft = 14,
  55915. /** DRight */
  55916. DPadRight = 15,
  55917. /** Home */
  55918. Home = 16,
  55919. /** Capture */
  55920. Capture = 17,
  55921. /** LStickXAxis */
  55922. LStickXAxis = 18,
  55923. /** LStickYAxis */
  55924. LStickYAxis = 19,
  55925. /** RStickXAxis */
  55926. RStickXAxis = 20,
  55927. /** RStickYAxis */
  55928. RStickYAxis = 21
  55929. }
  55930. }
  55931. declare module BABYLON {
  55932. /**
  55933. * This class will take all inputs from Keyboard, Pointer, and
  55934. * any Gamepads and provide a polling system that all devices
  55935. * will use. This class assumes that there will only be one
  55936. * pointer device and one keyboard.
  55937. */
  55938. export class DeviceInputSystem implements IDisposable {
  55939. /**
  55940. * Returns onDeviceConnected callback property
  55941. * @returns Callback with function to execute when a device is connected
  55942. */
  55943. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55944. /**
  55945. * Sets callback function when a device is connected and executes against all connected devices
  55946. * @param callback Function to execute when a device is connected
  55947. */
  55948. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55949. /**
  55950. * Callback to be triggered when a device is disconnected
  55951. */
  55952. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55953. /**
  55954. * Callback to be triggered when event driven input is updated
  55955. */
  55956. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55957. private _inputs;
  55958. private _gamepads;
  55959. private _keyboardActive;
  55960. private _pointerActive;
  55961. private _elementToAttachTo;
  55962. private _keyboardDownEvent;
  55963. private _keyboardUpEvent;
  55964. private _pointerMoveEvent;
  55965. private _pointerDownEvent;
  55966. private _pointerUpEvent;
  55967. private _gamepadConnectedEvent;
  55968. private _gamepadDisconnectedEvent;
  55969. private _onDeviceConnected;
  55970. private static _MAX_KEYCODES;
  55971. private static _MAX_POINTER_INPUTS;
  55972. private constructor();
  55973. /**
  55974. * Creates a new DeviceInputSystem instance
  55975. * @param engine Engine to pull input element from
  55976. * @returns The new instance
  55977. */
  55978. static Create(engine: Engine): DeviceInputSystem;
  55979. /**
  55980. * Checks for current device input value, given an id and input index
  55981. * @param deviceName Id of connected device
  55982. * @param inputIndex Index of device input
  55983. * @returns Current value of input
  55984. */
  55985. /**
  55986. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55987. * @param deviceType Enum specifiying device type
  55988. * @param deviceSlot "Slot" or index that device is referenced in
  55989. * @param inputIndex Id of input to be checked
  55990. * @returns Current value of input
  55991. */
  55992. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55993. /**
  55994. * Dispose of all the eventlisteners
  55995. */
  55996. dispose(): void;
  55997. /**
  55998. * Checks for existing connections to devices and register them, if necessary
  55999. * Currently handles gamepads and mouse
  56000. */
  56001. private _checkForConnectedDevices;
  56002. /**
  56003. * Add a gamepad to the DeviceInputSystem
  56004. * @param gamepad A single DOM Gamepad object
  56005. */
  56006. private _addGamePad;
  56007. /**
  56008. * Add pointer device to DeviceInputSystem
  56009. * @param deviceType Type of Pointer to add
  56010. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56011. * @param currentX Current X at point of adding
  56012. * @param currentY Current Y at point of adding
  56013. */
  56014. private _addPointerDevice;
  56015. /**
  56016. * Add device and inputs to device array
  56017. * @param deviceType Enum specifiying device type
  56018. * @param deviceSlot "Slot" or index that device is referenced in
  56019. * @param numberOfInputs Number of input entries to create for given device
  56020. */
  56021. private _registerDevice;
  56022. /**
  56023. * Given a specific device name, remove that device from the device map
  56024. * @param deviceType Enum specifiying device type
  56025. * @param deviceSlot "Slot" or index that device is referenced in
  56026. */
  56027. private _unregisterDevice;
  56028. /**
  56029. * Handle all actions that come from keyboard interaction
  56030. */
  56031. private _handleKeyActions;
  56032. /**
  56033. * Handle all actions that come from pointer interaction
  56034. */
  56035. private _handlePointerActions;
  56036. /**
  56037. * Handle all actions that come from gamepad interaction
  56038. */
  56039. private _handleGamepadActions;
  56040. /**
  56041. * Update all non-event based devices with each frame
  56042. * @param deviceType Enum specifiying device type
  56043. * @param deviceSlot "Slot" or index that device is referenced in
  56044. * @param inputIndex Id of input to be checked
  56045. */
  56046. private _updateDevice;
  56047. /**
  56048. * Gets DeviceType from the device name
  56049. * @param deviceName Name of Device from DeviceInputSystem
  56050. * @returns DeviceType enum value
  56051. */
  56052. private _getGamepadDeviceType;
  56053. }
  56054. }
  56055. declare module BABYLON {
  56056. /**
  56057. * Type to handle enforcement of inputs
  56058. */
  56059. 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;
  56060. }
  56061. declare module BABYLON {
  56062. /**
  56063. * Class that handles all input for a specific device
  56064. */
  56065. export class DeviceSource<T extends DeviceType> {
  56066. /** Type of device */
  56067. readonly deviceType: DeviceType;
  56068. /** "Slot" or index that device is referenced in */
  56069. readonly deviceSlot: number;
  56070. /**
  56071. * Observable to handle device input changes per device
  56072. */
  56073. readonly onInputChangedObservable: Observable<{
  56074. inputIndex: DeviceInput<T>;
  56075. previousState: Nullable<number>;
  56076. currentState: Nullable<number>;
  56077. }>;
  56078. private readonly _deviceInputSystem;
  56079. /**
  56080. * Default Constructor
  56081. * @param deviceInputSystem Reference to DeviceInputSystem
  56082. * @param deviceType Type of device
  56083. * @param deviceSlot "Slot" or index that device is referenced in
  56084. */
  56085. constructor(deviceInputSystem: DeviceInputSystem,
  56086. /** Type of device */
  56087. deviceType: DeviceType,
  56088. /** "Slot" or index that device is referenced in */
  56089. deviceSlot?: number);
  56090. /**
  56091. * Get input for specific input
  56092. * @param inputIndex index of specific input on device
  56093. * @returns Input value from DeviceInputSystem
  56094. */
  56095. getInput(inputIndex: DeviceInput<T>): number;
  56096. }
  56097. /**
  56098. * Class to keep track of devices
  56099. */
  56100. export class DeviceSourceManager implements IDisposable {
  56101. /**
  56102. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56103. */
  56104. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56105. /**
  56106. * Observable to be triggered when after a device is disconnected
  56107. */
  56108. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56109. private readonly _devices;
  56110. private readonly _firstDevice;
  56111. private readonly _deviceInputSystem;
  56112. /**
  56113. * Default Constructor
  56114. * @param engine engine to pull input element from
  56115. */
  56116. constructor(engine: Engine);
  56117. /**
  56118. * Gets a DeviceSource, given a type and slot
  56119. * @param deviceType Enum specifying device type
  56120. * @param deviceSlot "Slot" or index that device is referenced in
  56121. * @returns DeviceSource object
  56122. */
  56123. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56124. /**
  56125. * Gets an array of DeviceSource objects for a given device type
  56126. * @param deviceType Enum specifying device type
  56127. * @returns Array of DeviceSource objects
  56128. */
  56129. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56130. /**
  56131. * Returns a read-only list of all available devices
  56132. * @returns Read-only array with active devices
  56133. */
  56134. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56135. /**
  56136. * Dispose of DeviceInputSystem and other parts
  56137. */
  56138. dispose(): void;
  56139. /**
  56140. * Function to add device name to device list
  56141. * @param deviceType Enum specifying device type
  56142. * @param deviceSlot "Slot" or index that device is referenced in
  56143. */
  56144. private _addDevice;
  56145. /**
  56146. * Function to remove device name to device list
  56147. * @param deviceType Enum specifying device type
  56148. * @param deviceSlot "Slot" or index that device is referenced in
  56149. */
  56150. private _removeDevice;
  56151. /**
  56152. * Updates array storing first connected device of each type
  56153. * @param type Type of Device
  56154. */
  56155. private _updateFirstDevices;
  56156. }
  56157. }
  56158. declare module BABYLON {
  56159. /**
  56160. * Options to create the null engine
  56161. */
  56162. export class NullEngineOptions {
  56163. /**
  56164. * Render width (Default: 512)
  56165. */
  56166. renderWidth: number;
  56167. /**
  56168. * Render height (Default: 256)
  56169. */
  56170. renderHeight: number;
  56171. /**
  56172. * Texture size (Default: 512)
  56173. */
  56174. textureSize: number;
  56175. /**
  56176. * If delta time between frames should be constant
  56177. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56178. */
  56179. deterministicLockstep: boolean;
  56180. /**
  56181. * Maximum about of steps between frames (Default: 4)
  56182. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56183. */
  56184. lockstepMaxSteps: number;
  56185. /**
  56186. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56187. */
  56188. useHighPrecisionMatrix?: boolean;
  56189. }
  56190. /**
  56191. * The null engine class provides support for headless version of babylon.js.
  56192. * This can be used in server side scenario or for testing purposes
  56193. */
  56194. export class NullEngine extends Engine {
  56195. private _options;
  56196. /**
  56197. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56198. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56199. * @returns true if engine is in deterministic lock step mode
  56200. */
  56201. isDeterministicLockStep(): boolean;
  56202. /**
  56203. * Gets the max steps when engine is running in deterministic lock step
  56204. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56205. * @returns the max steps
  56206. */
  56207. getLockstepMaxSteps(): number;
  56208. /**
  56209. * Gets the current hardware scaling level.
  56210. * By default the hardware scaling level is computed from the window device ratio.
  56211. * 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.
  56212. * @returns a number indicating the current hardware scaling level
  56213. */
  56214. getHardwareScalingLevel(): number;
  56215. constructor(options?: NullEngineOptions);
  56216. /**
  56217. * Creates a vertex buffer
  56218. * @param vertices the data for the vertex buffer
  56219. * @returns the new WebGL static buffer
  56220. */
  56221. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56222. /**
  56223. * Creates a new index buffer
  56224. * @param indices defines the content of the index buffer
  56225. * @param updatable defines if the index buffer must be updatable
  56226. * @returns a new webGL buffer
  56227. */
  56228. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56229. /**
  56230. * Clear the current render buffer or the current render target (if any is set up)
  56231. * @param color defines the color to use
  56232. * @param backBuffer defines if the back buffer must be cleared
  56233. * @param depth defines if the depth buffer must be cleared
  56234. * @param stencil defines if the stencil buffer must be cleared
  56235. */
  56236. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56237. /**
  56238. * Gets the current render width
  56239. * @param useScreen defines if screen size must be used (or the current render target if any)
  56240. * @returns a number defining the current render width
  56241. */
  56242. getRenderWidth(useScreen?: boolean): number;
  56243. /**
  56244. * Gets the current render height
  56245. * @param useScreen defines if screen size must be used (or the current render target if any)
  56246. * @returns a number defining the current render height
  56247. */
  56248. getRenderHeight(useScreen?: boolean): number;
  56249. /**
  56250. * Set the WebGL's viewport
  56251. * @param viewport defines the viewport element to be used
  56252. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56253. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56254. */
  56255. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56256. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56257. /**
  56258. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56259. * @param pipelineContext defines the pipeline context to use
  56260. * @param uniformsNames defines the list of uniform names
  56261. * @returns an array of webGL uniform locations
  56262. */
  56263. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56264. /**
  56265. * Gets the lsit of active attributes for a given webGL program
  56266. * @param pipelineContext defines the pipeline context to use
  56267. * @param attributesNames defines the list of attribute names to get
  56268. * @returns an array of indices indicating the offset of each attribute
  56269. */
  56270. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56271. /**
  56272. * Binds an effect to the webGL context
  56273. * @param effect defines the effect to bind
  56274. */
  56275. bindSamplers(effect: Effect): void;
  56276. /**
  56277. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56278. * @param effect defines the effect to activate
  56279. */
  56280. enableEffect(effect: Effect): void;
  56281. /**
  56282. * Set various states to the webGL context
  56283. * @param culling defines backface culling state
  56284. * @param zOffset defines the value to apply to zOffset (0 by default)
  56285. * @param force defines if states must be applied even if cache is up to date
  56286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56287. */
  56288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56289. /**
  56290. * Set the value of an uniform to an array of int32
  56291. * @param uniform defines the webGL uniform location where to store the value
  56292. * @param array defines the array of int32 to store
  56293. * @returns true if value was set
  56294. */
  56295. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56296. /**
  56297. * Set the value of an uniform to an array of int32 (stored as vec2)
  56298. * @param uniform defines the webGL uniform location where to store the value
  56299. * @param array defines the array of int32 to store
  56300. * @returns true if value was set
  56301. */
  56302. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56303. /**
  56304. * Set the value of an uniform to an array of int32 (stored as vec3)
  56305. * @param uniform defines the webGL uniform location where to store the value
  56306. * @param array defines the array of int32 to store
  56307. * @returns true if value was set
  56308. */
  56309. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56310. /**
  56311. * Set the value of an uniform to an array of int32 (stored as vec4)
  56312. * @param uniform defines the webGL uniform location where to store the value
  56313. * @param array defines the array of int32 to store
  56314. * @returns true if value was set
  56315. */
  56316. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56317. /**
  56318. * Set the value of an uniform to an array of float32
  56319. * @param uniform defines the webGL uniform location where to store the value
  56320. * @param array defines the array of float32 to store
  56321. * @returns true if value was set
  56322. */
  56323. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56324. /**
  56325. * Set the value of an uniform to an array of float32 (stored as vec2)
  56326. * @param uniform defines the webGL uniform location where to store the value
  56327. * @param array defines the array of float32 to store
  56328. * @returns true if value was set
  56329. */
  56330. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56331. /**
  56332. * Set the value of an uniform to an array of float32 (stored as vec3)
  56333. * @param uniform defines the webGL uniform location where to store the value
  56334. * @param array defines the array of float32 to store
  56335. * @returns true if value was set
  56336. */
  56337. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56338. /**
  56339. * Set the value of an uniform to an array of float32 (stored as vec4)
  56340. * @param uniform defines the webGL uniform location where to store the value
  56341. * @param array defines the array of float32 to store
  56342. * @returns true if value was set
  56343. */
  56344. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56345. /**
  56346. * Set the value of an uniform to an array of number
  56347. * @param uniform defines the webGL uniform location where to store the value
  56348. * @param array defines the array of number to store
  56349. * @returns true if value was set
  56350. */
  56351. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56352. /**
  56353. * Set the value of an uniform to an array of number (stored as vec2)
  56354. * @param uniform defines the webGL uniform location where to store the value
  56355. * @param array defines the array of number to store
  56356. * @returns true if value was set
  56357. */
  56358. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56359. /**
  56360. * Set the value of an uniform to an array of number (stored as vec3)
  56361. * @param uniform defines the webGL uniform location where to store the value
  56362. * @param array defines the array of number to store
  56363. * @returns true if value was set
  56364. */
  56365. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56366. /**
  56367. * Set the value of an uniform to an array of number (stored as vec4)
  56368. * @param uniform defines the webGL uniform location where to store the value
  56369. * @param array defines the array of number to store
  56370. * @returns true if value was set
  56371. */
  56372. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56373. /**
  56374. * Set the value of an uniform to an array of float32 (stored as matrices)
  56375. * @param uniform defines the webGL uniform location where to store the value
  56376. * @param matrices defines the array of float32 to store
  56377. * @returns true if value was set
  56378. */
  56379. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56380. /**
  56381. * Set the value of an uniform to a matrix (3x3)
  56382. * @param uniform defines the webGL uniform location where to store the value
  56383. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56384. * @returns true if value was set
  56385. */
  56386. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56387. /**
  56388. * Set the value of an uniform to a matrix (2x2)
  56389. * @param uniform defines the webGL uniform location where to store the value
  56390. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56391. * @returns true if value was set
  56392. */
  56393. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56394. /**
  56395. * Set the value of an uniform to a number (float)
  56396. * @param uniform defines the webGL uniform location where to store the value
  56397. * @param value defines the float number to store
  56398. * @returns true if value was set
  56399. */
  56400. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56401. /**
  56402. * Set the value of an uniform to a vec2
  56403. * @param uniform defines the webGL uniform location where to store the value
  56404. * @param x defines the 1st component of the value
  56405. * @param y defines the 2nd component of the value
  56406. * @returns true if value was set
  56407. */
  56408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56409. /**
  56410. * Set the value of an uniform to a vec3
  56411. * @param uniform defines the webGL uniform location where to store the value
  56412. * @param x defines the 1st component of the value
  56413. * @param y defines the 2nd component of the value
  56414. * @param z defines the 3rd component of the value
  56415. * @returns true if value was set
  56416. */
  56417. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56418. /**
  56419. * Set the value of an uniform to a boolean
  56420. * @param uniform defines the webGL uniform location where to store the value
  56421. * @param bool defines the boolean to store
  56422. * @returns true if value was set
  56423. */
  56424. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56425. /**
  56426. * Set the value of an uniform to a vec4
  56427. * @param uniform defines the webGL uniform location where to store the value
  56428. * @param x defines the 1st component of the value
  56429. * @param y defines the 2nd component of the value
  56430. * @param z defines the 3rd component of the value
  56431. * @param w defines the 4th component of the value
  56432. * @returns true if value was set
  56433. */
  56434. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56435. /**
  56436. * Sets the current alpha mode
  56437. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56438. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56439. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56440. */
  56441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56442. /**
  56443. * Bind webGl buffers directly to the webGL context
  56444. * @param vertexBuffers defines the vertex buffer to bind
  56445. * @param indexBuffer defines the index buffer to bind
  56446. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56447. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56448. * @param effect defines the effect associated with the vertex buffer
  56449. */
  56450. bindBuffers(vertexBuffers: {
  56451. [key: string]: VertexBuffer;
  56452. }, indexBuffer: DataBuffer, effect: Effect): void;
  56453. /**
  56454. * Force the entire cache to be cleared
  56455. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56456. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56457. */
  56458. wipeCaches(bruteForce?: boolean): void;
  56459. /**
  56460. * Send a draw order
  56461. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56462. * @param indexStart defines the starting index
  56463. * @param indexCount defines the number of index to draw
  56464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56465. */
  56466. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56467. /**
  56468. * Draw a list of indexed primitives
  56469. * @param fillMode defines the primitive to use
  56470. * @param indexStart defines the starting index
  56471. * @param indexCount defines the number of index to draw
  56472. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56473. */
  56474. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56475. /**
  56476. * Draw a list of unindexed primitives
  56477. * @param fillMode defines the primitive to use
  56478. * @param verticesStart defines the index of first vertex to draw
  56479. * @param verticesCount defines the count of vertices to draw
  56480. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56481. */
  56482. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56483. /** @hidden */
  56484. _createTexture(): WebGLTexture;
  56485. /** @hidden */
  56486. _releaseTexture(texture: InternalTexture): void;
  56487. /**
  56488. * Usually called from Texture.ts.
  56489. * Passed information to create a WebGLTexture
  56490. * @param urlArg defines a value which contains one of the following:
  56491. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56492. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56493. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56494. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56495. * @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)
  56496. * @param scene needed for loading to the correct scene
  56497. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56498. * @param onLoad optional callback to be called upon successful completion
  56499. * @param onError optional callback to be called upon failure
  56500. * @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
  56501. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56502. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56503. * @param forcedExtension defines the extension to use to pick the right loader
  56504. * @param mimeType defines an optional mime type
  56505. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56506. */
  56507. 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;
  56508. /**
  56509. * Creates a new render target texture
  56510. * @param size defines the size of the texture
  56511. * @param options defines the options used to create the texture
  56512. * @returns a new render target texture stored in an InternalTexture
  56513. */
  56514. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56515. /**
  56516. * Update the sampling mode of a given texture
  56517. * @param samplingMode defines the required sampling mode
  56518. * @param texture defines the texture to update
  56519. */
  56520. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56521. /**
  56522. * Binds the frame buffer to the specified texture.
  56523. * @param texture The texture to render to or null for the default canvas
  56524. * @param faceIndex The face of the texture to render to in case of cube texture
  56525. * @param requiredWidth The width of the target to render to
  56526. * @param requiredHeight The height of the target to render to
  56527. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56528. * @param lodLevel defines le lod level to bind to the frame buffer
  56529. */
  56530. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56531. /**
  56532. * Unbind the current render target texture from the webGL context
  56533. * @param texture defines the render target texture to unbind
  56534. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56535. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56536. */
  56537. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56538. /**
  56539. * Creates a dynamic vertex buffer
  56540. * @param vertices the data for the dynamic vertex buffer
  56541. * @returns the new WebGL dynamic buffer
  56542. */
  56543. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56544. /**
  56545. * Update the content of a dynamic texture
  56546. * @param texture defines the texture to update
  56547. * @param canvas defines the canvas containing the source
  56548. * @param invertY defines if data must be stored with Y axis inverted
  56549. * @param premulAlpha defines if alpha is stored as premultiplied
  56550. * @param format defines the format of the data
  56551. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56552. */
  56553. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56554. /**
  56555. * Gets a boolean indicating if all created effects are ready
  56556. * @returns true if all effects are ready
  56557. */
  56558. areAllEffectsReady(): boolean;
  56559. /**
  56560. * @hidden
  56561. * Get the current error code of the webGL context
  56562. * @returns the error code
  56563. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56564. */
  56565. getError(): number;
  56566. /** @hidden */
  56567. _getUnpackAlignement(): number;
  56568. /** @hidden */
  56569. _unpackFlipY(value: boolean): void;
  56570. /**
  56571. * Update a dynamic index buffer
  56572. * @param indexBuffer defines the target index buffer
  56573. * @param indices defines the data to update
  56574. * @param offset defines the offset in the target index buffer where update should start
  56575. */
  56576. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56577. /**
  56578. * Updates a dynamic vertex buffer.
  56579. * @param vertexBuffer the vertex buffer to update
  56580. * @param vertices the data used to update the vertex buffer
  56581. * @param byteOffset the byte offset of the data (optional)
  56582. * @param byteLength the byte length of the data (optional)
  56583. */
  56584. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56585. /** @hidden */
  56586. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56587. /** @hidden */
  56588. _bindTexture(channel: number, texture: InternalTexture): void;
  56589. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56590. /**
  56591. * 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
  56592. */
  56593. releaseEffects(): void;
  56594. displayLoadingUI(): void;
  56595. hideLoadingUI(): void;
  56596. /** @hidden */
  56597. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56598. /** @hidden */
  56599. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56600. /** @hidden */
  56601. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56602. /** @hidden */
  56603. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56604. }
  56605. }
  56606. declare module BABYLON {
  56607. /**
  56608. * @hidden
  56609. **/
  56610. export class _TimeToken {
  56611. _startTimeQuery: Nullable<WebGLQuery>;
  56612. _endTimeQuery: Nullable<WebGLQuery>;
  56613. _timeElapsedQuery: Nullable<WebGLQuery>;
  56614. _timeElapsedQueryEnded: boolean;
  56615. }
  56616. }
  56617. declare module BABYLON {
  56618. /** @hidden */
  56619. export class _OcclusionDataStorage {
  56620. /** @hidden */
  56621. occlusionInternalRetryCounter: number;
  56622. /** @hidden */
  56623. isOcclusionQueryInProgress: boolean;
  56624. /** @hidden */
  56625. isOccluded: boolean;
  56626. /** @hidden */
  56627. occlusionRetryCount: number;
  56628. /** @hidden */
  56629. occlusionType: number;
  56630. /** @hidden */
  56631. occlusionQueryAlgorithmType: number;
  56632. }
  56633. interface Engine {
  56634. /**
  56635. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56636. * @return the new query
  56637. */
  56638. createQuery(): WebGLQuery;
  56639. /**
  56640. * Delete and release a webGL query
  56641. * @param query defines the query to delete
  56642. * @return the current engine
  56643. */
  56644. deleteQuery(query: WebGLQuery): Engine;
  56645. /**
  56646. * Check if a given query has resolved and got its value
  56647. * @param query defines the query to check
  56648. * @returns true if the query got its value
  56649. */
  56650. isQueryResultAvailable(query: WebGLQuery): boolean;
  56651. /**
  56652. * Gets the value of a given query
  56653. * @param query defines the query to check
  56654. * @returns the value of the query
  56655. */
  56656. getQueryResult(query: WebGLQuery): number;
  56657. /**
  56658. * Initiates an occlusion query
  56659. * @param algorithmType defines the algorithm to use
  56660. * @param query defines the query to use
  56661. * @returns the current engine
  56662. * @see https://doc.babylonjs.com/features/occlusionquery
  56663. */
  56664. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56665. /**
  56666. * Ends an occlusion query
  56667. * @see https://doc.babylonjs.com/features/occlusionquery
  56668. * @param algorithmType defines the algorithm to use
  56669. * @returns the current engine
  56670. */
  56671. endOcclusionQuery(algorithmType: number): Engine;
  56672. /**
  56673. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56674. * Please note that only one query can be issued at a time
  56675. * @returns a time token used to track the time span
  56676. */
  56677. startTimeQuery(): Nullable<_TimeToken>;
  56678. /**
  56679. * Ends a time query
  56680. * @param token defines the token used to measure the time span
  56681. * @returns the time spent (in ns)
  56682. */
  56683. endTimeQuery(token: _TimeToken): int;
  56684. /** @hidden */
  56685. _currentNonTimestampToken: Nullable<_TimeToken>;
  56686. /** @hidden */
  56687. _createTimeQuery(): WebGLQuery;
  56688. /** @hidden */
  56689. _deleteTimeQuery(query: WebGLQuery): void;
  56690. /** @hidden */
  56691. _getGlAlgorithmType(algorithmType: number): number;
  56692. /** @hidden */
  56693. _getTimeQueryResult(query: WebGLQuery): any;
  56694. /** @hidden */
  56695. _getTimeQueryAvailability(query: WebGLQuery): any;
  56696. }
  56697. interface AbstractMesh {
  56698. /**
  56699. * Backing filed
  56700. * @hidden
  56701. */
  56702. __occlusionDataStorage: _OcclusionDataStorage;
  56703. /**
  56704. * Access property
  56705. * @hidden
  56706. */
  56707. _occlusionDataStorage: _OcclusionDataStorage;
  56708. /**
  56709. * 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.
  56710. * The default value is -1 which means don't break the query and wait till the result
  56711. * @see https://doc.babylonjs.com/features/occlusionquery
  56712. */
  56713. occlusionRetryCount: number;
  56714. /**
  56715. * 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:
  56716. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56717. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56718. * * 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.
  56719. * @see https://doc.babylonjs.com/features/occlusionquery
  56720. */
  56721. occlusionType: number;
  56722. /**
  56723. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56724. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56725. * * 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.
  56726. * @see https://doc.babylonjs.com/features/occlusionquery
  56727. */
  56728. occlusionQueryAlgorithmType: number;
  56729. /**
  56730. * 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
  56731. * @see https://doc.babylonjs.com/features/occlusionquery
  56732. */
  56733. isOccluded: boolean;
  56734. /**
  56735. * Flag to check the progress status of the query
  56736. * @see https://doc.babylonjs.com/features/occlusionquery
  56737. */
  56738. isOcclusionQueryInProgress: boolean;
  56739. }
  56740. }
  56741. declare module BABYLON {
  56742. /** @hidden */
  56743. export var _forceTransformFeedbackToBundle: boolean;
  56744. interface Engine {
  56745. /**
  56746. * Creates a webGL transform feedback object
  56747. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56748. * @returns the webGL transform feedback object
  56749. */
  56750. createTransformFeedback(): WebGLTransformFeedback;
  56751. /**
  56752. * Delete a webGL transform feedback object
  56753. * @param value defines the webGL transform feedback object to delete
  56754. */
  56755. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56756. /**
  56757. * Bind a webGL transform feedback object to the webgl context
  56758. * @param value defines the webGL transform feedback object to bind
  56759. */
  56760. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56761. /**
  56762. * Begins a transform feedback operation
  56763. * @param usePoints defines if points or triangles must be used
  56764. */
  56765. beginTransformFeedback(usePoints: boolean): void;
  56766. /**
  56767. * Ends a transform feedback operation
  56768. */
  56769. endTransformFeedback(): void;
  56770. /**
  56771. * Specify the varyings to use with transform feedback
  56772. * @param program defines the associated webGL program
  56773. * @param value defines the list of strings representing the varying names
  56774. */
  56775. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56776. /**
  56777. * Bind a webGL buffer for a transform feedback operation
  56778. * @param value defines the webGL buffer to bind
  56779. */
  56780. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56781. }
  56782. }
  56783. declare module BABYLON {
  56784. /**
  56785. * Class used to define an additional view for the engine
  56786. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56787. */
  56788. export class EngineView {
  56789. /** Defines the canvas where to render the view */
  56790. target: HTMLCanvasElement;
  56791. /** Defines an optional camera used to render the view (will use active camera else) */
  56792. camera?: Camera;
  56793. }
  56794. interface Engine {
  56795. /**
  56796. * Gets or sets the HTML element to use for attaching events
  56797. */
  56798. inputElement: Nullable<HTMLElement>;
  56799. /**
  56800. * Gets the current engine view
  56801. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56802. */
  56803. activeView: Nullable<EngineView>;
  56804. /** Gets or sets the list of views */
  56805. views: EngineView[];
  56806. /**
  56807. * Register a new child canvas
  56808. * @param canvas defines the canvas to register
  56809. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56810. * @returns the associated view
  56811. */
  56812. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56813. /**
  56814. * Remove a registered child canvas
  56815. * @param canvas defines the canvas to remove
  56816. * @returns the current engine
  56817. */
  56818. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56819. }
  56820. }
  56821. declare module BABYLON {
  56822. interface Engine {
  56823. /** @hidden */
  56824. _excludedCompressedTextures: string[];
  56825. /** @hidden */
  56826. _textureFormatInUse: string;
  56827. /**
  56828. * Gets the list of texture formats supported
  56829. */
  56830. readonly texturesSupported: Array<string>;
  56831. /**
  56832. * Gets the texture format in use
  56833. */
  56834. readonly textureFormatInUse: Nullable<string>;
  56835. /**
  56836. * Set the compressed texture extensions or file names to skip.
  56837. *
  56838. * @param skippedFiles defines the list of those texture files you want to skip
  56839. * Example: [".dds", ".env", "myfile.png"]
  56840. */
  56841. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56842. /**
  56843. * Set the compressed texture format to use, based on the formats you have, and the formats
  56844. * supported by the hardware / browser.
  56845. *
  56846. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56847. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56848. * to API arguments needed to compressed textures. This puts the burden on the container
  56849. * generator to house the arcane code for determining these for current & future formats.
  56850. *
  56851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56853. *
  56854. * Note: The result of this call is not taken into account when a texture is base64.
  56855. *
  56856. * @param formatsAvailable defines the list of those format families you have created
  56857. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56858. *
  56859. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56860. * @returns The extension selected.
  56861. */
  56862. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56863. }
  56864. }
  56865. declare module BABYLON {
  56866. /** @hidden */
  56867. export var rgbdEncodePixelShader: {
  56868. name: string;
  56869. shader: string;
  56870. };
  56871. }
  56872. declare module BABYLON {
  56873. /**
  56874. * Raw texture data and descriptor sufficient for WebGL texture upload
  56875. */
  56876. export interface EnvironmentTextureInfo {
  56877. /**
  56878. * Version of the environment map
  56879. */
  56880. version: number;
  56881. /**
  56882. * Width of image
  56883. */
  56884. width: number;
  56885. /**
  56886. * Irradiance information stored in the file.
  56887. */
  56888. irradiance: any;
  56889. /**
  56890. * Specular information stored in the file.
  56891. */
  56892. specular: any;
  56893. }
  56894. /**
  56895. * Defines One Image in the file. It requires only the position in the file
  56896. * as well as the length.
  56897. */
  56898. interface BufferImageData {
  56899. /**
  56900. * Length of the image data.
  56901. */
  56902. length: number;
  56903. /**
  56904. * Position of the data from the null terminator delimiting the end of the JSON.
  56905. */
  56906. position: number;
  56907. }
  56908. /**
  56909. * Defines the specular data enclosed in the file.
  56910. * This corresponds to the version 1 of the data.
  56911. */
  56912. export interface EnvironmentTextureSpecularInfoV1 {
  56913. /**
  56914. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56915. */
  56916. specularDataPosition?: number;
  56917. /**
  56918. * This contains all the images data needed to reconstruct the cubemap.
  56919. */
  56920. mipmaps: Array<BufferImageData>;
  56921. /**
  56922. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56923. */
  56924. lodGenerationScale: number;
  56925. }
  56926. /**
  56927. * Sets of helpers addressing the serialization and deserialization of environment texture
  56928. * stored in a BabylonJS env file.
  56929. * Those files are usually stored as .env files.
  56930. */
  56931. export class EnvironmentTextureTools {
  56932. /**
  56933. * Magic number identifying the env file.
  56934. */
  56935. private static _MagicBytes;
  56936. /**
  56937. * Gets the environment info from an env file.
  56938. * @param data The array buffer containing the .env bytes.
  56939. * @returns the environment file info (the json header) if successfully parsed.
  56940. */
  56941. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56942. /**
  56943. * Creates an environment texture from a loaded cube texture.
  56944. * @param texture defines the cube texture to convert in env file
  56945. * @return a promise containing the environment data if succesfull.
  56946. */
  56947. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56948. /**
  56949. * Creates a JSON representation of the spherical data.
  56950. * @param texture defines the texture containing the polynomials
  56951. * @return the JSON representation of the spherical info
  56952. */
  56953. private static _CreateEnvTextureIrradiance;
  56954. /**
  56955. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56956. * @param data the image data
  56957. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56958. * @return the views described by info providing access to the underlying buffer
  56959. */
  56960. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56961. /**
  56962. * Uploads the texture info contained in the env file to the GPU.
  56963. * @param texture defines the internal texture to upload to
  56964. * @param data defines the data to load
  56965. * @param info defines the texture info retrieved through the GetEnvInfo method
  56966. * @returns a promise
  56967. */
  56968. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56969. private static _OnImageReadyAsync;
  56970. /**
  56971. * Uploads the levels of image data to the GPU.
  56972. * @param texture defines the internal texture to upload to
  56973. * @param imageData defines the array buffer views of image data [mipmap][face]
  56974. * @returns a promise
  56975. */
  56976. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56977. /**
  56978. * Uploads spherical polynomials information to the texture.
  56979. * @param texture defines the texture we are trying to upload the information to
  56980. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56981. */
  56982. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56983. /** @hidden */
  56984. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56985. }
  56986. }
  56987. declare module BABYLON {
  56988. /**
  56989. * Class used to inline functions in shader code
  56990. */
  56991. export class ShaderCodeInliner {
  56992. private static readonly _RegexpFindFunctionNameAndType;
  56993. private _sourceCode;
  56994. private _functionDescr;
  56995. private _numMaxIterations;
  56996. /** Gets or sets the token used to mark the functions to inline */
  56997. inlineToken: string;
  56998. /** Gets or sets the debug mode */
  56999. debug: boolean;
  57000. /** Gets the code after the inlining process */
  57001. get code(): string;
  57002. /**
  57003. * Initializes the inliner
  57004. * @param sourceCode shader code source to inline
  57005. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57006. */
  57007. constructor(sourceCode: string, numMaxIterations?: number);
  57008. /**
  57009. * Start the processing of the shader code
  57010. */
  57011. processCode(): void;
  57012. private _collectFunctions;
  57013. private _processInlining;
  57014. private _extractBetweenMarkers;
  57015. private _skipWhitespaces;
  57016. private _removeComments;
  57017. private _replaceFunctionCallsByCode;
  57018. private _findBackward;
  57019. private _escapeRegExp;
  57020. private _replaceNames;
  57021. }
  57022. }
  57023. declare module BABYLON {
  57024. /**
  57025. * Container for accessors for natively-stored mesh data buffers.
  57026. */
  57027. class NativeDataBuffer extends DataBuffer {
  57028. /**
  57029. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57030. */
  57031. nativeIndexBuffer?: any;
  57032. /**
  57033. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57034. */
  57035. nativeVertexBuffer?: any;
  57036. }
  57037. /** @hidden */
  57038. class NativeTexture extends InternalTexture {
  57039. getInternalTexture(): InternalTexture;
  57040. getViewCount(): number;
  57041. }
  57042. /** @hidden */
  57043. export class NativeEngine extends Engine {
  57044. private readonly _native;
  57045. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57046. private readonly INVALID_HANDLE;
  57047. private _boundBuffersVertexArray;
  57048. private _currentDepthTest;
  57049. getHardwareScalingLevel(): number;
  57050. constructor();
  57051. dispose(): void;
  57052. /**
  57053. * Can be used to override the current requestAnimationFrame requester.
  57054. * @hidden
  57055. */
  57056. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57057. /**
  57058. * Override default engine behavior.
  57059. * @param color
  57060. * @param backBuffer
  57061. * @param depth
  57062. * @param stencil
  57063. */
  57064. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57065. /**
  57066. * Gets host document
  57067. * @returns the host document object
  57068. */
  57069. getHostDocument(): Nullable<Document>;
  57070. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57071. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57072. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57073. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57074. [key: string]: VertexBuffer;
  57075. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57076. bindBuffers(vertexBuffers: {
  57077. [key: string]: VertexBuffer;
  57078. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57079. recordVertexArrayObject(vertexBuffers: {
  57080. [key: string]: VertexBuffer;
  57081. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57082. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57083. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57084. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57085. /**
  57086. * Draw a list of indexed primitives
  57087. * @param fillMode defines the primitive to use
  57088. * @param indexStart defines the starting index
  57089. * @param indexCount defines the number of index to draw
  57090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57091. */
  57092. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57093. /**
  57094. * Draw a list of unindexed primitives
  57095. * @param fillMode defines the primitive to use
  57096. * @param verticesStart defines the index of first vertex to draw
  57097. * @param verticesCount defines the count of vertices to draw
  57098. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57099. */
  57100. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57101. createPipelineContext(): IPipelineContext;
  57102. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57103. /** @hidden */
  57104. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57105. /** @hidden */
  57106. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57107. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57108. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57109. protected _setProgram(program: WebGLProgram): void;
  57110. _releaseEffect(effect: Effect): void;
  57111. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57112. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57113. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57114. bindSamplers(effect: Effect): void;
  57115. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57116. getRenderWidth(useScreen?: boolean): number;
  57117. getRenderHeight(useScreen?: boolean): number;
  57118. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57119. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57120. /**
  57121. * Set the z offset to apply to current rendering
  57122. * @param value defines the offset to apply
  57123. */
  57124. setZOffset(value: number): void;
  57125. /**
  57126. * Gets the current value of the zOffset
  57127. * @returns the current zOffset state
  57128. */
  57129. getZOffset(): number;
  57130. /**
  57131. * Enable or disable depth buffering
  57132. * @param enable defines the state to set
  57133. */
  57134. setDepthBuffer(enable: boolean): void;
  57135. /**
  57136. * Gets a boolean indicating if depth writing is enabled
  57137. * @returns the current depth writing state
  57138. */
  57139. getDepthWrite(): boolean;
  57140. setDepthFunctionToGreater(): void;
  57141. setDepthFunctionToGreaterOrEqual(): void;
  57142. setDepthFunctionToLess(): void;
  57143. setDepthFunctionToLessOrEqual(): void;
  57144. /**
  57145. * Enable or disable depth writing
  57146. * @param enable defines the state to set
  57147. */
  57148. setDepthWrite(enable: boolean): void;
  57149. /**
  57150. * Enable or disable color writing
  57151. * @param enable defines the state to set
  57152. */
  57153. setColorWrite(enable: boolean): void;
  57154. /**
  57155. * Gets a boolean indicating if color writing is enabled
  57156. * @returns the current color writing state
  57157. */
  57158. getColorWrite(): boolean;
  57159. /**
  57160. * Sets alpha constants used by some alpha blending modes
  57161. * @param r defines the red component
  57162. * @param g defines the green component
  57163. * @param b defines the blue component
  57164. * @param a defines the alpha component
  57165. */
  57166. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57167. /**
  57168. * Sets the current alpha mode
  57169. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57170. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57171. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57172. */
  57173. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57174. /**
  57175. * Gets the current alpha mode
  57176. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57177. * @returns the current alpha mode
  57178. */
  57179. getAlphaMode(): number;
  57180. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57181. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57182. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57183. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57184. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57185. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57186. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57187. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57188. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57189. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57190. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57191. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57192. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57193. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57194. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57195. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57196. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57197. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57198. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57199. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57200. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57201. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57202. wipeCaches(bruteForce?: boolean): void;
  57203. _createTexture(): WebGLTexture;
  57204. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57205. /**
  57206. * Update the content of a dynamic texture
  57207. * @param texture defines the texture to update
  57208. * @param canvas defines the canvas containing the source
  57209. * @param invertY defines if data must be stored with Y axis inverted
  57210. * @param premulAlpha defines if alpha is stored as premultiplied
  57211. * @param format defines the format of the data
  57212. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57213. */
  57214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57215. /**
  57216. * Usually called from Texture.ts.
  57217. * Passed information to create a WebGLTexture
  57218. * @param url defines a value which contains one of the following:
  57219. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57220. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57221. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57223. * @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)
  57224. * @param scene needed for loading to the correct scene
  57225. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57226. * @param onLoad optional callback to be called upon successful completion
  57227. * @param onError optional callback to be called upon failure
  57228. * @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
  57229. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57230. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57231. * @param forcedExtension defines the extension to use to pick the right loader
  57232. * @param mimeType defines an optional mime type
  57233. * @param loaderOptions options to be passed to the loader
  57234. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57235. */
  57236. 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, loaderOptions?: any): InternalTexture;
  57237. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57238. _releaseFramebufferObjects(texture: InternalTexture): void;
  57239. /**
  57240. * Creates a cube texture
  57241. * @param rootUrl defines the url where the files to load is located
  57242. * @param scene defines the current scene
  57243. * @param files defines the list of files to load (1 per face)
  57244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57245. * @param onLoad defines an optional callback raised when the texture is loaded
  57246. * @param onError defines an optional callback raised if there is an issue to load the texture
  57247. * @param format defines the format of the data
  57248. * @param forcedExtension defines the extension to use to pick the right loader
  57249. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57250. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57251. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57252. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57253. * @returns the cube texture as an InternalTexture
  57254. */
  57255. 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;
  57256. createRenderTargetTexture(size: number | {
  57257. width: number;
  57258. height: number;
  57259. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57260. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57261. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57262. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57263. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57264. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57265. /**
  57266. * Updates a dynamic vertex buffer.
  57267. * @param vertexBuffer the vertex buffer to update
  57268. * @param data the data used to update the vertex buffer
  57269. * @param byteOffset the byte offset of the data (optional)
  57270. * @param byteLength the byte length of the data (optional)
  57271. */
  57272. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57273. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57274. private _updateAnisotropicLevel;
  57275. private _getAddressMode;
  57276. /** @hidden */
  57277. _bindTexture(channel: number, texture: InternalTexture): void;
  57278. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57279. releaseEffects(): void;
  57280. /** @hidden */
  57281. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57282. /** @hidden */
  57283. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57284. /** @hidden */
  57285. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57286. /** @hidden */
  57287. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57288. private _getNativeSamplingMode;
  57289. private _getNativeTextureFormat;
  57290. private _getNativeAlphaMode;
  57291. private _getNativeAttribType;
  57292. }
  57293. }
  57294. declare module BABYLON {
  57295. /**
  57296. * Gather the list of clipboard event types as constants.
  57297. */
  57298. export class ClipboardEventTypes {
  57299. /**
  57300. * The clipboard event is fired when a copy command is active (pressed).
  57301. */
  57302. static readonly COPY: number;
  57303. /**
  57304. * The clipboard event is fired when a cut command is active (pressed).
  57305. */
  57306. static readonly CUT: number;
  57307. /**
  57308. * The clipboard event is fired when a paste command is active (pressed).
  57309. */
  57310. static readonly PASTE: number;
  57311. }
  57312. /**
  57313. * This class is used to store clipboard related info for the onClipboardObservable event.
  57314. */
  57315. export class ClipboardInfo {
  57316. /**
  57317. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57318. */
  57319. type: number;
  57320. /**
  57321. * Defines the related dom event
  57322. */
  57323. event: ClipboardEvent;
  57324. /**
  57325. *Creates an instance of ClipboardInfo.
  57326. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57327. * @param event Defines the related dom event
  57328. */
  57329. constructor(
  57330. /**
  57331. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57332. */
  57333. type: number,
  57334. /**
  57335. * Defines the related dom event
  57336. */
  57337. event: ClipboardEvent);
  57338. /**
  57339. * Get the clipboard event's type from the keycode.
  57340. * @param keyCode Defines the keyCode for the current keyboard event.
  57341. * @return {number}
  57342. */
  57343. static GetTypeFromCharacter(keyCode: number): number;
  57344. }
  57345. }
  57346. declare module BABYLON {
  57347. /**
  57348. * Google Daydream controller
  57349. */
  57350. export class DaydreamController extends WebVRController {
  57351. /**
  57352. * Base Url for the controller model.
  57353. */
  57354. static MODEL_BASE_URL: string;
  57355. /**
  57356. * File name for the controller model.
  57357. */
  57358. static MODEL_FILENAME: string;
  57359. /**
  57360. * Gamepad Id prefix used to identify Daydream Controller.
  57361. */
  57362. static readonly GAMEPAD_ID_PREFIX: string;
  57363. /**
  57364. * Creates a new DaydreamController from a gamepad
  57365. * @param vrGamepad the gamepad that the controller should be created from
  57366. */
  57367. constructor(vrGamepad: any);
  57368. /**
  57369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57370. * @param scene scene in which to add meshes
  57371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57372. */
  57373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57374. /**
  57375. * Called once for each button that changed state since the last frame
  57376. * @param buttonIdx Which button index changed
  57377. * @param state New state of the button
  57378. * @param changes Which properties on the state changed since last frame
  57379. */
  57380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57381. }
  57382. }
  57383. declare module BABYLON {
  57384. /**
  57385. * Gear VR Controller
  57386. */
  57387. export class GearVRController extends WebVRController {
  57388. /**
  57389. * Base Url for the controller model.
  57390. */
  57391. static MODEL_BASE_URL: string;
  57392. /**
  57393. * File name for the controller model.
  57394. */
  57395. static MODEL_FILENAME: string;
  57396. /**
  57397. * Gamepad Id prefix used to identify this controller.
  57398. */
  57399. static readonly GAMEPAD_ID_PREFIX: string;
  57400. private readonly _buttonIndexToObservableNameMap;
  57401. /**
  57402. * Creates a new GearVRController from a gamepad
  57403. * @param vrGamepad the gamepad that the controller should be created from
  57404. */
  57405. constructor(vrGamepad: any);
  57406. /**
  57407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57408. * @param scene scene in which to add meshes
  57409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57410. */
  57411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57412. /**
  57413. * Called once for each button that changed state since the last frame
  57414. * @param buttonIdx Which button index changed
  57415. * @param state New state of the button
  57416. * @param changes Which properties on the state changed since last frame
  57417. */
  57418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57419. }
  57420. }
  57421. declare module BABYLON {
  57422. /**
  57423. * Generic Controller
  57424. */
  57425. export class GenericController extends WebVRController {
  57426. /**
  57427. * Base Url for the controller model.
  57428. */
  57429. static readonly MODEL_BASE_URL: string;
  57430. /**
  57431. * File name for the controller model.
  57432. */
  57433. static readonly MODEL_FILENAME: string;
  57434. /**
  57435. * Creates a new GenericController from a gamepad
  57436. * @param vrGamepad the gamepad that the controller should be created from
  57437. */
  57438. constructor(vrGamepad: any);
  57439. /**
  57440. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57441. * @param scene scene in which to add meshes
  57442. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57443. */
  57444. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57445. /**
  57446. * Called once for each button that changed state since the last frame
  57447. * @param buttonIdx Which button index changed
  57448. * @param state New state of the button
  57449. * @param changes Which properties on the state changed since last frame
  57450. */
  57451. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57452. }
  57453. }
  57454. declare module BABYLON {
  57455. /**
  57456. * Oculus Touch Controller
  57457. */
  57458. export class OculusTouchController extends WebVRController {
  57459. /**
  57460. * Base Url for the controller model.
  57461. */
  57462. static MODEL_BASE_URL: string;
  57463. /**
  57464. * File name for the left controller model.
  57465. */
  57466. static MODEL_LEFT_FILENAME: string;
  57467. /**
  57468. * File name for the right controller model.
  57469. */
  57470. static MODEL_RIGHT_FILENAME: string;
  57471. /**
  57472. * Base Url for the Quest controller model.
  57473. */
  57474. static QUEST_MODEL_BASE_URL: string;
  57475. /**
  57476. * @hidden
  57477. * If the controllers are running on a device that needs the updated Quest controller models
  57478. */
  57479. static _IsQuest: boolean;
  57480. /**
  57481. * Fired when the secondary trigger on this controller is modified
  57482. */
  57483. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57484. /**
  57485. * Fired when the thumb rest on this controller is modified
  57486. */
  57487. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57488. /**
  57489. * Creates a new OculusTouchController from a gamepad
  57490. * @param vrGamepad the gamepad that the controller should be created from
  57491. */
  57492. constructor(vrGamepad: any);
  57493. /**
  57494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57495. * @param scene scene in which to add meshes
  57496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57497. */
  57498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57499. /**
  57500. * Fired when the A button on this controller is modified
  57501. */
  57502. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57503. /**
  57504. * Fired when the B button on this controller is modified
  57505. */
  57506. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57507. /**
  57508. * Fired when the X button on this controller is modified
  57509. */
  57510. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57511. /**
  57512. * Fired when the Y button on this controller is modified
  57513. */
  57514. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57515. /**
  57516. * Called once for each button that changed state since the last frame
  57517. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57518. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57519. * 2) secondary trigger (same)
  57520. * 3) A (right) X (left), touch, pressed = value
  57521. * 4) B / Y
  57522. * 5) thumb rest
  57523. * @param buttonIdx Which button index changed
  57524. * @param state New state of the button
  57525. * @param changes Which properties on the state changed since last frame
  57526. */
  57527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57528. }
  57529. }
  57530. declare module BABYLON {
  57531. /**
  57532. * Vive Controller
  57533. */
  57534. export class ViveController extends WebVRController {
  57535. /**
  57536. * Base Url for the controller model.
  57537. */
  57538. static MODEL_BASE_URL: string;
  57539. /**
  57540. * File name for the controller model.
  57541. */
  57542. static MODEL_FILENAME: string;
  57543. /**
  57544. * Creates a new ViveController from a gamepad
  57545. * @param vrGamepad the gamepad that the controller should be created from
  57546. */
  57547. constructor(vrGamepad: any);
  57548. /**
  57549. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57550. * @param scene scene in which to add meshes
  57551. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57552. */
  57553. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57554. /**
  57555. * Fired when the left button on this controller is modified
  57556. */
  57557. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57558. /**
  57559. * Fired when the right button on this controller is modified
  57560. */
  57561. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57562. /**
  57563. * Fired when the menu button on this controller is modified
  57564. */
  57565. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57566. /**
  57567. * Called once for each button that changed state since the last frame
  57568. * Vive mapping:
  57569. * 0: touchpad
  57570. * 1: trigger
  57571. * 2: left AND right buttons
  57572. * 3: menu button
  57573. * @param buttonIdx Which button index changed
  57574. * @param state New state of the button
  57575. * @param changes Which properties on the state changed since last frame
  57576. */
  57577. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57578. }
  57579. }
  57580. declare module BABYLON {
  57581. /**
  57582. * Defines the WindowsMotionController object that the state of the windows motion controller
  57583. */
  57584. export class WindowsMotionController extends WebVRController {
  57585. /**
  57586. * The base url used to load the left and right controller models
  57587. */
  57588. static MODEL_BASE_URL: string;
  57589. /**
  57590. * The name of the left controller model file
  57591. */
  57592. static MODEL_LEFT_FILENAME: string;
  57593. /**
  57594. * The name of the right controller model file
  57595. */
  57596. static MODEL_RIGHT_FILENAME: string;
  57597. /**
  57598. * The controller name prefix for this controller type
  57599. */
  57600. static readonly GAMEPAD_ID_PREFIX: string;
  57601. /**
  57602. * The controller id pattern for this controller type
  57603. */
  57604. private static readonly GAMEPAD_ID_PATTERN;
  57605. private _loadedMeshInfo;
  57606. protected readonly _mapping: {
  57607. buttons: string[];
  57608. buttonMeshNames: {
  57609. trigger: string;
  57610. menu: string;
  57611. grip: string;
  57612. thumbstick: string;
  57613. trackpad: string;
  57614. };
  57615. buttonObservableNames: {
  57616. trigger: string;
  57617. menu: string;
  57618. grip: string;
  57619. thumbstick: string;
  57620. trackpad: string;
  57621. };
  57622. axisMeshNames: string[];
  57623. pointingPoseMeshName: string;
  57624. };
  57625. /**
  57626. * Fired when the trackpad on this controller is clicked
  57627. */
  57628. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57629. /**
  57630. * Fired when the trackpad on this controller is modified
  57631. */
  57632. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57633. /**
  57634. * The current x and y values of this controller's trackpad
  57635. */
  57636. trackpad: StickValues;
  57637. /**
  57638. * Creates a new WindowsMotionController from a gamepad
  57639. * @param vrGamepad the gamepad that the controller should be created from
  57640. */
  57641. constructor(vrGamepad: any);
  57642. /**
  57643. * Fired when the trigger on this controller is modified
  57644. */
  57645. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57646. /**
  57647. * Fired when the menu button on this controller is modified
  57648. */
  57649. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57650. /**
  57651. * Fired when the grip button on this controller is modified
  57652. */
  57653. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57654. /**
  57655. * Fired when the thumbstick button on this controller is modified
  57656. */
  57657. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57658. /**
  57659. * Fired when the touchpad button on this controller is modified
  57660. */
  57661. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57662. /**
  57663. * Fired when the touchpad values on this controller are modified
  57664. */
  57665. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57666. protected _updateTrackpad(): void;
  57667. /**
  57668. * Called once per frame by the engine.
  57669. */
  57670. update(): void;
  57671. /**
  57672. * Called once for each button that changed state since the last frame
  57673. * @param buttonIdx Which button index changed
  57674. * @param state New state of the button
  57675. * @param changes Which properties on the state changed since last frame
  57676. */
  57677. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57678. /**
  57679. * Moves the buttons on the controller mesh based on their current state
  57680. * @param buttonName the name of the button to move
  57681. * @param buttonValue the value of the button which determines the buttons new position
  57682. */
  57683. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57684. /**
  57685. * Moves the axis on the controller mesh based on its current state
  57686. * @param axis the index of the axis
  57687. * @param axisValue the value of the axis which determines the meshes new position
  57688. * @hidden
  57689. */
  57690. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57691. /**
  57692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57693. * @param scene scene in which to add meshes
  57694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57695. */
  57696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57697. /**
  57698. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57699. * can be transformed by button presses and axes values, based on this._mapping.
  57700. *
  57701. * @param scene scene in which the meshes exist
  57702. * @param meshes list of meshes that make up the controller model to process
  57703. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57704. */
  57705. private processModel;
  57706. private createMeshInfo;
  57707. /**
  57708. * Gets the ray of the controller in the direction the controller is pointing
  57709. * @param length the length the resulting ray should be
  57710. * @returns a ray in the direction the controller is pointing
  57711. */
  57712. getForwardRay(length?: number): Ray;
  57713. /**
  57714. * Disposes of the controller
  57715. */
  57716. dispose(): void;
  57717. }
  57718. /**
  57719. * This class represents a new windows motion controller in XR.
  57720. */
  57721. export class XRWindowsMotionController extends WindowsMotionController {
  57722. /**
  57723. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57724. */
  57725. protected readonly _mapping: {
  57726. buttons: string[];
  57727. buttonMeshNames: {
  57728. trigger: string;
  57729. menu: string;
  57730. grip: string;
  57731. thumbstick: string;
  57732. trackpad: string;
  57733. };
  57734. buttonObservableNames: {
  57735. trigger: string;
  57736. menu: string;
  57737. grip: string;
  57738. thumbstick: string;
  57739. trackpad: string;
  57740. };
  57741. axisMeshNames: string[];
  57742. pointingPoseMeshName: string;
  57743. };
  57744. /**
  57745. * Construct a new XR-Based windows motion controller
  57746. *
  57747. * @param gamepadInfo the gamepad object from the browser
  57748. */
  57749. constructor(gamepadInfo: any);
  57750. /**
  57751. * holds the thumbstick values (X,Y)
  57752. */
  57753. thumbstickValues: StickValues;
  57754. /**
  57755. * Fired when the thumbstick on this controller is clicked
  57756. */
  57757. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57758. /**
  57759. * Fired when the thumbstick on this controller is modified
  57760. */
  57761. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57762. /**
  57763. * Fired when the touchpad button on this controller is modified
  57764. */
  57765. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57766. /**
  57767. * Fired when the touchpad values on this controller are modified
  57768. */
  57769. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57770. /**
  57771. * Fired when the thumbstick button on this controller is modified
  57772. * here to prevent breaking changes
  57773. */
  57774. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57775. /**
  57776. * updating the thumbstick(!) and not the trackpad.
  57777. * This is named this way due to the difference between WebVR and XR and to avoid
  57778. * changing the parent class.
  57779. */
  57780. protected _updateTrackpad(): void;
  57781. /**
  57782. * Disposes the class with joy
  57783. */
  57784. dispose(): void;
  57785. }
  57786. }
  57787. declare module BABYLON {
  57788. /**
  57789. * A directional light is defined by a direction (what a surprise!).
  57790. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57791. * 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.
  57792. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57793. */
  57794. export class DirectionalLight extends ShadowLight {
  57795. private _shadowFrustumSize;
  57796. /**
  57797. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57798. */
  57799. get shadowFrustumSize(): number;
  57800. /**
  57801. * Specifies a fix frustum size for the shadow generation.
  57802. */
  57803. set shadowFrustumSize(value: number);
  57804. private _shadowOrthoScale;
  57805. /**
  57806. * Gets the shadow projection scale against the optimal computed one.
  57807. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57808. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57809. */
  57810. get shadowOrthoScale(): number;
  57811. /**
  57812. * Sets the shadow projection scale against the optimal computed one.
  57813. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57814. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57815. */
  57816. set shadowOrthoScale(value: number);
  57817. /**
  57818. * Automatically compute the projection matrix to best fit (including all the casters)
  57819. * on each frame.
  57820. */
  57821. autoUpdateExtends: boolean;
  57822. /**
  57823. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57824. * on each frame. autoUpdateExtends must be set to true for this to work
  57825. */
  57826. autoCalcShadowZBounds: boolean;
  57827. private _orthoLeft;
  57828. private _orthoRight;
  57829. private _orthoTop;
  57830. private _orthoBottom;
  57831. /**
  57832. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57833. * The directional light is emitted from everywhere in the given direction.
  57834. * It can cast shadows.
  57835. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57836. * @param name The friendly name of the light
  57837. * @param direction The direction of the light
  57838. * @param scene The scene the light belongs to
  57839. */
  57840. constructor(name: string, direction: Vector3, scene: Scene);
  57841. /**
  57842. * Returns the string "DirectionalLight".
  57843. * @return The class name
  57844. */
  57845. getClassName(): string;
  57846. /**
  57847. * Returns the integer 1.
  57848. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57849. */
  57850. getTypeID(): number;
  57851. /**
  57852. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57853. * Returns the DirectionalLight Shadow projection matrix.
  57854. */
  57855. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57856. /**
  57857. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57858. * Returns the DirectionalLight Shadow projection matrix.
  57859. */
  57860. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57861. /**
  57862. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57863. * Returns the DirectionalLight Shadow projection matrix.
  57864. */
  57865. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57866. protected _buildUniformLayout(): void;
  57867. /**
  57868. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57869. * @param effect The effect to update
  57870. * @param lightIndex The index of the light in the effect to update
  57871. * @returns The directional light
  57872. */
  57873. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57874. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57875. /**
  57876. * Gets the minZ used for shadow according to both the scene and the light.
  57877. *
  57878. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57879. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57880. * @param activeCamera The camera we are returning the min for
  57881. * @returns the depth min z
  57882. */
  57883. getDepthMinZ(activeCamera: Camera): number;
  57884. /**
  57885. * Gets the maxZ used for shadow according to both the scene and the light.
  57886. *
  57887. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57888. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57889. * @param activeCamera The camera we are returning the max for
  57890. * @returns the depth max z
  57891. */
  57892. getDepthMaxZ(activeCamera: Camera): number;
  57893. /**
  57894. * Prepares the list of defines specific to the light type.
  57895. * @param defines the list of defines
  57896. * @param lightIndex defines the index of the light for the effect
  57897. */
  57898. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57899. }
  57900. }
  57901. declare module BABYLON {
  57902. /**
  57903. * Class containing static functions to help procedurally build meshes
  57904. */
  57905. export class HemisphereBuilder {
  57906. /**
  57907. * Creates a hemisphere mesh
  57908. * @param name defines the name of the mesh
  57909. * @param options defines the options used to create the mesh
  57910. * @param scene defines the hosting scene
  57911. * @returns the hemisphere mesh
  57912. */
  57913. static CreateHemisphere(name: string, options: {
  57914. segments?: number;
  57915. diameter?: number;
  57916. sideOrientation?: number;
  57917. }, scene: any): Mesh;
  57918. }
  57919. }
  57920. declare module BABYLON {
  57921. /**
  57922. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57923. * These values define a cone of light starting from the position, emitting toward the direction.
  57924. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57925. * and the exponent defines the speed of the decay of the light with distance (reach).
  57926. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57927. */
  57928. export class SpotLight extends ShadowLight {
  57929. private _angle;
  57930. private _innerAngle;
  57931. private _cosHalfAngle;
  57932. private _lightAngleScale;
  57933. private _lightAngleOffset;
  57934. /**
  57935. * Gets the cone angle of the spot light in Radians.
  57936. */
  57937. get angle(): number;
  57938. /**
  57939. * Sets the cone angle of the spot light in Radians.
  57940. */
  57941. set angle(value: number);
  57942. /**
  57943. * Only used in gltf falloff mode, this defines the angle where
  57944. * the directional falloff will start before cutting at angle which could be seen
  57945. * as outer angle.
  57946. */
  57947. get innerAngle(): number;
  57948. /**
  57949. * Only used in gltf falloff mode, this defines the angle where
  57950. * the directional falloff will start before cutting at angle which could be seen
  57951. * as outer angle.
  57952. */
  57953. set innerAngle(value: number);
  57954. private _shadowAngleScale;
  57955. /**
  57956. * Allows scaling the angle of the light for shadow generation only.
  57957. */
  57958. get shadowAngleScale(): number;
  57959. /**
  57960. * Allows scaling the angle of the light for shadow generation only.
  57961. */
  57962. set shadowAngleScale(value: number);
  57963. /**
  57964. * The light decay speed with the distance from the emission spot.
  57965. */
  57966. exponent: number;
  57967. private _projectionTextureMatrix;
  57968. /**
  57969. * Allows reading the projecton texture
  57970. */
  57971. get projectionTextureMatrix(): Matrix;
  57972. protected _projectionTextureLightNear: number;
  57973. /**
  57974. * Gets the near clip of the Spotlight for texture projection.
  57975. */
  57976. get projectionTextureLightNear(): number;
  57977. /**
  57978. * Sets the near clip of the Spotlight for texture projection.
  57979. */
  57980. set projectionTextureLightNear(value: number);
  57981. protected _projectionTextureLightFar: number;
  57982. /**
  57983. * Gets the far clip of the Spotlight for texture projection.
  57984. */
  57985. get projectionTextureLightFar(): number;
  57986. /**
  57987. * Sets the far clip of the Spotlight for texture projection.
  57988. */
  57989. set projectionTextureLightFar(value: number);
  57990. protected _projectionTextureUpDirection: Vector3;
  57991. /**
  57992. * Gets the Up vector of the Spotlight for texture projection.
  57993. */
  57994. get projectionTextureUpDirection(): Vector3;
  57995. /**
  57996. * Sets the Up vector of the Spotlight for texture projection.
  57997. */
  57998. set projectionTextureUpDirection(value: Vector3);
  57999. private _projectionTexture;
  58000. /**
  58001. * Gets the projection texture of the light.
  58002. */
  58003. get projectionTexture(): Nullable<BaseTexture>;
  58004. /**
  58005. * Sets the projection texture of the light.
  58006. */
  58007. set projectionTexture(value: Nullable<BaseTexture>);
  58008. private static _IsProceduralTexture;
  58009. private static _IsTexture;
  58010. private _projectionTextureViewLightDirty;
  58011. private _projectionTextureProjectionLightDirty;
  58012. private _projectionTextureDirty;
  58013. private _projectionTextureViewTargetVector;
  58014. private _projectionTextureViewLightMatrix;
  58015. private _projectionTextureProjectionLightMatrix;
  58016. private _projectionTextureScalingMatrix;
  58017. /**
  58018. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58019. * It can cast shadows.
  58020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58021. * @param name The light friendly name
  58022. * @param position The position of the spot light in the scene
  58023. * @param direction The direction of the light in the scene
  58024. * @param angle The cone angle of the light in Radians
  58025. * @param exponent The light decay speed with the distance from the emission spot
  58026. * @param scene The scene the lights belongs to
  58027. */
  58028. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58029. /**
  58030. * Returns the string "SpotLight".
  58031. * @returns the class name
  58032. */
  58033. getClassName(): string;
  58034. /**
  58035. * Returns the integer 2.
  58036. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58037. */
  58038. getTypeID(): number;
  58039. /**
  58040. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58041. */
  58042. protected _setDirection(value: Vector3): void;
  58043. /**
  58044. * Overrides the position setter to recompute the projection texture view light Matrix.
  58045. */
  58046. protected _setPosition(value: Vector3): void;
  58047. /**
  58048. * 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.
  58049. * Returns the SpotLight.
  58050. */
  58051. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58052. protected _computeProjectionTextureViewLightMatrix(): void;
  58053. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58054. /**
  58055. * Main function for light texture projection matrix computing.
  58056. */
  58057. protected _computeProjectionTextureMatrix(): void;
  58058. protected _buildUniformLayout(): void;
  58059. private _computeAngleValues;
  58060. /**
  58061. * Sets the passed Effect "effect" with the Light textures.
  58062. * @param effect The effect to update
  58063. * @param lightIndex The index of the light in the effect to update
  58064. * @returns The light
  58065. */
  58066. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58067. /**
  58068. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58069. * @param effect The effect to update
  58070. * @param lightIndex The index of the light in the effect to update
  58071. * @returns The spot light
  58072. */
  58073. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58074. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58075. /**
  58076. * Disposes the light and the associated resources.
  58077. */
  58078. dispose(): void;
  58079. /**
  58080. * Prepares the list of defines specific to the light type.
  58081. * @param defines the list of defines
  58082. * @param lightIndex defines the index of the light for the effect
  58083. */
  58084. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58085. }
  58086. }
  58087. declare module BABYLON {
  58088. /**
  58089. * Gizmo that enables viewing a light
  58090. */
  58091. export class LightGizmo extends Gizmo {
  58092. private _lightMesh;
  58093. private _material;
  58094. private _cachedPosition;
  58095. private _cachedForward;
  58096. private _attachedMeshParent;
  58097. private _pointerObserver;
  58098. /**
  58099. * Event that fires each time the gizmo is clicked
  58100. */
  58101. onClickedObservable: Observable<Light>;
  58102. /**
  58103. * Creates a LightGizmo
  58104. * @param gizmoLayer The utility layer the gizmo will be added to
  58105. */
  58106. constructor(gizmoLayer?: UtilityLayerRenderer);
  58107. private _light;
  58108. /**
  58109. * The light that the gizmo is attached to
  58110. */
  58111. set light(light: Nullable<Light>);
  58112. get light(): Nullable<Light>;
  58113. /**
  58114. * Gets the material used to render the light gizmo
  58115. */
  58116. get material(): StandardMaterial;
  58117. /**
  58118. * @hidden
  58119. * Updates the gizmo to match the attached mesh's position/rotation
  58120. */
  58121. protected _update(): void;
  58122. private static _Scale;
  58123. /**
  58124. * Creates the lines for a light mesh
  58125. */
  58126. private static _CreateLightLines;
  58127. /**
  58128. * Disposes of the light gizmo
  58129. */
  58130. dispose(): void;
  58131. private static _CreateHemisphericLightMesh;
  58132. private static _CreatePointLightMesh;
  58133. private static _CreateSpotLightMesh;
  58134. private static _CreateDirectionalLightMesh;
  58135. }
  58136. }
  58137. declare module BABYLON {
  58138. /**
  58139. * Gizmo that enables viewing a camera
  58140. */
  58141. export class CameraGizmo extends Gizmo {
  58142. private _cameraMesh;
  58143. private _cameraLinesMesh;
  58144. private _material;
  58145. private _pointerObserver;
  58146. /**
  58147. * Event that fires each time the gizmo is clicked
  58148. */
  58149. onClickedObservable: Observable<Camera>;
  58150. /**
  58151. * Creates a CameraGizmo
  58152. * @param gizmoLayer The utility layer the gizmo will be added to
  58153. */
  58154. constructor(gizmoLayer?: UtilityLayerRenderer);
  58155. private _camera;
  58156. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58157. get displayFrustum(): boolean;
  58158. set displayFrustum(value: boolean);
  58159. /**
  58160. * The camera that the gizmo is attached to
  58161. */
  58162. set camera(camera: Nullable<Camera>);
  58163. get camera(): Nullable<Camera>;
  58164. /**
  58165. * Gets the material used to render the camera gizmo
  58166. */
  58167. get material(): StandardMaterial;
  58168. /**
  58169. * @hidden
  58170. * Updates the gizmo to match the attached mesh's position/rotation
  58171. */
  58172. protected _update(): void;
  58173. private static _Scale;
  58174. private _invProjection;
  58175. /**
  58176. * Disposes of the camera gizmo
  58177. */
  58178. dispose(): void;
  58179. private static _CreateCameraMesh;
  58180. private static _CreateCameraFrustum;
  58181. }
  58182. }
  58183. declare module BABYLON {
  58184. /** @hidden */
  58185. export var backgroundFragmentDeclaration: {
  58186. name: string;
  58187. shader: string;
  58188. };
  58189. }
  58190. declare module BABYLON {
  58191. /** @hidden */
  58192. export var backgroundUboDeclaration: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module BABYLON {
  58198. /** @hidden */
  58199. export var backgroundPixelShader: {
  58200. name: string;
  58201. shader: string;
  58202. };
  58203. }
  58204. declare module BABYLON {
  58205. /** @hidden */
  58206. export var backgroundVertexDeclaration: {
  58207. name: string;
  58208. shader: string;
  58209. };
  58210. }
  58211. declare module BABYLON {
  58212. /** @hidden */
  58213. export var backgroundVertexShader: {
  58214. name: string;
  58215. shader: string;
  58216. };
  58217. }
  58218. declare module BABYLON {
  58219. /**
  58220. * Background material used to create an efficient environement around your scene.
  58221. */
  58222. export class BackgroundMaterial extends PushMaterial {
  58223. /**
  58224. * Standard reflectance value at parallel view angle.
  58225. */
  58226. static StandardReflectance0: number;
  58227. /**
  58228. * Standard reflectance value at grazing angle.
  58229. */
  58230. static StandardReflectance90: number;
  58231. protected _primaryColor: Color3;
  58232. /**
  58233. * Key light Color (multiply against the environement texture)
  58234. */
  58235. primaryColor: Color3;
  58236. protected __perceptualColor: Nullable<Color3>;
  58237. /**
  58238. * Experimental Internal Use Only.
  58239. *
  58240. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58241. * This acts as a helper to set the primary color to a more "human friendly" value.
  58242. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58243. * output color as close as possible from the chosen value.
  58244. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58245. * part of lighting setup.)
  58246. */
  58247. get _perceptualColor(): Nullable<Color3>;
  58248. set _perceptualColor(value: Nullable<Color3>);
  58249. protected _primaryColorShadowLevel: float;
  58250. /**
  58251. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58252. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58253. */
  58254. get primaryColorShadowLevel(): float;
  58255. set primaryColorShadowLevel(value: float);
  58256. protected _primaryColorHighlightLevel: float;
  58257. /**
  58258. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58259. * The primary color is used at the level chosen to define what the white area would look.
  58260. */
  58261. get primaryColorHighlightLevel(): float;
  58262. set primaryColorHighlightLevel(value: float);
  58263. protected _reflectionTexture: Nullable<BaseTexture>;
  58264. /**
  58265. * Reflection Texture used in the material.
  58266. * Should be author in a specific way for the best result (refer to the documentation).
  58267. */
  58268. reflectionTexture: Nullable<BaseTexture>;
  58269. protected _reflectionBlur: float;
  58270. /**
  58271. * Reflection Texture level of blur.
  58272. *
  58273. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58274. * texture twice.
  58275. */
  58276. reflectionBlur: float;
  58277. protected _diffuseTexture: Nullable<BaseTexture>;
  58278. /**
  58279. * Diffuse Texture used in the material.
  58280. * Should be author in a specific way for the best result (refer to the documentation).
  58281. */
  58282. diffuseTexture: Nullable<BaseTexture>;
  58283. protected _shadowLights: Nullable<IShadowLight[]>;
  58284. /**
  58285. * Specify the list of lights casting shadow on the material.
  58286. * All scene shadow lights will be included if null.
  58287. */
  58288. shadowLights: Nullable<IShadowLight[]>;
  58289. protected _shadowLevel: float;
  58290. /**
  58291. * Helps adjusting the shadow to a softer level if required.
  58292. * 0 means black shadows and 1 means no shadows.
  58293. */
  58294. shadowLevel: float;
  58295. protected _sceneCenter: Vector3;
  58296. /**
  58297. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58298. * It is usually zero but might be interesting to modify according to your setup.
  58299. */
  58300. sceneCenter: Vector3;
  58301. protected _opacityFresnel: boolean;
  58302. /**
  58303. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58304. * This helps ensuring a nice transition when the camera goes under the ground.
  58305. */
  58306. opacityFresnel: boolean;
  58307. protected _reflectionFresnel: boolean;
  58308. /**
  58309. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58310. * This helps adding a mirror texture on the ground.
  58311. */
  58312. reflectionFresnel: boolean;
  58313. protected _reflectionFalloffDistance: number;
  58314. /**
  58315. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58316. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58317. */
  58318. reflectionFalloffDistance: number;
  58319. protected _reflectionAmount: number;
  58320. /**
  58321. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58322. */
  58323. reflectionAmount: number;
  58324. protected _reflectionReflectance0: number;
  58325. /**
  58326. * This specifies the weight of the reflection at grazing angle.
  58327. */
  58328. reflectionReflectance0: number;
  58329. protected _reflectionReflectance90: number;
  58330. /**
  58331. * This specifies the weight of the reflection at a perpendicular point of view.
  58332. */
  58333. reflectionReflectance90: number;
  58334. /**
  58335. * Sets the reflection reflectance fresnel values according to the default standard
  58336. * empirically know to work well :-)
  58337. */
  58338. set reflectionStandardFresnelWeight(value: number);
  58339. protected _useRGBColor: boolean;
  58340. /**
  58341. * Helps to directly use the maps channels instead of their level.
  58342. */
  58343. useRGBColor: boolean;
  58344. protected _enableNoise: boolean;
  58345. /**
  58346. * This helps reducing the banding effect that could occur on the background.
  58347. */
  58348. enableNoise: boolean;
  58349. /**
  58350. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58351. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58352. * Recommended to be keep at 1.0 except for special cases.
  58353. */
  58354. get fovMultiplier(): number;
  58355. set fovMultiplier(value: number);
  58356. private _fovMultiplier;
  58357. /**
  58358. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58359. */
  58360. useEquirectangularFOV: boolean;
  58361. private _maxSimultaneousLights;
  58362. /**
  58363. * Number of Simultaneous lights allowed on the material.
  58364. */
  58365. maxSimultaneousLights: int;
  58366. private _shadowOnly;
  58367. /**
  58368. * Make the material only render shadows
  58369. */
  58370. shadowOnly: boolean;
  58371. /**
  58372. * Default configuration related to image processing available in the Background Material.
  58373. */
  58374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58375. /**
  58376. * Keep track of the image processing observer to allow dispose and replace.
  58377. */
  58378. private _imageProcessingObserver;
  58379. /**
  58380. * Attaches a new image processing configuration to the PBR Material.
  58381. * @param configuration (if null the scene configuration will be use)
  58382. */
  58383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58384. /**
  58385. * Gets the image processing configuration used either in this material.
  58386. */
  58387. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58388. /**
  58389. * Sets the Default image processing configuration used either in the this material.
  58390. *
  58391. * If sets to null, the scene one is in use.
  58392. */
  58393. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58394. /**
  58395. * Gets wether the color curves effect is enabled.
  58396. */
  58397. get cameraColorCurvesEnabled(): boolean;
  58398. /**
  58399. * Sets wether the color curves effect is enabled.
  58400. */
  58401. set cameraColorCurvesEnabled(value: boolean);
  58402. /**
  58403. * Gets wether the color grading effect is enabled.
  58404. */
  58405. get cameraColorGradingEnabled(): boolean;
  58406. /**
  58407. * Gets wether the color grading effect is enabled.
  58408. */
  58409. set cameraColorGradingEnabled(value: boolean);
  58410. /**
  58411. * Gets wether tonemapping is enabled or not.
  58412. */
  58413. get cameraToneMappingEnabled(): boolean;
  58414. /**
  58415. * Sets wether tonemapping is enabled or not
  58416. */
  58417. set cameraToneMappingEnabled(value: boolean);
  58418. /**
  58419. * The camera exposure used on this material.
  58420. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58421. * This corresponds to a photographic exposure.
  58422. */
  58423. get cameraExposure(): float;
  58424. /**
  58425. * The camera exposure used on this material.
  58426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58427. * This corresponds to a photographic exposure.
  58428. */
  58429. set cameraExposure(value: float);
  58430. /**
  58431. * Gets The camera contrast used on this material.
  58432. */
  58433. get cameraContrast(): float;
  58434. /**
  58435. * Sets The camera contrast used on this material.
  58436. */
  58437. set cameraContrast(value: float);
  58438. /**
  58439. * Gets the Color Grading 2D Lookup Texture.
  58440. */
  58441. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58442. /**
  58443. * Sets the Color Grading 2D Lookup Texture.
  58444. */
  58445. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58446. /**
  58447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58449. * 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;
  58450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58451. */
  58452. get cameraColorCurves(): Nullable<ColorCurves>;
  58453. /**
  58454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58456. * 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;
  58457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58458. */
  58459. set cameraColorCurves(value: Nullable<ColorCurves>);
  58460. /**
  58461. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58462. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58463. */
  58464. switchToBGR: boolean;
  58465. private _renderTargets;
  58466. private _reflectionControls;
  58467. private _white;
  58468. private _primaryShadowColor;
  58469. private _primaryHighlightColor;
  58470. /**
  58471. * Instantiates a Background Material in the given scene
  58472. * @param name The friendly name of the material
  58473. * @param scene The scene to add the material to
  58474. */
  58475. constructor(name: string, scene: Scene);
  58476. /**
  58477. * Gets a boolean indicating that current material needs to register RTT
  58478. */
  58479. get hasRenderTargetTextures(): boolean;
  58480. /**
  58481. * The entire material has been created in order to prevent overdraw.
  58482. * @returns false
  58483. */
  58484. needAlphaTesting(): boolean;
  58485. /**
  58486. * The entire material has been created in order to prevent overdraw.
  58487. * @returns true if blending is enable
  58488. */
  58489. needAlphaBlending(): boolean;
  58490. /**
  58491. * Checks wether the material is ready to be rendered for a given mesh.
  58492. * @param mesh The mesh to render
  58493. * @param subMesh The submesh to check against
  58494. * @param useInstances Specify wether or not the material is used with instances
  58495. * @returns true if all the dependencies are ready (Textures, Effects...)
  58496. */
  58497. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58498. /**
  58499. * Compute the primary color according to the chosen perceptual color.
  58500. */
  58501. private _computePrimaryColorFromPerceptualColor;
  58502. /**
  58503. * Compute the highlights and shadow colors according to their chosen levels.
  58504. */
  58505. private _computePrimaryColors;
  58506. /**
  58507. * Build the uniform buffer used in the material.
  58508. */
  58509. buildUniformLayout(): void;
  58510. /**
  58511. * Unbind the material.
  58512. */
  58513. unbind(): void;
  58514. /**
  58515. * Bind only the world matrix to the material.
  58516. * @param world The world matrix to bind.
  58517. */
  58518. bindOnlyWorldMatrix(world: Matrix): void;
  58519. /**
  58520. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58521. * @param world The world matrix to bind.
  58522. * @param subMesh The submesh to bind for.
  58523. */
  58524. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58525. /**
  58526. * Checks to see if a texture is used in the material.
  58527. * @param texture - Base texture to use.
  58528. * @returns - Boolean specifying if a texture is used in the material.
  58529. */
  58530. hasTexture(texture: BaseTexture): boolean;
  58531. /**
  58532. * Dispose the material.
  58533. * @param forceDisposeEffect Force disposal of the associated effect.
  58534. * @param forceDisposeTextures Force disposal of the associated textures.
  58535. */
  58536. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58537. /**
  58538. * Clones the material.
  58539. * @param name The cloned name.
  58540. * @returns The cloned material.
  58541. */
  58542. clone(name: string): BackgroundMaterial;
  58543. /**
  58544. * Serializes the current material to its JSON representation.
  58545. * @returns The JSON representation.
  58546. */
  58547. serialize(): any;
  58548. /**
  58549. * Gets the class name of the material
  58550. * @returns "BackgroundMaterial"
  58551. */
  58552. getClassName(): string;
  58553. /**
  58554. * Parse a JSON input to create back a background material.
  58555. * @param source The JSON data to parse
  58556. * @param scene The scene to create the parsed material in
  58557. * @param rootUrl The root url of the assets the material depends upon
  58558. * @returns the instantiated BackgroundMaterial.
  58559. */
  58560. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58561. }
  58562. }
  58563. declare module BABYLON {
  58564. /**
  58565. * Represents the different options available during the creation of
  58566. * a Environment helper.
  58567. *
  58568. * This can control the default ground, skybox and image processing setup of your scene.
  58569. */
  58570. export interface IEnvironmentHelperOptions {
  58571. /**
  58572. * Specifies whether or not to create a ground.
  58573. * True by default.
  58574. */
  58575. createGround: boolean;
  58576. /**
  58577. * Specifies the ground size.
  58578. * 15 by default.
  58579. */
  58580. groundSize: number;
  58581. /**
  58582. * The texture used on the ground for the main color.
  58583. * Comes from the BabylonJS CDN by default.
  58584. *
  58585. * Remarks: Can be either a texture or a url.
  58586. */
  58587. groundTexture: string | BaseTexture;
  58588. /**
  58589. * The color mixed in the ground texture by default.
  58590. * BabylonJS clearColor by default.
  58591. */
  58592. groundColor: Color3;
  58593. /**
  58594. * Specifies the ground opacity.
  58595. * 1 by default.
  58596. */
  58597. groundOpacity: number;
  58598. /**
  58599. * Enables the ground to receive shadows.
  58600. * True by default.
  58601. */
  58602. enableGroundShadow: boolean;
  58603. /**
  58604. * Helps preventing the shadow to be fully black on the ground.
  58605. * 0.5 by default.
  58606. */
  58607. groundShadowLevel: number;
  58608. /**
  58609. * Creates a mirror texture attach to the ground.
  58610. * false by default.
  58611. */
  58612. enableGroundMirror: boolean;
  58613. /**
  58614. * Specifies the ground mirror size ratio.
  58615. * 0.3 by default as the default kernel is 64.
  58616. */
  58617. groundMirrorSizeRatio: number;
  58618. /**
  58619. * Specifies the ground mirror blur kernel size.
  58620. * 64 by default.
  58621. */
  58622. groundMirrorBlurKernel: number;
  58623. /**
  58624. * Specifies the ground mirror visibility amount.
  58625. * 1 by default
  58626. */
  58627. groundMirrorAmount: number;
  58628. /**
  58629. * Specifies the ground mirror reflectance weight.
  58630. * This uses the standard weight of the background material to setup the fresnel effect
  58631. * of the mirror.
  58632. * 1 by default.
  58633. */
  58634. groundMirrorFresnelWeight: number;
  58635. /**
  58636. * Specifies the ground mirror Falloff distance.
  58637. * This can helps reducing the size of the reflection.
  58638. * 0 by Default.
  58639. */
  58640. groundMirrorFallOffDistance: number;
  58641. /**
  58642. * Specifies the ground mirror texture type.
  58643. * Unsigned Int by Default.
  58644. */
  58645. groundMirrorTextureType: number;
  58646. /**
  58647. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58648. * the shown objects.
  58649. */
  58650. groundYBias: number;
  58651. /**
  58652. * Specifies whether or not to create a skybox.
  58653. * True by default.
  58654. */
  58655. createSkybox: boolean;
  58656. /**
  58657. * Specifies the skybox size.
  58658. * 20 by default.
  58659. */
  58660. skyboxSize: number;
  58661. /**
  58662. * The texture used on the skybox for the main color.
  58663. * Comes from the BabylonJS CDN by default.
  58664. *
  58665. * Remarks: Can be either a texture or a url.
  58666. */
  58667. skyboxTexture: string | BaseTexture;
  58668. /**
  58669. * The color mixed in the skybox texture by default.
  58670. * BabylonJS clearColor by default.
  58671. */
  58672. skyboxColor: Color3;
  58673. /**
  58674. * The background rotation around the Y axis of the scene.
  58675. * This helps aligning the key lights of your scene with the background.
  58676. * 0 by default.
  58677. */
  58678. backgroundYRotation: number;
  58679. /**
  58680. * Compute automatically the size of the elements to best fit with the scene.
  58681. */
  58682. sizeAuto: boolean;
  58683. /**
  58684. * Default position of the rootMesh if autoSize is not true.
  58685. */
  58686. rootPosition: Vector3;
  58687. /**
  58688. * Sets up the image processing in the scene.
  58689. * true by default.
  58690. */
  58691. setupImageProcessing: boolean;
  58692. /**
  58693. * The texture used as your environment texture in the scene.
  58694. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58695. *
  58696. * Remarks: Can be either a texture or a url.
  58697. */
  58698. environmentTexture: string | BaseTexture;
  58699. /**
  58700. * The value of the exposure to apply to the scene.
  58701. * 0.6 by default if setupImageProcessing is true.
  58702. */
  58703. cameraExposure: number;
  58704. /**
  58705. * The value of the contrast to apply to the scene.
  58706. * 1.6 by default if setupImageProcessing is true.
  58707. */
  58708. cameraContrast: number;
  58709. /**
  58710. * Specifies whether or not tonemapping should be enabled in the scene.
  58711. * true by default if setupImageProcessing is true.
  58712. */
  58713. toneMappingEnabled: boolean;
  58714. }
  58715. /**
  58716. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58717. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58718. * It also helps with the default setup of your imageProcessing configuration.
  58719. */
  58720. export class EnvironmentHelper {
  58721. /**
  58722. * Default ground texture URL.
  58723. */
  58724. private static _groundTextureCDNUrl;
  58725. /**
  58726. * Default skybox texture URL.
  58727. */
  58728. private static _skyboxTextureCDNUrl;
  58729. /**
  58730. * Default environment texture URL.
  58731. */
  58732. private static _environmentTextureCDNUrl;
  58733. /**
  58734. * Creates the default options for the helper.
  58735. */
  58736. private static _getDefaultOptions;
  58737. private _rootMesh;
  58738. /**
  58739. * Gets the root mesh created by the helper.
  58740. */
  58741. get rootMesh(): Mesh;
  58742. private _skybox;
  58743. /**
  58744. * Gets the skybox created by the helper.
  58745. */
  58746. get skybox(): Nullable<Mesh>;
  58747. private _skyboxTexture;
  58748. /**
  58749. * Gets the skybox texture created by the helper.
  58750. */
  58751. get skyboxTexture(): Nullable<BaseTexture>;
  58752. private _skyboxMaterial;
  58753. /**
  58754. * Gets the skybox material created by the helper.
  58755. */
  58756. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58757. private _ground;
  58758. /**
  58759. * Gets the ground mesh created by the helper.
  58760. */
  58761. get ground(): Nullable<Mesh>;
  58762. private _groundTexture;
  58763. /**
  58764. * Gets the ground texture created by the helper.
  58765. */
  58766. get groundTexture(): Nullable<BaseTexture>;
  58767. private _groundMirror;
  58768. /**
  58769. * Gets the ground mirror created by the helper.
  58770. */
  58771. get groundMirror(): Nullable<MirrorTexture>;
  58772. /**
  58773. * Gets the ground mirror render list to helps pushing the meshes
  58774. * you wish in the ground reflection.
  58775. */
  58776. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58777. private _groundMaterial;
  58778. /**
  58779. * Gets the ground material created by the helper.
  58780. */
  58781. get groundMaterial(): Nullable<BackgroundMaterial>;
  58782. /**
  58783. * Stores the creation options.
  58784. */
  58785. private readonly _scene;
  58786. private _options;
  58787. /**
  58788. * This observable will be notified with any error during the creation of the environment,
  58789. * mainly texture creation errors.
  58790. */
  58791. onErrorObservable: Observable<{
  58792. message?: string;
  58793. exception?: any;
  58794. }>;
  58795. /**
  58796. * constructor
  58797. * @param options Defines the options we want to customize the helper
  58798. * @param scene The scene to add the material to
  58799. */
  58800. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58801. /**
  58802. * Updates the background according to the new options
  58803. * @param options
  58804. */
  58805. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58806. /**
  58807. * Sets the primary color of all the available elements.
  58808. * @param color the main color to affect to the ground and the background
  58809. */
  58810. setMainColor(color: Color3): void;
  58811. /**
  58812. * Setup the image processing according to the specified options.
  58813. */
  58814. private _setupImageProcessing;
  58815. /**
  58816. * Setup the environment texture according to the specified options.
  58817. */
  58818. private _setupEnvironmentTexture;
  58819. /**
  58820. * Setup the background according to the specified options.
  58821. */
  58822. private _setupBackground;
  58823. /**
  58824. * Get the scene sizes according to the setup.
  58825. */
  58826. private _getSceneSize;
  58827. /**
  58828. * Setup the ground according to the specified options.
  58829. */
  58830. private _setupGround;
  58831. /**
  58832. * Setup the ground material according to the specified options.
  58833. */
  58834. private _setupGroundMaterial;
  58835. /**
  58836. * Setup the ground diffuse texture according to the specified options.
  58837. */
  58838. private _setupGroundDiffuseTexture;
  58839. /**
  58840. * Setup the ground mirror texture according to the specified options.
  58841. */
  58842. private _setupGroundMirrorTexture;
  58843. /**
  58844. * Setup the ground to receive the mirror texture.
  58845. */
  58846. private _setupMirrorInGroundMaterial;
  58847. /**
  58848. * Setup the skybox according to the specified options.
  58849. */
  58850. private _setupSkybox;
  58851. /**
  58852. * Setup the skybox material according to the specified options.
  58853. */
  58854. private _setupSkyboxMaterial;
  58855. /**
  58856. * Setup the skybox reflection texture according to the specified options.
  58857. */
  58858. private _setupSkyboxReflectionTexture;
  58859. private _errorHandler;
  58860. /**
  58861. * Dispose all the elements created by the Helper.
  58862. */
  58863. dispose(): void;
  58864. }
  58865. }
  58866. declare module BABYLON {
  58867. /**
  58868. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58869. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58870. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58871. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58872. */
  58873. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58874. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58875. /**
  58876. * Define the source as a Monoscopic panoramic 360/180.
  58877. */
  58878. static readonly MODE_MONOSCOPIC: number;
  58879. /**
  58880. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58881. */
  58882. static readonly MODE_TOPBOTTOM: number;
  58883. /**
  58884. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58885. */
  58886. static readonly MODE_SIDEBYSIDE: number;
  58887. private _halfDome;
  58888. private _crossEye;
  58889. protected _useDirectMapping: boolean;
  58890. /**
  58891. * The texture being displayed on the sphere
  58892. */
  58893. protected _texture: T;
  58894. /**
  58895. * Gets the texture being displayed on the sphere
  58896. */
  58897. get texture(): T;
  58898. /**
  58899. * Sets the texture being displayed on the sphere
  58900. */
  58901. set texture(newTexture: T);
  58902. /**
  58903. * The skybox material
  58904. */
  58905. protected _material: BackgroundMaterial;
  58906. /**
  58907. * The surface used for the dome
  58908. */
  58909. protected _mesh: Mesh;
  58910. /**
  58911. * Gets the mesh used for the dome.
  58912. */
  58913. get mesh(): Mesh;
  58914. /**
  58915. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58916. */
  58917. private _halfDomeMask;
  58918. /**
  58919. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58920. * Also see the options.resolution property.
  58921. */
  58922. get fovMultiplier(): number;
  58923. set fovMultiplier(value: number);
  58924. protected _textureMode: number;
  58925. /**
  58926. * Gets or set the current texture mode for the texture. It can be:
  58927. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58928. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58929. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58930. */
  58931. get textureMode(): number;
  58932. /**
  58933. * Sets the current texture mode for the texture. It can be:
  58934. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58935. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58936. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58937. */
  58938. set textureMode(value: number);
  58939. /**
  58940. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58941. */
  58942. get halfDome(): boolean;
  58943. /**
  58944. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58945. */
  58946. set halfDome(enabled: boolean);
  58947. /**
  58948. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58949. */
  58950. set crossEye(enabled: boolean);
  58951. /**
  58952. * Is it a cross-eye texture?
  58953. */
  58954. get crossEye(): boolean;
  58955. /**
  58956. * The background material of this dome.
  58957. */
  58958. get material(): BackgroundMaterial;
  58959. /**
  58960. * Oberserver used in Stereoscopic VR Mode.
  58961. */
  58962. private _onBeforeCameraRenderObserver;
  58963. /**
  58964. * Observable raised when an error occured while loading the 360 image
  58965. */
  58966. onLoadErrorObservable: Observable<string>;
  58967. /**
  58968. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58969. * @param name Element's name, child elements will append suffixes for their own names.
  58970. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58971. * @param options An object containing optional or exposed sub element properties
  58972. */
  58973. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58974. resolution?: number;
  58975. clickToPlay?: boolean;
  58976. autoPlay?: boolean;
  58977. loop?: boolean;
  58978. size?: number;
  58979. poster?: string;
  58980. faceForward?: boolean;
  58981. useDirectMapping?: boolean;
  58982. halfDomeMode?: boolean;
  58983. crossEyeMode?: boolean;
  58984. generateMipMaps?: boolean;
  58985. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58986. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58987. protected _changeTextureMode(value: number): void;
  58988. /**
  58989. * Releases resources associated with this node.
  58990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58992. */
  58993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58994. }
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58999. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  59000. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  59001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59002. */
  59003. export class PhotoDome extends TextureDome<Texture> {
  59004. /**
  59005. * Define the image as a Monoscopic panoramic 360 image.
  59006. */
  59007. static readonly MODE_MONOSCOPIC: number;
  59008. /**
  59009. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59010. */
  59011. static readonly MODE_TOPBOTTOM: number;
  59012. /**
  59013. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59014. */
  59015. static readonly MODE_SIDEBYSIDE: number;
  59016. /**
  59017. * Gets or sets the texture being displayed on the sphere
  59018. */
  59019. get photoTexture(): Texture;
  59020. /**
  59021. * sets the texture being displayed on the sphere
  59022. */
  59023. set photoTexture(value: Texture);
  59024. /**
  59025. * Gets the current video mode for the video. It can be:
  59026. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59027. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59028. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59029. */
  59030. get imageMode(): number;
  59031. /**
  59032. * Sets the current video mode for the video. It can be:
  59033. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59034. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59035. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59036. */
  59037. set imageMode(value: number);
  59038. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59039. }
  59040. }
  59041. declare module BABYLON {
  59042. /**
  59043. * Direct draw surface info
  59044. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59045. */
  59046. export interface DDSInfo {
  59047. /**
  59048. * Width of the texture
  59049. */
  59050. width: number;
  59051. /**
  59052. * Width of the texture
  59053. */
  59054. height: number;
  59055. /**
  59056. * Number of Mipmaps for the texture
  59057. * @see https://en.wikipedia.org/wiki/Mipmap
  59058. */
  59059. mipmapCount: number;
  59060. /**
  59061. * If the textures format is a known fourCC format
  59062. * @see https://www.fourcc.org/
  59063. */
  59064. isFourCC: boolean;
  59065. /**
  59066. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59067. */
  59068. isRGB: boolean;
  59069. /**
  59070. * If the texture is a lumincance format
  59071. */
  59072. isLuminance: boolean;
  59073. /**
  59074. * If this is a cube texture
  59075. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59076. */
  59077. isCube: boolean;
  59078. /**
  59079. * If the texture is a compressed format eg. FOURCC_DXT1
  59080. */
  59081. isCompressed: boolean;
  59082. /**
  59083. * The dxgiFormat of the texture
  59084. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59085. */
  59086. dxgiFormat: number;
  59087. /**
  59088. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59089. */
  59090. textureType: number;
  59091. /**
  59092. * Sphericle polynomial created for the dds texture
  59093. */
  59094. sphericalPolynomial?: SphericalPolynomial;
  59095. }
  59096. /**
  59097. * Class used to provide DDS decompression tools
  59098. */
  59099. export class DDSTools {
  59100. /**
  59101. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59102. */
  59103. static StoreLODInAlphaChannel: boolean;
  59104. /**
  59105. * Gets DDS information from an array buffer
  59106. * @param data defines the array buffer view to read data from
  59107. * @returns the DDS information
  59108. */
  59109. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59110. private static _FloatView;
  59111. private static _Int32View;
  59112. private static _ToHalfFloat;
  59113. private static _FromHalfFloat;
  59114. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59115. private static _GetHalfFloatRGBAArrayBuffer;
  59116. private static _GetFloatRGBAArrayBuffer;
  59117. private static _GetFloatAsUIntRGBAArrayBuffer;
  59118. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59119. private static _GetRGBAArrayBuffer;
  59120. private static _ExtractLongWordOrder;
  59121. private static _GetRGBArrayBuffer;
  59122. private static _GetLuminanceArrayBuffer;
  59123. /**
  59124. * Uploads DDS Levels to a Babylon Texture
  59125. * @hidden
  59126. */
  59127. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59128. }
  59129. interface ThinEngine {
  59130. /**
  59131. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59132. * @param rootUrl defines the url where the file to load is located
  59133. * @param scene defines the current scene
  59134. * @param lodScale defines scale to apply to the mip map selection
  59135. * @param lodOffset defines offset to apply to the mip map selection
  59136. * @param onLoad defines an optional callback raised when the texture is loaded
  59137. * @param onError defines an optional callback raised if there is an issue to load the texture
  59138. * @param format defines the format of the data
  59139. * @param forcedExtension defines the extension to use to pick the right loader
  59140. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59141. * @returns the cube texture as an InternalTexture
  59142. */
  59143. 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;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * Implementation of the DDS Texture Loader.
  59149. * @hidden
  59150. */
  59151. export class _DDSTextureLoader implements IInternalTextureLoader {
  59152. /**
  59153. * Defines wether the loader supports cascade loading the different faces.
  59154. */
  59155. readonly supportCascades: boolean;
  59156. /**
  59157. * This returns if the loader support the current file information.
  59158. * @param extension defines the file extension of the file being loaded
  59159. * @returns true if the loader can load the specified file
  59160. */
  59161. canLoad(extension: string): boolean;
  59162. /**
  59163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59164. * @param data contains the texture data
  59165. * @param texture defines the BabylonJS internal texture
  59166. * @param createPolynomials will be true if polynomials have been requested
  59167. * @param onLoad defines the callback to trigger once the texture is ready
  59168. * @param onError defines the callback to trigger in case of error
  59169. */
  59170. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59171. /**
  59172. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59173. * @param data contains the texture data
  59174. * @param texture defines the BabylonJS internal texture
  59175. * @param callback defines the method to call once ready to upload
  59176. */
  59177. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59178. }
  59179. }
  59180. declare module BABYLON {
  59181. /**
  59182. * Implementation of the ENV Texture Loader.
  59183. * @hidden
  59184. */
  59185. export class _ENVTextureLoader implements IInternalTextureLoader {
  59186. /**
  59187. * Defines wether the loader supports cascade loading the different faces.
  59188. */
  59189. readonly supportCascades: boolean;
  59190. /**
  59191. * This returns if the loader support the current file information.
  59192. * @param extension defines the file extension of the file being loaded
  59193. * @returns true if the loader can load the specified file
  59194. */
  59195. canLoad(extension: string): boolean;
  59196. /**
  59197. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59198. * @param data contains the texture data
  59199. * @param texture defines the BabylonJS internal texture
  59200. * @param createPolynomials will be true if polynomials have been requested
  59201. * @param onLoad defines the callback to trigger once the texture is ready
  59202. * @param onError defines the callback to trigger in case of error
  59203. */
  59204. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59205. /**
  59206. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59207. * @param data contains the texture data
  59208. * @param texture defines the BabylonJS internal texture
  59209. * @param callback defines the method to call once ready to upload
  59210. */
  59211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59212. }
  59213. }
  59214. declare module BABYLON {
  59215. /**
  59216. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59217. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59218. */
  59219. export class KhronosTextureContainer {
  59220. /** contents of the KTX container file */
  59221. data: ArrayBufferView;
  59222. private static HEADER_LEN;
  59223. private static COMPRESSED_2D;
  59224. private static COMPRESSED_3D;
  59225. private static TEX_2D;
  59226. private static TEX_3D;
  59227. /**
  59228. * Gets the openGL type
  59229. */
  59230. glType: number;
  59231. /**
  59232. * Gets the openGL type size
  59233. */
  59234. glTypeSize: number;
  59235. /**
  59236. * Gets the openGL format
  59237. */
  59238. glFormat: number;
  59239. /**
  59240. * Gets the openGL internal format
  59241. */
  59242. glInternalFormat: number;
  59243. /**
  59244. * Gets the base internal format
  59245. */
  59246. glBaseInternalFormat: number;
  59247. /**
  59248. * Gets image width in pixel
  59249. */
  59250. pixelWidth: number;
  59251. /**
  59252. * Gets image height in pixel
  59253. */
  59254. pixelHeight: number;
  59255. /**
  59256. * Gets image depth in pixels
  59257. */
  59258. pixelDepth: number;
  59259. /**
  59260. * Gets the number of array elements
  59261. */
  59262. numberOfArrayElements: number;
  59263. /**
  59264. * Gets the number of faces
  59265. */
  59266. numberOfFaces: number;
  59267. /**
  59268. * Gets the number of mipmap levels
  59269. */
  59270. numberOfMipmapLevels: number;
  59271. /**
  59272. * Gets the bytes of key value data
  59273. */
  59274. bytesOfKeyValueData: number;
  59275. /**
  59276. * Gets the load type
  59277. */
  59278. loadType: number;
  59279. /**
  59280. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59281. */
  59282. isInvalid: boolean;
  59283. /**
  59284. * Creates a new KhronosTextureContainer
  59285. * @param data contents of the KTX container file
  59286. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59287. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59288. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59289. */
  59290. constructor(
  59291. /** contents of the KTX container file */
  59292. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59293. /**
  59294. * Uploads KTX content to a Babylon Texture.
  59295. * It is assumed that the texture has already been created & is currently bound
  59296. * @hidden
  59297. */
  59298. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59299. private _upload2DCompressedLevels;
  59300. /**
  59301. * Checks if the given data starts with a KTX file identifier.
  59302. * @param data the data to check
  59303. * @returns true if the data is a KTX file or false otherwise
  59304. */
  59305. static IsValid(data: ArrayBufferView): boolean;
  59306. }
  59307. }
  59308. declare module BABYLON {
  59309. /**
  59310. * Helper class to push actions to a pool of workers.
  59311. */
  59312. export class WorkerPool implements IDisposable {
  59313. private _workerInfos;
  59314. private _pendingActions;
  59315. /**
  59316. * Constructor
  59317. * @param workers Array of workers to use for actions
  59318. */
  59319. constructor(workers: Array<Worker>);
  59320. /**
  59321. * Terminates all workers and clears any pending actions.
  59322. */
  59323. dispose(): void;
  59324. /**
  59325. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59326. * pended until a worker has completed its action.
  59327. * @param action The action to perform. Call onComplete when the action is complete.
  59328. */
  59329. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59330. private _execute;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Class for loading KTX2 files
  59336. */
  59337. export class KhronosTextureContainer2 {
  59338. private static _WorkerPoolPromise?;
  59339. private static _Initialized;
  59340. private static _Ktx2Decoder;
  59341. /**
  59342. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59343. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59344. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59345. * Urls you can change:
  59346. * URLConfig.jsDecoderModule
  59347. * URLConfig.wasmUASTCToASTC
  59348. * URLConfig.wasmUASTCToBC7
  59349. * URLConfig.wasmUASTCToRGBA_UNORM
  59350. * URLConfig.wasmUASTCToRGBA_SRGB
  59351. * URLConfig.jsMSCTranscoder
  59352. * URLConfig.wasmMSCTranscoder
  59353. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59354. */
  59355. static URLConfig: {
  59356. jsDecoderModule: string;
  59357. wasmUASTCToASTC: null;
  59358. wasmUASTCToBC7: null;
  59359. wasmUASTCToRGBA_UNORM: null;
  59360. wasmUASTCToRGBA_SRGB: null;
  59361. jsMSCTranscoder: null;
  59362. wasmMSCTranscoder: null;
  59363. };
  59364. /**
  59365. * Default number of workers used to handle data decoding
  59366. */
  59367. static DefaultNumWorkers: number;
  59368. private static GetDefaultNumWorkers;
  59369. private _engine;
  59370. private static _CreateWorkerPool;
  59371. /**
  59372. * Constructor
  59373. * @param engine The engine to use
  59374. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59375. */
  59376. constructor(engine: ThinEngine, numWorkers?: number);
  59377. /** @hidden */
  59378. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59379. /**
  59380. * Stop all async operations and release resources.
  59381. */
  59382. dispose(): void;
  59383. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59384. /**
  59385. * Checks if the given data starts with a KTX2 file identifier.
  59386. * @param data the data to check
  59387. * @returns true if the data is a KTX2 file or false otherwise
  59388. */
  59389. static IsValid(data: ArrayBufferView): boolean;
  59390. }
  59391. }
  59392. declare module BABYLON {
  59393. /**
  59394. * Implementation of the KTX Texture Loader.
  59395. * @hidden
  59396. */
  59397. export class _KTXTextureLoader implements IInternalTextureLoader {
  59398. /**
  59399. * Defines wether the loader supports cascade loading the different faces.
  59400. */
  59401. readonly supportCascades: boolean;
  59402. /**
  59403. * This returns if the loader support the current file information.
  59404. * @param extension defines the file extension of the file being loaded
  59405. * @param mimeType defines the optional mime type of the file being loaded
  59406. * @returns true if the loader can load the specified file
  59407. */
  59408. canLoad(extension: string, mimeType?: string): boolean;
  59409. /**
  59410. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59411. * @param data contains the texture data
  59412. * @param texture defines the BabylonJS internal texture
  59413. * @param createPolynomials will be true if polynomials have been requested
  59414. * @param onLoad defines the callback to trigger once the texture is ready
  59415. * @param onError defines the callback to trigger in case of error
  59416. */
  59417. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59418. /**
  59419. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59420. * @param data contains the texture data
  59421. * @param texture defines the BabylonJS internal texture
  59422. * @param callback defines the method to call once ready to upload
  59423. */
  59424. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59425. }
  59426. }
  59427. declare module BABYLON {
  59428. /** @hidden */
  59429. export var _forceSceneHelpersToBundle: boolean;
  59430. interface Scene {
  59431. /**
  59432. * Creates a default light for the scene.
  59433. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59434. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59435. */
  59436. createDefaultLight(replace?: boolean): void;
  59437. /**
  59438. * Creates a default camera for the scene.
  59439. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59440. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59441. * @param replace has default false, when true replaces the active camera in the scene
  59442. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59443. */
  59444. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59445. /**
  59446. * Creates a default camera and a default light.
  59447. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59449. * @param replace has the default false, when true replaces the active camera/light in the scene
  59450. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59451. */
  59452. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59453. /**
  59454. * Creates a new sky box
  59455. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59456. * @param environmentTexture defines the texture to use as environment texture
  59457. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59458. * @param scale defines the overall scale of the skybox
  59459. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59460. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59461. * @returns a new mesh holding the sky box
  59462. */
  59463. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59464. /**
  59465. * Creates a new environment
  59466. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59467. * @param options defines the options you can use to configure the environment
  59468. * @returns the new EnvironmentHelper
  59469. */
  59470. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59471. /**
  59472. * Creates a new VREXperienceHelper
  59473. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59474. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59475. * @returns a new VREXperienceHelper
  59476. */
  59477. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59478. /**
  59479. * Creates a new WebXRDefaultExperience
  59480. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59481. * @param options experience options
  59482. * @returns a promise for a new WebXRDefaultExperience
  59483. */
  59484. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59485. }
  59486. }
  59487. declare module BABYLON {
  59488. /**
  59489. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59490. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59491. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59492. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59493. */
  59494. export class VideoDome extends TextureDome<VideoTexture> {
  59495. /**
  59496. * Define the video source as a Monoscopic panoramic 360 video.
  59497. */
  59498. static readonly MODE_MONOSCOPIC: number;
  59499. /**
  59500. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59501. */
  59502. static readonly MODE_TOPBOTTOM: number;
  59503. /**
  59504. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59505. */
  59506. static readonly MODE_SIDEBYSIDE: number;
  59507. /**
  59508. * Get the video texture associated with this video dome
  59509. */
  59510. get videoTexture(): VideoTexture;
  59511. /**
  59512. * Get the video mode of this dome
  59513. */
  59514. get videoMode(): number;
  59515. /**
  59516. * Set the video mode of this dome.
  59517. * @see textureMode
  59518. */
  59519. set videoMode(value: number);
  59520. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59521. }
  59522. }
  59523. declare module BABYLON {
  59524. /**
  59525. * This class can be used to get instrumentation data from a Babylon engine
  59526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59527. */
  59528. export class EngineInstrumentation implements IDisposable {
  59529. /**
  59530. * Define the instrumented engine.
  59531. */
  59532. engine: Engine;
  59533. private _captureGPUFrameTime;
  59534. private _gpuFrameTimeToken;
  59535. private _gpuFrameTime;
  59536. private _captureShaderCompilationTime;
  59537. private _shaderCompilationTime;
  59538. private _onBeginFrameObserver;
  59539. private _onEndFrameObserver;
  59540. private _onBeforeShaderCompilationObserver;
  59541. private _onAfterShaderCompilationObserver;
  59542. /**
  59543. * Gets the perf counter used for GPU frame time
  59544. */
  59545. get gpuFrameTimeCounter(): PerfCounter;
  59546. /**
  59547. * Gets the GPU frame time capture status
  59548. */
  59549. get captureGPUFrameTime(): boolean;
  59550. /**
  59551. * Enable or disable the GPU frame time capture
  59552. */
  59553. set captureGPUFrameTime(value: boolean);
  59554. /**
  59555. * Gets the perf counter used for shader compilation time
  59556. */
  59557. get shaderCompilationTimeCounter(): PerfCounter;
  59558. /**
  59559. * Gets the shader compilation time capture status
  59560. */
  59561. get captureShaderCompilationTime(): boolean;
  59562. /**
  59563. * Enable or disable the shader compilation time capture
  59564. */
  59565. set captureShaderCompilationTime(value: boolean);
  59566. /**
  59567. * Instantiates a new engine instrumentation.
  59568. * This class can be used to get instrumentation data from a Babylon engine
  59569. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59570. * @param engine Defines the engine to instrument
  59571. */
  59572. constructor(
  59573. /**
  59574. * Define the instrumented engine.
  59575. */
  59576. engine: Engine);
  59577. /**
  59578. * Dispose and release associated resources.
  59579. */
  59580. dispose(): void;
  59581. }
  59582. }
  59583. declare module BABYLON {
  59584. /**
  59585. * This class can be used to get instrumentation data from a Babylon engine
  59586. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59587. */
  59588. export class SceneInstrumentation implements IDisposable {
  59589. /**
  59590. * Defines the scene to instrument
  59591. */
  59592. scene: Scene;
  59593. private _captureActiveMeshesEvaluationTime;
  59594. private _activeMeshesEvaluationTime;
  59595. private _captureRenderTargetsRenderTime;
  59596. private _renderTargetsRenderTime;
  59597. private _captureFrameTime;
  59598. private _frameTime;
  59599. private _captureRenderTime;
  59600. private _renderTime;
  59601. private _captureInterFrameTime;
  59602. private _interFrameTime;
  59603. private _captureParticlesRenderTime;
  59604. private _particlesRenderTime;
  59605. private _captureSpritesRenderTime;
  59606. private _spritesRenderTime;
  59607. private _capturePhysicsTime;
  59608. private _physicsTime;
  59609. private _captureAnimationsTime;
  59610. private _animationsTime;
  59611. private _captureCameraRenderTime;
  59612. private _cameraRenderTime;
  59613. private _onBeforeActiveMeshesEvaluationObserver;
  59614. private _onAfterActiveMeshesEvaluationObserver;
  59615. private _onBeforeRenderTargetsRenderObserver;
  59616. private _onAfterRenderTargetsRenderObserver;
  59617. private _onAfterRenderObserver;
  59618. private _onBeforeDrawPhaseObserver;
  59619. private _onAfterDrawPhaseObserver;
  59620. private _onBeforeAnimationsObserver;
  59621. private _onBeforeParticlesRenderingObserver;
  59622. private _onAfterParticlesRenderingObserver;
  59623. private _onBeforeSpritesRenderingObserver;
  59624. private _onAfterSpritesRenderingObserver;
  59625. private _onBeforePhysicsObserver;
  59626. private _onAfterPhysicsObserver;
  59627. private _onAfterAnimationsObserver;
  59628. private _onBeforeCameraRenderObserver;
  59629. private _onAfterCameraRenderObserver;
  59630. /**
  59631. * Gets the perf counter used for active meshes evaluation time
  59632. */
  59633. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59634. /**
  59635. * Gets the active meshes evaluation time capture status
  59636. */
  59637. get captureActiveMeshesEvaluationTime(): boolean;
  59638. /**
  59639. * Enable or disable the active meshes evaluation time capture
  59640. */
  59641. set captureActiveMeshesEvaluationTime(value: boolean);
  59642. /**
  59643. * Gets the perf counter used for render targets render time
  59644. */
  59645. get renderTargetsRenderTimeCounter(): PerfCounter;
  59646. /**
  59647. * Gets the render targets render time capture status
  59648. */
  59649. get captureRenderTargetsRenderTime(): boolean;
  59650. /**
  59651. * Enable or disable the render targets render time capture
  59652. */
  59653. set captureRenderTargetsRenderTime(value: boolean);
  59654. /**
  59655. * Gets the perf counter used for particles render time
  59656. */
  59657. get particlesRenderTimeCounter(): PerfCounter;
  59658. /**
  59659. * Gets the particles render time capture status
  59660. */
  59661. get captureParticlesRenderTime(): boolean;
  59662. /**
  59663. * Enable or disable the particles render time capture
  59664. */
  59665. set captureParticlesRenderTime(value: boolean);
  59666. /**
  59667. * Gets the perf counter used for sprites render time
  59668. */
  59669. get spritesRenderTimeCounter(): PerfCounter;
  59670. /**
  59671. * Gets the sprites render time capture status
  59672. */
  59673. get captureSpritesRenderTime(): boolean;
  59674. /**
  59675. * Enable or disable the sprites render time capture
  59676. */
  59677. set captureSpritesRenderTime(value: boolean);
  59678. /**
  59679. * Gets the perf counter used for physics time
  59680. */
  59681. get physicsTimeCounter(): PerfCounter;
  59682. /**
  59683. * Gets the physics time capture status
  59684. */
  59685. get capturePhysicsTime(): boolean;
  59686. /**
  59687. * Enable or disable the physics time capture
  59688. */
  59689. set capturePhysicsTime(value: boolean);
  59690. /**
  59691. * Gets the perf counter used for animations time
  59692. */
  59693. get animationsTimeCounter(): PerfCounter;
  59694. /**
  59695. * Gets the animations time capture status
  59696. */
  59697. get captureAnimationsTime(): boolean;
  59698. /**
  59699. * Enable or disable the animations time capture
  59700. */
  59701. set captureAnimationsTime(value: boolean);
  59702. /**
  59703. * Gets the perf counter used for frame time capture
  59704. */
  59705. get frameTimeCounter(): PerfCounter;
  59706. /**
  59707. * Gets the frame time capture status
  59708. */
  59709. get captureFrameTime(): boolean;
  59710. /**
  59711. * Enable or disable the frame time capture
  59712. */
  59713. set captureFrameTime(value: boolean);
  59714. /**
  59715. * Gets the perf counter used for inter-frames time capture
  59716. */
  59717. get interFrameTimeCounter(): PerfCounter;
  59718. /**
  59719. * Gets the inter-frames time capture status
  59720. */
  59721. get captureInterFrameTime(): boolean;
  59722. /**
  59723. * Enable or disable the inter-frames time capture
  59724. */
  59725. set captureInterFrameTime(value: boolean);
  59726. /**
  59727. * Gets the perf counter used for render time capture
  59728. */
  59729. get renderTimeCounter(): PerfCounter;
  59730. /**
  59731. * Gets the render time capture status
  59732. */
  59733. get captureRenderTime(): boolean;
  59734. /**
  59735. * Enable or disable the render time capture
  59736. */
  59737. set captureRenderTime(value: boolean);
  59738. /**
  59739. * Gets the perf counter used for camera render time capture
  59740. */
  59741. get cameraRenderTimeCounter(): PerfCounter;
  59742. /**
  59743. * Gets the camera render time capture status
  59744. */
  59745. get captureCameraRenderTime(): boolean;
  59746. /**
  59747. * Enable or disable the camera render time capture
  59748. */
  59749. set captureCameraRenderTime(value: boolean);
  59750. /**
  59751. * Gets the perf counter used for draw calls
  59752. */
  59753. get drawCallsCounter(): PerfCounter;
  59754. /**
  59755. * Instantiates a new scene instrumentation.
  59756. * This class can be used to get instrumentation data from a Babylon engine
  59757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59758. * @param scene Defines the scene to instrument
  59759. */
  59760. constructor(
  59761. /**
  59762. * Defines the scene to instrument
  59763. */
  59764. scene: Scene);
  59765. /**
  59766. * Dispose and release associated resources.
  59767. */
  59768. dispose(): void;
  59769. }
  59770. }
  59771. declare module BABYLON {
  59772. /** @hidden */
  59773. export var glowMapGenerationPixelShader: {
  59774. name: string;
  59775. shader: string;
  59776. };
  59777. }
  59778. declare module BABYLON {
  59779. /** @hidden */
  59780. export var glowMapGenerationVertexShader: {
  59781. name: string;
  59782. shader: string;
  59783. };
  59784. }
  59785. declare module BABYLON {
  59786. /**
  59787. * Effect layer options. This helps customizing the behaviour
  59788. * of the effect layer.
  59789. */
  59790. export interface IEffectLayerOptions {
  59791. /**
  59792. * Multiplication factor apply to the canvas size to compute the render target size
  59793. * used to generated the objects (the smaller the faster).
  59794. */
  59795. mainTextureRatio: number;
  59796. /**
  59797. * Enforces a fixed size texture to ensure effect stability across devices.
  59798. */
  59799. mainTextureFixedSize?: number;
  59800. /**
  59801. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59802. */
  59803. alphaBlendingMode: number;
  59804. /**
  59805. * The camera attached to the layer.
  59806. */
  59807. camera: Nullable<Camera>;
  59808. /**
  59809. * The rendering group to draw the layer in.
  59810. */
  59811. renderingGroupId: number;
  59812. }
  59813. /**
  59814. * The effect layer Helps adding post process effect blended with the main pass.
  59815. *
  59816. * This can be for instance use to generate glow or higlight effects on the scene.
  59817. *
  59818. * The effect layer class can not be used directly and is intented to inherited from to be
  59819. * customized per effects.
  59820. */
  59821. export abstract class EffectLayer {
  59822. private _vertexBuffers;
  59823. private _indexBuffer;
  59824. private _cachedDefines;
  59825. private _effectLayerMapGenerationEffect;
  59826. private _effectLayerOptions;
  59827. private _mergeEffect;
  59828. protected _scene: Scene;
  59829. protected _engine: Engine;
  59830. protected _maxSize: number;
  59831. protected _mainTextureDesiredSize: ISize;
  59832. protected _mainTexture: RenderTargetTexture;
  59833. protected _shouldRender: boolean;
  59834. protected _postProcesses: PostProcess[];
  59835. protected _textures: BaseTexture[];
  59836. protected _emissiveTextureAndColor: {
  59837. texture: Nullable<BaseTexture>;
  59838. color: Color4;
  59839. };
  59840. /**
  59841. * The name of the layer
  59842. */
  59843. name: string;
  59844. /**
  59845. * The clear color of the texture used to generate the glow map.
  59846. */
  59847. neutralColor: Color4;
  59848. /**
  59849. * Specifies whether the highlight layer is enabled or not.
  59850. */
  59851. isEnabled: boolean;
  59852. /**
  59853. * Gets the camera attached to the layer.
  59854. */
  59855. get camera(): Nullable<Camera>;
  59856. /**
  59857. * Gets the rendering group id the layer should render in.
  59858. */
  59859. get renderingGroupId(): number;
  59860. set renderingGroupId(renderingGroupId: number);
  59861. /**
  59862. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59863. */
  59864. disableBoundingBoxesFromEffectLayer: boolean;
  59865. /**
  59866. * An event triggered when the effect layer has been disposed.
  59867. */
  59868. onDisposeObservable: Observable<EffectLayer>;
  59869. /**
  59870. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59871. */
  59872. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59873. /**
  59874. * An event triggered when the generated texture is being merged in the scene.
  59875. */
  59876. onBeforeComposeObservable: Observable<EffectLayer>;
  59877. /**
  59878. * An event triggered when the mesh is rendered into the effect render target.
  59879. */
  59880. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59881. /**
  59882. * An event triggered after the mesh has been rendered into the effect render target.
  59883. */
  59884. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59885. /**
  59886. * An event triggered when the generated texture has been merged in the scene.
  59887. */
  59888. onAfterComposeObservable: Observable<EffectLayer>;
  59889. /**
  59890. * An event triggered when the efffect layer changes its size.
  59891. */
  59892. onSizeChangedObservable: Observable<EffectLayer>;
  59893. /** @hidden */
  59894. static _SceneComponentInitialization: (scene: Scene) => void;
  59895. /**
  59896. * Instantiates a new effect Layer and references it in the scene.
  59897. * @param name The name of the layer
  59898. * @param scene The scene to use the layer in
  59899. */
  59900. constructor(
  59901. /** The Friendly of the effect in the scene */
  59902. name: string, scene: Scene);
  59903. /**
  59904. * Get the effect name of the layer.
  59905. * @return The effect name
  59906. */
  59907. abstract getEffectName(): string;
  59908. /**
  59909. * Checks for the readiness of the element composing the layer.
  59910. * @param subMesh the mesh to check for
  59911. * @param useInstances specify whether or not to use instances to render the mesh
  59912. * @return true if ready otherwise, false
  59913. */
  59914. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59915. /**
  59916. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59917. * @returns true if the effect requires stencil during the main canvas render pass.
  59918. */
  59919. abstract needStencil(): boolean;
  59920. /**
  59921. * Create the merge effect. This is the shader use to blit the information back
  59922. * to the main canvas at the end of the scene rendering.
  59923. * @returns The effect containing the shader used to merge the effect on the main canvas
  59924. */
  59925. protected abstract _createMergeEffect(): Effect;
  59926. /**
  59927. * Creates the render target textures and post processes used in the effect layer.
  59928. */
  59929. protected abstract _createTextureAndPostProcesses(): void;
  59930. /**
  59931. * Implementation specific of rendering the generating effect on the main canvas.
  59932. * @param effect The effect used to render through
  59933. */
  59934. protected abstract _internalRender(effect: Effect): void;
  59935. /**
  59936. * Sets the required values for both the emissive texture and and the main color.
  59937. */
  59938. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59939. /**
  59940. * Free any resources and references associated to a mesh.
  59941. * Internal use
  59942. * @param mesh The mesh to free.
  59943. */
  59944. abstract _disposeMesh(mesh: Mesh): void;
  59945. /**
  59946. * Serializes this layer (Glow or Highlight for example)
  59947. * @returns a serialized layer object
  59948. */
  59949. abstract serialize?(): any;
  59950. /**
  59951. * Initializes the effect layer with the required options.
  59952. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59953. */
  59954. protected _init(options: Partial<IEffectLayerOptions>): void;
  59955. /**
  59956. * Generates the index buffer of the full screen quad blending to the main canvas.
  59957. */
  59958. private _generateIndexBuffer;
  59959. /**
  59960. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59961. */
  59962. private _generateVertexBuffer;
  59963. /**
  59964. * Sets the main texture desired size which is the closest power of two
  59965. * of the engine canvas size.
  59966. */
  59967. private _setMainTextureSize;
  59968. /**
  59969. * Creates the main texture for the effect layer.
  59970. */
  59971. protected _createMainTexture(): void;
  59972. /**
  59973. * Adds specific effects defines.
  59974. * @param defines The defines to add specifics to.
  59975. */
  59976. protected _addCustomEffectDefines(defines: string[]): void;
  59977. /**
  59978. * Checks for the readiness of the element composing the layer.
  59979. * @param subMesh the mesh to check for
  59980. * @param useInstances specify whether or not to use instances to render the mesh
  59981. * @param emissiveTexture the associated emissive texture used to generate the glow
  59982. * @return true if ready otherwise, false
  59983. */
  59984. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59985. /**
  59986. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59987. */
  59988. render(): void;
  59989. /**
  59990. * Determine if a given mesh will be used in the current effect.
  59991. * @param mesh mesh to test
  59992. * @returns true if the mesh will be used
  59993. */
  59994. hasMesh(mesh: AbstractMesh): boolean;
  59995. /**
  59996. * Returns true if the layer contains information to display, otherwise false.
  59997. * @returns true if the glow layer should be rendered
  59998. */
  59999. shouldRender(): boolean;
  60000. /**
  60001. * Returns true if the mesh should render, otherwise false.
  60002. * @param mesh The mesh to render
  60003. * @returns true if it should render otherwise false
  60004. */
  60005. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60006. /**
  60007. * Returns true if the mesh can be rendered, otherwise false.
  60008. * @param mesh The mesh to render
  60009. * @param material The material used on the mesh
  60010. * @returns true if it can be rendered otherwise false
  60011. */
  60012. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60013. /**
  60014. * Returns true if the mesh should render, otherwise false.
  60015. * @param mesh The mesh to render
  60016. * @returns true if it should render otherwise false
  60017. */
  60018. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60019. /**
  60020. * Renders the submesh passed in parameter to the generation map.
  60021. */
  60022. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60023. /**
  60024. * Defines whether the current material of the mesh should be use to render the effect.
  60025. * @param mesh defines the current mesh to render
  60026. */
  60027. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60028. /**
  60029. * Rebuild the required buffers.
  60030. * @hidden Internal use only.
  60031. */
  60032. _rebuild(): void;
  60033. /**
  60034. * Dispose only the render target textures and post process.
  60035. */
  60036. private _disposeTextureAndPostProcesses;
  60037. /**
  60038. * Dispose the highlight layer and free resources.
  60039. */
  60040. dispose(): void;
  60041. /**
  60042. * Gets the class name of the effect layer
  60043. * @returns the string with the class name of the effect layer
  60044. */
  60045. getClassName(): string;
  60046. /**
  60047. * Creates an effect layer from parsed effect layer data
  60048. * @param parsedEffectLayer defines effect layer data
  60049. * @param scene defines the current scene
  60050. * @param rootUrl defines the root URL containing the effect layer information
  60051. * @returns a parsed effect Layer
  60052. */
  60053. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. interface AbstractScene {
  60058. /**
  60059. * The list of effect layers (highlights/glow) added to the scene
  60060. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60061. * @see https://doc.babylonjs.com/how_to/glow_layer
  60062. */
  60063. effectLayers: Array<EffectLayer>;
  60064. /**
  60065. * Removes the given effect layer from this scene.
  60066. * @param toRemove defines the effect layer to remove
  60067. * @returns the index of the removed effect layer
  60068. */
  60069. removeEffectLayer(toRemove: EffectLayer): number;
  60070. /**
  60071. * Adds the given effect layer to this scene
  60072. * @param newEffectLayer defines the effect layer to add
  60073. */
  60074. addEffectLayer(newEffectLayer: EffectLayer): void;
  60075. }
  60076. /**
  60077. * Defines the layer scene component responsible to manage any effect layers
  60078. * in a given scene.
  60079. */
  60080. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60081. /**
  60082. * The component name helpfull to identify the component in the list of scene components.
  60083. */
  60084. readonly name: string;
  60085. /**
  60086. * The scene the component belongs to.
  60087. */
  60088. scene: Scene;
  60089. private _engine;
  60090. private _renderEffects;
  60091. private _needStencil;
  60092. private _previousStencilState;
  60093. /**
  60094. * Creates a new instance of the component for the given scene
  60095. * @param scene Defines the scene to register the component in
  60096. */
  60097. constructor(scene: Scene);
  60098. /**
  60099. * Registers the component in a given scene
  60100. */
  60101. register(): void;
  60102. /**
  60103. * Rebuilds the elements related to this component in case of
  60104. * context lost for instance.
  60105. */
  60106. rebuild(): void;
  60107. /**
  60108. * Serializes the component data to the specified json object
  60109. * @param serializationObject The object to serialize to
  60110. */
  60111. serialize(serializationObject: any): void;
  60112. /**
  60113. * Adds all the elements from the container to the scene
  60114. * @param container the container holding the elements
  60115. */
  60116. addFromContainer(container: AbstractScene): void;
  60117. /**
  60118. * Removes all the elements in the container from the scene
  60119. * @param container contains the elements to remove
  60120. * @param dispose if the removed element should be disposed (default: false)
  60121. */
  60122. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60123. /**
  60124. * Disposes the component and the associated ressources.
  60125. */
  60126. dispose(): void;
  60127. private _isReadyForMesh;
  60128. private _renderMainTexture;
  60129. private _setStencil;
  60130. private _setStencilBack;
  60131. private _draw;
  60132. private _drawCamera;
  60133. private _drawRenderingGroup;
  60134. }
  60135. }
  60136. declare module BABYLON {
  60137. /** @hidden */
  60138. export var glowMapMergePixelShader: {
  60139. name: string;
  60140. shader: string;
  60141. };
  60142. }
  60143. declare module BABYLON {
  60144. /** @hidden */
  60145. export var glowMapMergeVertexShader: {
  60146. name: string;
  60147. shader: string;
  60148. };
  60149. }
  60150. declare module BABYLON {
  60151. interface AbstractScene {
  60152. /**
  60153. * Return a the first highlight layer of the scene with a given name.
  60154. * @param name The name of the highlight layer to look for.
  60155. * @return The highlight layer if found otherwise null.
  60156. */
  60157. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60158. }
  60159. /**
  60160. * Glow layer options. This helps customizing the behaviour
  60161. * of the glow layer.
  60162. */
  60163. export interface IGlowLayerOptions {
  60164. /**
  60165. * Multiplication factor apply to the canvas size to compute the render target size
  60166. * used to generated the glowing objects (the smaller the faster).
  60167. */
  60168. mainTextureRatio: number;
  60169. /**
  60170. * Enforces a fixed size texture to ensure resize independant blur.
  60171. */
  60172. mainTextureFixedSize?: number;
  60173. /**
  60174. * How big is the kernel of the blur texture.
  60175. */
  60176. blurKernelSize: number;
  60177. /**
  60178. * The camera attached to the layer.
  60179. */
  60180. camera: Nullable<Camera>;
  60181. /**
  60182. * Enable MSAA by chosing the number of samples.
  60183. */
  60184. mainTextureSamples?: number;
  60185. /**
  60186. * The rendering group to draw the layer in.
  60187. */
  60188. renderingGroupId: number;
  60189. }
  60190. /**
  60191. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60192. *
  60193. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60194. *
  60195. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60196. */
  60197. export class GlowLayer extends EffectLayer {
  60198. /**
  60199. * Effect Name of the layer.
  60200. */
  60201. static readonly EffectName: string;
  60202. /**
  60203. * The default blur kernel size used for the glow.
  60204. */
  60205. static DefaultBlurKernelSize: number;
  60206. /**
  60207. * The default texture size ratio used for the glow.
  60208. */
  60209. static DefaultTextureRatio: number;
  60210. /**
  60211. * Sets the kernel size of the blur.
  60212. */
  60213. set blurKernelSize(value: number);
  60214. /**
  60215. * Gets the kernel size of the blur.
  60216. */
  60217. get blurKernelSize(): number;
  60218. /**
  60219. * Sets the glow intensity.
  60220. */
  60221. set intensity(value: number);
  60222. /**
  60223. * Gets the glow intensity.
  60224. */
  60225. get intensity(): number;
  60226. private _options;
  60227. private _intensity;
  60228. private _horizontalBlurPostprocess1;
  60229. private _verticalBlurPostprocess1;
  60230. private _horizontalBlurPostprocess2;
  60231. private _verticalBlurPostprocess2;
  60232. private _blurTexture1;
  60233. private _blurTexture2;
  60234. private _postProcesses1;
  60235. private _postProcesses2;
  60236. private _includedOnlyMeshes;
  60237. private _excludedMeshes;
  60238. private _meshesUsingTheirOwnMaterials;
  60239. /**
  60240. * Callback used to let the user override the color selection on a per mesh basis
  60241. */
  60242. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60243. /**
  60244. * Callback used to let the user override the texture selection on a per mesh basis
  60245. */
  60246. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60247. /**
  60248. * Instantiates a new glow Layer and references it to the scene.
  60249. * @param name The name of the layer
  60250. * @param scene The scene to use the layer in
  60251. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60252. */
  60253. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60254. /**
  60255. * Get the effect name of the layer.
  60256. * @return The effect name
  60257. */
  60258. getEffectName(): string;
  60259. /**
  60260. * Create the merge effect. This is the shader use to blit the information back
  60261. * to the main canvas at the end of the scene rendering.
  60262. */
  60263. protected _createMergeEffect(): Effect;
  60264. /**
  60265. * Creates the render target textures and post processes used in the glow layer.
  60266. */
  60267. protected _createTextureAndPostProcesses(): void;
  60268. /**
  60269. * Checks for the readiness of the element composing the layer.
  60270. * @param subMesh the mesh to check for
  60271. * @param useInstances specify wether or not to use instances to render the mesh
  60272. * @param emissiveTexture the associated emissive texture used to generate the glow
  60273. * @return true if ready otherwise, false
  60274. */
  60275. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60276. /**
  60277. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60278. */
  60279. needStencil(): boolean;
  60280. /**
  60281. * Returns true if the mesh can be rendered, otherwise false.
  60282. * @param mesh The mesh to render
  60283. * @param material The material used on the mesh
  60284. * @returns true if it can be rendered otherwise false
  60285. */
  60286. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60287. /**
  60288. * Implementation specific of rendering the generating effect on the main canvas.
  60289. * @param effect The effect used to render through
  60290. */
  60291. protected _internalRender(effect: Effect): void;
  60292. /**
  60293. * Sets the required values for both the emissive texture and and the main color.
  60294. */
  60295. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60296. /**
  60297. * Returns true if the mesh should render, otherwise false.
  60298. * @param mesh The mesh to render
  60299. * @returns true if it should render otherwise false
  60300. */
  60301. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60302. /**
  60303. * Adds specific effects defines.
  60304. * @param defines The defines to add specifics to.
  60305. */
  60306. protected _addCustomEffectDefines(defines: string[]): void;
  60307. /**
  60308. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60309. * @param mesh The mesh to exclude from the glow layer
  60310. */
  60311. addExcludedMesh(mesh: Mesh): void;
  60312. /**
  60313. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60314. * @param mesh The mesh to remove
  60315. */
  60316. removeExcludedMesh(mesh: Mesh): void;
  60317. /**
  60318. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60319. * @param mesh The mesh to include in the glow layer
  60320. */
  60321. addIncludedOnlyMesh(mesh: Mesh): void;
  60322. /**
  60323. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60324. * @param mesh The mesh to remove
  60325. */
  60326. removeIncludedOnlyMesh(mesh: Mesh): void;
  60327. /**
  60328. * Determine if a given mesh will be used in the glow layer
  60329. * @param mesh The mesh to test
  60330. * @returns true if the mesh will be highlighted by the current glow layer
  60331. */
  60332. hasMesh(mesh: AbstractMesh): boolean;
  60333. /**
  60334. * Defines whether the current material of the mesh should be use to render the effect.
  60335. * @param mesh defines the current mesh to render
  60336. */
  60337. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60338. /**
  60339. * Add a mesh to be rendered through its own material and not with emissive only.
  60340. * @param mesh The mesh for which we need to use its material
  60341. */
  60342. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60343. /**
  60344. * Remove a mesh from being rendered through its own material and not with emissive only.
  60345. * @param mesh The mesh for which we need to not use its material
  60346. */
  60347. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60348. /**
  60349. * Free any resources and references associated to a mesh.
  60350. * Internal use
  60351. * @param mesh The mesh to free.
  60352. * @hidden
  60353. */
  60354. _disposeMesh(mesh: Mesh): void;
  60355. /**
  60356. * Gets the class name of the effect layer
  60357. * @returns the string with the class name of the effect layer
  60358. */
  60359. getClassName(): string;
  60360. /**
  60361. * Serializes this glow layer
  60362. * @returns a serialized glow layer object
  60363. */
  60364. serialize(): any;
  60365. /**
  60366. * Creates a Glow Layer from parsed glow layer data
  60367. * @param parsedGlowLayer defines glow layer data
  60368. * @param scene defines the current scene
  60369. * @param rootUrl defines the root URL containing the glow layer information
  60370. * @returns a parsed Glow Layer
  60371. */
  60372. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60373. }
  60374. }
  60375. declare module BABYLON {
  60376. /** @hidden */
  60377. export var glowBlurPostProcessPixelShader: {
  60378. name: string;
  60379. shader: string;
  60380. };
  60381. }
  60382. declare module BABYLON {
  60383. interface AbstractScene {
  60384. /**
  60385. * Return a the first highlight layer of the scene with a given name.
  60386. * @param name The name of the highlight layer to look for.
  60387. * @return The highlight layer if found otherwise null.
  60388. */
  60389. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60390. }
  60391. /**
  60392. * Highlight layer options. This helps customizing the behaviour
  60393. * of the highlight layer.
  60394. */
  60395. export interface IHighlightLayerOptions {
  60396. /**
  60397. * Multiplication factor apply to the canvas size to compute the render target size
  60398. * used to generated the glowing objects (the smaller the faster).
  60399. */
  60400. mainTextureRatio: number;
  60401. /**
  60402. * Enforces a fixed size texture to ensure resize independant blur.
  60403. */
  60404. mainTextureFixedSize?: number;
  60405. /**
  60406. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60407. * of the picture to blur (the smaller the faster).
  60408. */
  60409. blurTextureSizeRatio: number;
  60410. /**
  60411. * How big in texel of the blur texture is the vertical blur.
  60412. */
  60413. blurVerticalSize: number;
  60414. /**
  60415. * How big in texel of the blur texture is the horizontal blur.
  60416. */
  60417. blurHorizontalSize: number;
  60418. /**
  60419. * Alpha blending mode used to apply the blur. Default is combine.
  60420. */
  60421. alphaBlendingMode: number;
  60422. /**
  60423. * The camera attached to the layer.
  60424. */
  60425. camera: Nullable<Camera>;
  60426. /**
  60427. * Should we display highlight as a solid stroke?
  60428. */
  60429. isStroke?: boolean;
  60430. /**
  60431. * The rendering group to draw the layer in.
  60432. */
  60433. renderingGroupId: number;
  60434. }
  60435. /**
  60436. * The highlight layer Helps adding a glow effect around a mesh.
  60437. *
  60438. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60439. * glowy meshes to your scene.
  60440. *
  60441. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60442. */
  60443. export class HighlightLayer extends EffectLayer {
  60444. name: string;
  60445. /**
  60446. * Effect Name of the highlight layer.
  60447. */
  60448. static readonly EffectName: string;
  60449. /**
  60450. * The neutral color used during the preparation of the glow effect.
  60451. * This is black by default as the blend operation is a blend operation.
  60452. */
  60453. static NeutralColor: Color4;
  60454. /**
  60455. * Stencil value used for glowing meshes.
  60456. */
  60457. static GlowingMeshStencilReference: number;
  60458. /**
  60459. * Stencil value used for the other meshes in the scene.
  60460. */
  60461. static NormalMeshStencilReference: number;
  60462. /**
  60463. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60464. */
  60465. innerGlow: boolean;
  60466. /**
  60467. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60468. */
  60469. outerGlow: boolean;
  60470. /**
  60471. * Specifies the horizontal size of the blur.
  60472. */
  60473. set blurHorizontalSize(value: number);
  60474. /**
  60475. * Specifies the vertical size of the blur.
  60476. */
  60477. set blurVerticalSize(value: number);
  60478. /**
  60479. * Gets the horizontal size of the blur.
  60480. */
  60481. get blurHorizontalSize(): number;
  60482. /**
  60483. * Gets the vertical size of the blur.
  60484. */
  60485. get blurVerticalSize(): number;
  60486. /**
  60487. * An event triggered when the highlight layer is being blurred.
  60488. */
  60489. onBeforeBlurObservable: Observable<HighlightLayer>;
  60490. /**
  60491. * An event triggered when the highlight layer has been blurred.
  60492. */
  60493. onAfterBlurObservable: Observable<HighlightLayer>;
  60494. private _instanceGlowingMeshStencilReference;
  60495. private _options;
  60496. private _downSamplePostprocess;
  60497. private _horizontalBlurPostprocess;
  60498. private _verticalBlurPostprocess;
  60499. private _blurTexture;
  60500. private _meshes;
  60501. private _excludedMeshes;
  60502. /**
  60503. * Instantiates a new highlight Layer and references it to the scene..
  60504. * @param name The name of the layer
  60505. * @param scene The scene to use the layer in
  60506. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60507. */
  60508. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60509. /**
  60510. * Get the effect name of the layer.
  60511. * @return The effect name
  60512. */
  60513. getEffectName(): string;
  60514. /**
  60515. * Create the merge effect. This is the shader use to blit the information back
  60516. * to the main canvas at the end of the scene rendering.
  60517. */
  60518. protected _createMergeEffect(): Effect;
  60519. /**
  60520. * Creates the render target textures and post processes used in the highlight layer.
  60521. */
  60522. protected _createTextureAndPostProcesses(): void;
  60523. /**
  60524. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60525. */
  60526. needStencil(): boolean;
  60527. /**
  60528. * Checks for the readiness of the element composing the layer.
  60529. * @param subMesh the mesh to check for
  60530. * @param useInstances specify wether or not to use instances to render the mesh
  60531. * @param emissiveTexture the associated emissive texture used to generate the glow
  60532. * @return true if ready otherwise, false
  60533. */
  60534. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60535. /**
  60536. * Implementation specific of rendering the generating effect on the main canvas.
  60537. * @param effect The effect used to render through
  60538. */
  60539. protected _internalRender(effect: Effect): void;
  60540. /**
  60541. * Returns true if the layer contains information to display, otherwise false.
  60542. */
  60543. shouldRender(): boolean;
  60544. /**
  60545. * Returns true if the mesh should render, otherwise false.
  60546. * @param mesh The mesh to render
  60547. * @returns true if it should render otherwise false
  60548. */
  60549. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60550. /**
  60551. * Returns true if the mesh can be rendered, otherwise false.
  60552. * @param mesh The mesh to render
  60553. * @param material The material used on the mesh
  60554. * @returns true if it can be rendered otherwise false
  60555. */
  60556. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60557. /**
  60558. * Adds specific effects defines.
  60559. * @param defines The defines to add specifics to.
  60560. */
  60561. protected _addCustomEffectDefines(defines: string[]): void;
  60562. /**
  60563. * Sets the required values for both the emissive texture and and the main color.
  60564. */
  60565. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60566. /**
  60567. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60568. * @param mesh The mesh to exclude from the highlight layer
  60569. */
  60570. addExcludedMesh(mesh: Mesh): void;
  60571. /**
  60572. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60573. * @param mesh The mesh to highlight
  60574. */
  60575. removeExcludedMesh(mesh: Mesh): void;
  60576. /**
  60577. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60578. * @param mesh mesh to test
  60579. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60580. */
  60581. hasMesh(mesh: AbstractMesh): boolean;
  60582. /**
  60583. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60584. * @param mesh The mesh to highlight
  60585. * @param color The color of the highlight
  60586. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60587. */
  60588. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60589. /**
  60590. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60591. * @param mesh The mesh to highlight
  60592. */
  60593. removeMesh(mesh: Mesh): void;
  60594. /**
  60595. * Remove all the meshes currently referenced in the highlight layer
  60596. */
  60597. removeAllMeshes(): void;
  60598. /**
  60599. * Force the stencil to the normal expected value for none glowing parts
  60600. */
  60601. private _defaultStencilReference;
  60602. /**
  60603. * Free any resources and references associated to a mesh.
  60604. * Internal use
  60605. * @param mesh The mesh to free.
  60606. * @hidden
  60607. */
  60608. _disposeMesh(mesh: Mesh): void;
  60609. /**
  60610. * Dispose the highlight layer and free resources.
  60611. */
  60612. dispose(): void;
  60613. /**
  60614. * Gets the class name of the effect layer
  60615. * @returns the string with the class name of the effect layer
  60616. */
  60617. getClassName(): string;
  60618. /**
  60619. * Serializes this Highlight layer
  60620. * @returns a serialized Highlight layer object
  60621. */
  60622. serialize(): any;
  60623. /**
  60624. * Creates a Highlight layer from parsed Highlight layer data
  60625. * @param parsedHightlightLayer defines the Highlight layer data
  60626. * @param scene defines the current scene
  60627. * @param rootUrl defines the root URL containing the Highlight layer information
  60628. * @returns a parsed Highlight layer
  60629. */
  60630. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60631. }
  60632. }
  60633. declare module BABYLON {
  60634. interface AbstractScene {
  60635. /**
  60636. * The list of layers (background and foreground) of the scene
  60637. */
  60638. layers: Array<Layer>;
  60639. }
  60640. /**
  60641. * Defines the layer scene component responsible to manage any layers
  60642. * in a given scene.
  60643. */
  60644. export class LayerSceneComponent implements ISceneComponent {
  60645. /**
  60646. * The component name helpfull to identify the component in the list of scene components.
  60647. */
  60648. readonly name: string;
  60649. /**
  60650. * The scene the component belongs to.
  60651. */
  60652. scene: Scene;
  60653. private _engine;
  60654. /**
  60655. * Creates a new instance of the component for the given scene
  60656. * @param scene Defines the scene to register the component in
  60657. */
  60658. constructor(scene: Scene);
  60659. /**
  60660. * Registers the component in a given scene
  60661. */
  60662. register(): void;
  60663. /**
  60664. * Rebuilds the elements related to this component in case of
  60665. * context lost for instance.
  60666. */
  60667. rebuild(): void;
  60668. /**
  60669. * Disposes the component and the associated ressources.
  60670. */
  60671. dispose(): void;
  60672. private _draw;
  60673. private _drawCameraPredicate;
  60674. private _drawCameraBackground;
  60675. private _drawCameraForeground;
  60676. private _drawRenderTargetPredicate;
  60677. private _drawRenderTargetBackground;
  60678. private _drawRenderTargetForeground;
  60679. /**
  60680. * Adds all the elements from the container to the scene
  60681. * @param container the container holding the elements
  60682. */
  60683. addFromContainer(container: AbstractScene): void;
  60684. /**
  60685. * Removes all the elements in the container from the scene
  60686. * @param container contains the elements to remove
  60687. * @param dispose if the removed element should be disposed (default: false)
  60688. */
  60689. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60690. }
  60691. }
  60692. declare module BABYLON {
  60693. /** @hidden */
  60694. export var layerPixelShader: {
  60695. name: string;
  60696. shader: string;
  60697. };
  60698. }
  60699. declare module BABYLON {
  60700. /** @hidden */
  60701. export var layerVertexShader: {
  60702. name: string;
  60703. shader: string;
  60704. };
  60705. }
  60706. declare module BABYLON {
  60707. /**
  60708. * This represents a full screen 2d layer.
  60709. * This can be useful to display a picture in the background of your scene for instance.
  60710. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60711. */
  60712. export class Layer {
  60713. /**
  60714. * Define the name of the layer.
  60715. */
  60716. name: string;
  60717. /**
  60718. * Define the texture the layer should display.
  60719. */
  60720. texture: Nullable<Texture>;
  60721. /**
  60722. * Is the layer in background or foreground.
  60723. */
  60724. isBackground: boolean;
  60725. /**
  60726. * Define the color of the layer (instead of texture).
  60727. */
  60728. color: Color4;
  60729. /**
  60730. * Define the scale of the layer in order to zoom in out of the texture.
  60731. */
  60732. scale: Vector2;
  60733. /**
  60734. * Define an offset for the layer in order to shift the texture.
  60735. */
  60736. offset: Vector2;
  60737. /**
  60738. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60739. */
  60740. alphaBlendingMode: number;
  60741. /**
  60742. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60743. * Alpha test will not mix with the background color in case of transparency.
  60744. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60745. */
  60746. alphaTest: boolean;
  60747. /**
  60748. * Define a mask to restrict the layer to only some of the scene cameras.
  60749. */
  60750. layerMask: number;
  60751. /**
  60752. * Define the list of render target the layer is visible into.
  60753. */
  60754. renderTargetTextures: RenderTargetTexture[];
  60755. /**
  60756. * Define if the layer is only used in renderTarget or if it also
  60757. * renders in the main frame buffer of the canvas.
  60758. */
  60759. renderOnlyInRenderTargetTextures: boolean;
  60760. private _scene;
  60761. private _vertexBuffers;
  60762. private _indexBuffer;
  60763. private _effect;
  60764. private _previousDefines;
  60765. /**
  60766. * An event triggered when the layer is disposed.
  60767. */
  60768. onDisposeObservable: Observable<Layer>;
  60769. private _onDisposeObserver;
  60770. /**
  60771. * Back compatibility with callback before the onDisposeObservable existed.
  60772. * The set callback will be triggered when the layer has been disposed.
  60773. */
  60774. set onDispose(callback: () => void);
  60775. /**
  60776. * An event triggered before rendering the scene
  60777. */
  60778. onBeforeRenderObservable: Observable<Layer>;
  60779. private _onBeforeRenderObserver;
  60780. /**
  60781. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60782. * The set callback will be triggered just before rendering the layer.
  60783. */
  60784. set onBeforeRender(callback: () => void);
  60785. /**
  60786. * An event triggered after rendering the scene
  60787. */
  60788. onAfterRenderObservable: Observable<Layer>;
  60789. private _onAfterRenderObserver;
  60790. /**
  60791. * Back compatibility with callback before the onAfterRenderObservable existed.
  60792. * The set callback will be triggered just after rendering the layer.
  60793. */
  60794. set onAfterRender(callback: () => void);
  60795. /**
  60796. * Instantiates a new layer.
  60797. * This represents a full screen 2d layer.
  60798. * This can be useful to display a picture in the background of your scene for instance.
  60799. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60800. * @param name Define the name of the layer in the scene
  60801. * @param imgUrl Define the url of the texture to display in the layer
  60802. * @param scene Define the scene the layer belongs to
  60803. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60804. * @param color Defines a color for the layer
  60805. */
  60806. constructor(
  60807. /**
  60808. * Define the name of the layer.
  60809. */
  60810. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60811. private _createIndexBuffer;
  60812. /** @hidden */
  60813. _rebuild(): void;
  60814. /**
  60815. * Renders the layer in the scene.
  60816. */
  60817. render(): void;
  60818. /**
  60819. * Disposes and releases the associated ressources.
  60820. */
  60821. dispose(): void;
  60822. }
  60823. }
  60824. declare module BABYLON {
  60825. /** @hidden */
  60826. export var lensFlarePixelShader: {
  60827. name: string;
  60828. shader: string;
  60829. };
  60830. }
  60831. declare module BABYLON {
  60832. /** @hidden */
  60833. export var lensFlareVertexShader: {
  60834. name: string;
  60835. shader: string;
  60836. };
  60837. }
  60838. declare module BABYLON {
  60839. /**
  60840. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60841. * It is usually composed of several `lensFlare`.
  60842. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60843. */
  60844. export class LensFlareSystem {
  60845. /**
  60846. * Define the name of the lens flare system
  60847. */
  60848. name: string;
  60849. /**
  60850. * List of lens flares used in this system.
  60851. */
  60852. lensFlares: LensFlare[];
  60853. /**
  60854. * Define a limit from the border the lens flare can be visible.
  60855. */
  60856. borderLimit: number;
  60857. /**
  60858. * Define a viewport border we do not want to see the lens flare in.
  60859. */
  60860. viewportBorder: number;
  60861. /**
  60862. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60863. */
  60864. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60865. /**
  60866. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60867. */
  60868. layerMask: number;
  60869. /**
  60870. * Define the id of the lens flare system in the scene.
  60871. * (equal to name by default)
  60872. */
  60873. id: string;
  60874. private _scene;
  60875. private _emitter;
  60876. private _vertexBuffers;
  60877. private _indexBuffer;
  60878. private _effect;
  60879. private _positionX;
  60880. private _positionY;
  60881. private _isEnabled;
  60882. /** @hidden */
  60883. static _SceneComponentInitialization: (scene: Scene) => void;
  60884. /**
  60885. * Instantiates a lens flare system.
  60886. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60887. * It is usually composed of several `lensFlare`.
  60888. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60889. * @param name Define the name of the lens flare system in the scene
  60890. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60891. * @param scene Define the scene the lens flare system belongs to
  60892. */
  60893. constructor(
  60894. /**
  60895. * Define the name of the lens flare system
  60896. */
  60897. name: string, emitter: any, scene: Scene);
  60898. /**
  60899. * Define if the lens flare system is enabled.
  60900. */
  60901. get isEnabled(): boolean;
  60902. set isEnabled(value: boolean);
  60903. /**
  60904. * Get the scene the effects belongs to.
  60905. * @returns the scene holding the lens flare system
  60906. */
  60907. getScene(): Scene;
  60908. /**
  60909. * Get the emitter of the lens flare system.
  60910. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60911. * @returns the emitter of the lens flare system
  60912. */
  60913. getEmitter(): any;
  60914. /**
  60915. * Set the emitter of the lens flare system.
  60916. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60917. * @param newEmitter Define the new emitter of the system
  60918. */
  60919. setEmitter(newEmitter: any): void;
  60920. /**
  60921. * Get the lens flare system emitter position.
  60922. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60923. * @returns the position
  60924. */
  60925. getEmitterPosition(): Vector3;
  60926. /**
  60927. * @hidden
  60928. */
  60929. computeEffectivePosition(globalViewport: Viewport): boolean;
  60930. /** @hidden */
  60931. _isVisible(): boolean;
  60932. /**
  60933. * @hidden
  60934. */
  60935. render(): boolean;
  60936. /**
  60937. * Dispose and release the lens flare with its associated resources.
  60938. */
  60939. dispose(): void;
  60940. /**
  60941. * Parse a lens flare system from a JSON repressentation
  60942. * @param parsedLensFlareSystem Define the JSON to parse
  60943. * @param scene Define the scene the parsed system should be instantiated in
  60944. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60945. * @returns the parsed system
  60946. */
  60947. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60948. /**
  60949. * Serialize the current Lens Flare System into a JSON representation.
  60950. * @returns the serialized JSON
  60951. */
  60952. serialize(): any;
  60953. }
  60954. }
  60955. declare module BABYLON {
  60956. /**
  60957. * This represents one of the lens effect in a `lensFlareSystem`.
  60958. * It controls one of the indiviual texture used in the effect.
  60959. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60960. */
  60961. export class LensFlare {
  60962. /**
  60963. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60964. */
  60965. size: number;
  60966. /**
  60967. * 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.
  60968. */
  60969. position: number;
  60970. /**
  60971. * Define the lens color.
  60972. */
  60973. color: Color3;
  60974. /**
  60975. * Define the lens texture.
  60976. */
  60977. texture: Nullable<Texture>;
  60978. /**
  60979. * Define the alpha mode to render this particular lens.
  60980. */
  60981. alphaMode: number;
  60982. private _system;
  60983. /**
  60984. * Creates a new Lens Flare.
  60985. * This represents one of the lens effect in a `lensFlareSystem`.
  60986. * It controls one of the indiviual texture used in the effect.
  60987. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60988. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60989. * @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.
  60990. * @param color Define the lens color
  60991. * @param imgUrl Define the lens texture url
  60992. * @param system Define the `lensFlareSystem` this flare is part of
  60993. * @returns The newly created Lens Flare
  60994. */
  60995. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60996. /**
  60997. * Instantiates a new Lens Flare.
  60998. * This represents one of the lens effect in a `lensFlareSystem`.
  60999. * It controls one of the indiviual texture used in the effect.
  61000. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61001. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61002. * @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.
  61003. * @param color Define the lens color
  61004. * @param imgUrl Define the lens texture url
  61005. * @param system Define the `lensFlareSystem` this flare is part of
  61006. */
  61007. constructor(
  61008. /**
  61009. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61010. */
  61011. size: number,
  61012. /**
  61013. * 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.
  61014. */
  61015. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61016. /**
  61017. * Dispose and release the lens flare with its associated resources.
  61018. */
  61019. dispose(): void;
  61020. }
  61021. }
  61022. declare module BABYLON {
  61023. interface AbstractScene {
  61024. /**
  61025. * The list of lens flare system added to the scene
  61026. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61027. */
  61028. lensFlareSystems: Array<LensFlareSystem>;
  61029. /**
  61030. * Removes the given lens flare system from this scene.
  61031. * @param toRemove The lens flare system to remove
  61032. * @returns The index of the removed lens flare system
  61033. */
  61034. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61035. /**
  61036. * Adds the given lens flare system to this scene
  61037. * @param newLensFlareSystem The lens flare system to add
  61038. */
  61039. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61040. /**
  61041. * Gets a lens flare system using its name
  61042. * @param name defines the name to look for
  61043. * @returns the lens flare system or null if not found
  61044. */
  61045. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61046. /**
  61047. * Gets a lens flare system using its id
  61048. * @param id defines the id to look for
  61049. * @returns the lens flare system or null if not found
  61050. */
  61051. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61052. }
  61053. /**
  61054. * Defines the lens flare scene component responsible to manage any lens flares
  61055. * in a given scene.
  61056. */
  61057. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61058. /**
  61059. * The component name helpfull to identify the component in the list of scene components.
  61060. */
  61061. readonly name: string;
  61062. /**
  61063. * The scene the component belongs to.
  61064. */
  61065. scene: Scene;
  61066. /**
  61067. * Creates a new instance of the component for the given scene
  61068. * @param scene Defines the scene to register the component in
  61069. */
  61070. constructor(scene: Scene);
  61071. /**
  61072. * Registers the component in a given scene
  61073. */
  61074. register(): void;
  61075. /**
  61076. * Rebuilds the elements related to this component in case of
  61077. * context lost for instance.
  61078. */
  61079. rebuild(): void;
  61080. /**
  61081. * Adds all the elements from the container to the scene
  61082. * @param container the container holding the elements
  61083. */
  61084. addFromContainer(container: AbstractScene): void;
  61085. /**
  61086. * Removes all the elements in the container from the scene
  61087. * @param container contains the elements to remove
  61088. * @param dispose if the removed element should be disposed (default: false)
  61089. */
  61090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61091. /**
  61092. * Serializes the component data to the specified json object
  61093. * @param serializationObject The object to serialize to
  61094. */
  61095. serialize(serializationObject: any): void;
  61096. /**
  61097. * Disposes the component and the associated ressources.
  61098. */
  61099. dispose(): void;
  61100. private _draw;
  61101. }
  61102. }
  61103. declare module BABYLON {
  61104. /** @hidden */
  61105. export var depthPixelShader: {
  61106. name: string;
  61107. shader: string;
  61108. };
  61109. }
  61110. declare module BABYLON {
  61111. /** @hidden */
  61112. export var depthVertexShader: {
  61113. name: string;
  61114. shader: string;
  61115. };
  61116. }
  61117. declare module BABYLON {
  61118. /**
  61119. * This represents a depth renderer in Babylon.
  61120. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61121. */
  61122. export class DepthRenderer {
  61123. private _scene;
  61124. private _depthMap;
  61125. private _effect;
  61126. private readonly _storeNonLinearDepth;
  61127. private readonly _clearColor;
  61128. /** Get if the depth renderer is using packed depth or not */
  61129. readonly isPacked: boolean;
  61130. private _cachedDefines;
  61131. private _camera;
  61132. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61133. enabled: boolean;
  61134. /**
  61135. * Specifiess that the depth renderer will only be used within
  61136. * the camera it is created for.
  61137. * This can help forcing its rendering during the camera processing.
  61138. */
  61139. useOnlyInActiveCamera: boolean;
  61140. /** @hidden */
  61141. static _SceneComponentInitialization: (scene: Scene) => void;
  61142. /**
  61143. * Instantiates a depth renderer
  61144. * @param scene The scene the renderer belongs to
  61145. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61146. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61147. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61148. */
  61149. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61150. /**
  61151. * Creates the depth rendering effect and checks if the effect is ready.
  61152. * @param subMesh The submesh to be used to render the depth map of
  61153. * @param useInstances If multiple world instances should be used
  61154. * @returns if the depth renderer is ready to render the depth map
  61155. */
  61156. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61157. /**
  61158. * Gets the texture which the depth map will be written to.
  61159. * @returns The depth map texture
  61160. */
  61161. getDepthMap(): RenderTargetTexture;
  61162. /**
  61163. * Disposes of the depth renderer.
  61164. */
  61165. dispose(): void;
  61166. }
  61167. }
  61168. declare module BABYLON {
  61169. /** @hidden */
  61170. export var minmaxReduxPixelShader: {
  61171. name: string;
  61172. shader: string;
  61173. };
  61174. }
  61175. declare module BABYLON {
  61176. /**
  61177. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61178. * and maximum values from all values of the texture.
  61179. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61180. * The source values are read from the red channel of the texture.
  61181. */
  61182. export class MinMaxReducer {
  61183. /**
  61184. * Observable triggered when the computation has been performed
  61185. */
  61186. onAfterReductionPerformed: Observable<{
  61187. min: number;
  61188. max: number;
  61189. }>;
  61190. protected _camera: Camera;
  61191. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61192. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61193. protected _postProcessManager: PostProcessManager;
  61194. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61195. protected _forceFullscreenViewport: boolean;
  61196. /**
  61197. * Creates a min/max reducer
  61198. * @param camera The camera to use for the post processes
  61199. */
  61200. constructor(camera: Camera);
  61201. /**
  61202. * Gets the texture used to read the values from.
  61203. */
  61204. get sourceTexture(): Nullable<RenderTargetTexture>;
  61205. /**
  61206. * Sets the source texture to read the values from.
  61207. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61208. * because in such textures '1' value must not be taken into account to compute the maximum
  61209. * as this value is used to clear the texture.
  61210. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61211. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61212. * @param depthRedux Indicates if the texture is a depth texture or not
  61213. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61214. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61215. */
  61216. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61217. /**
  61218. * Defines the refresh rate of the computation.
  61219. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61220. */
  61221. get refreshRate(): number;
  61222. set refreshRate(value: number);
  61223. protected _activated: boolean;
  61224. /**
  61225. * Gets the activation status of the reducer
  61226. */
  61227. get activated(): boolean;
  61228. /**
  61229. * Activates the reduction computation.
  61230. * When activated, the observers registered in onAfterReductionPerformed are
  61231. * called after the compuation is performed
  61232. */
  61233. activate(): void;
  61234. /**
  61235. * Deactivates the reduction computation.
  61236. */
  61237. deactivate(): void;
  61238. /**
  61239. * Disposes the min/max reducer
  61240. * @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.
  61241. */
  61242. dispose(disposeAll?: boolean): void;
  61243. }
  61244. }
  61245. declare module BABYLON {
  61246. /**
  61247. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61248. */
  61249. export class DepthReducer extends MinMaxReducer {
  61250. private _depthRenderer;
  61251. private _depthRendererId;
  61252. /**
  61253. * Gets the depth renderer used for the computation.
  61254. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61255. */
  61256. get depthRenderer(): Nullable<DepthRenderer>;
  61257. /**
  61258. * Creates a depth reducer
  61259. * @param camera The camera used to render the depth texture
  61260. */
  61261. constructor(camera: Camera);
  61262. /**
  61263. * Sets the depth renderer to use to generate the depth map
  61264. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61265. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61266. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61267. */
  61268. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61269. /** @hidden */
  61270. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61271. /**
  61272. * Activates the reduction computation.
  61273. * When activated, the observers registered in onAfterReductionPerformed are
  61274. * called after the compuation is performed
  61275. */
  61276. activate(): void;
  61277. /**
  61278. * Deactivates the reduction computation.
  61279. */
  61280. deactivate(): void;
  61281. /**
  61282. * Disposes the depth reducer
  61283. * @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.
  61284. */
  61285. dispose(disposeAll?: boolean): void;
  61286. }
  61287. }
  61288. declare module BABYLON {
  61289. /**
  61290. * A CSM implementation allowing casting shadows on large scenes.
  61291. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61292. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61293. */
  61294. export class CascadedShadowGenerator extends ShadowGenerator {
  61295. private static readonly frustumCornersNDCSpace;
  61296. /**
  61297. * Name of the CSM class
  61298. */
  61299. static CLASSNAME: string;
  61300. /**
  61301. * Defines the default number of cascades used by the CSM.
  61302. */
  61303. static readonly DEFAULT_CASCADES_COUNT: number;
  61304. /**
  61305. * Defines the minimum number of cascades used by the CSM.
  61306. */
  61307. static readonly MIN_CASCADES_COUNT: number;
  61308. /**
  61309. * Defines the maximum number of cascades used by the CSM.
  61310. */
  61311. static readonly MAX_CASCADES_COUNT: number;
  61312. protected _validateFilter(filter: number): number;
  61313. /**
  61314. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61315. */
  61316. penumbraDarkness: number;
  61317. private _numCascades;
  61318. /**
  61319. * Gets or set the number of cascades used by the CSM.
  61320. */
  61321. get numCascades(): number;
  61322. set numCascades(value: number);
  61323. /**
  61324. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61325. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61326. */
  61327. stabilizeCascades: boolean;
  61328. private _freezeShadowCastersBoundingInfo;
  61329. private _freezeShadowCastersBoundingInfoObservable;
  61330. /**
  61331. * Enables or disables the shadow casters bounding info computation.
  61332. * If your shadow casters don't move, you can disable this feature.
  61333. * If it is enabled, the bounding box computation is done every frame.
  61334. */
  61335. get freezeShadowCastersBoundingInfo(): boolean;
  61336. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61337. private _scbiMin;
  61338. private _scbiMax;
  61339. protected _computeShadowCastersBoundingInfo(): void;
  61340. protected _shadowCastersBoundingInfo: BoundingInfo;
  61341. /**
  61342. * Gets or sets the shadow casters bounding info.
  61343. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61344. * so that the system won't overwrite the bounds you provide
  61345. */
  61346. get shadowCastersBoundingInfo(): BoundingInfo;
  61347. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61348. protected _breaksAreDirty: boolean;
  61349. protected _minDistance: number;
  61350. protected _maxDistance: number;
  61351. /**
  61352. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61353. *
  61354. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61355. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61356. * @param min minimal distance for the breaks (default to 0.)
  61357. * @param max maximal distance for the breaks (default to 1.)
  61358. */
  61359. setMinMaxDistance(min: number, max: number): void;
  61360. /** Gets the minimal distance used in the cascade break computation */
  61361. get minDistance(): number;
  61362. /** Gets the maximal distance used in the cascade break computation */
  61363. get maxDistance(): number;
  61364. /**
  61365. * Gets the class name of that object
  61366. * @returns "CascadedShadowGenerator"
  61367. */
  61368. getClassName(): string;
  61369. private _cascadeMinExtents;
  61370. private _cascadeMaxExtents;
  61371. /**
  61372. * Gets a cascade minimum extents
  61373. * @param cascadeIndex index of the cascade
  61374. * @returns the minimum cascade extents
  61375. */
  61376. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61377. /**
  61378. * Gets a cascade maximum extents
  61379. * @param cascadeIndex index of the cascade
  61380. * @returns the maximum cascade extents
  61381. */
  61382. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61383. private _cascades;
  61384. private _currentLayer;
  61385. private _viewSpaceFrustumsZ;
  61386. private _viewMatrices;
  61387. private _projectionMatrices;
  61388. private _transformMatrices;
  61389. private _transformMatricesAsArray;
  61390. private _frustumLengths;
  61391. private _lightSizeUVCorrection;
  61392. private _depthCorrection;
  61393. private _frustumCornersWorldSpace;
  61394. private _frustumCenter;
  61395. private _shadowCameraPos;
  61396. private _shadowMaxZ;
  61397. /**
  61398. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61399. * It defaults to camera.maxZ
  61400. */
  61401. get shadowMaxZ(): number;
  61402. /**
  61403. * Sets the shadow max z distance.
  61404. */
  61405. set shadowMaxZ(value: number);
  61406. protected _debug: boolean;
  61407. /**
  61408. * Gets or sets the debug flag.
  61409. * When enabled, the cascades are materialized by different colors on the screen.
  61410. */
  61411. get debug(): boolean;
  61412. set debug(dbg: boolean);
  61413. private _depthClamp;
  61414. /**
  61415. * Gets or sets the depth clamping value.
  61416. *
  61417. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61418. * to account for the shadow casters far away.
  61419. *
  61420. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61421. */
  61422. get depthClamp(): boolean;
  61423. set depthClamp(value: boolean);
  61424. private _cascadeBlendPercentage;
  61425. /**
  61426. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61427. * It defaults to 0.1 (10% blending).
  61428. */
  61429. get cascadeBlendPercentage(): number;
  61430. set cascadeBlendPercentage(value: number);
  61431. private _lambda;
  61432. /**
  61433. * Gets or set the lambda parameter.
  61434. * This parameter is used to split the camera frustum and create the cascades.
  61435. * 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.
  61436. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61437. */
  61438. get lambda(): number;
  61439. set lambda(value: number);
  61440. /**
  61441. * Gets the view matrix corresponding to a given cascade
  61442. * @param cascadeNum cascade to retrieve the view matrix from
  61443. * @returns the cascade view matrix
  61444. */
  61445. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61446. /**
  61447. * Gets the projection matrix corresponding to a given cascade
  61448. * @param cascadeNum cascade to retrieve the projection matrix from
  61449. * @returns the cascade projection matrix
  61450. */
  61451. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61452. /**
  61453. * Gets the transformation matrix corresponding to a given cascade
  61454. * @param cascadeNum cascade to retrieve the transformation matrix from
  61455. * @returns the cascade transformation matrix
  61456. */
  61457. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61458. private _depthRenderer;
  61459. /**
  61460. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61461. *
  61462. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61463. *
  61464. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61465. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61466. * @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
  61467. */
  61468. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61469. private _depthReducer;
  61470. private _autoCalcDepthBounds;
  61471. /**
  61472. * Gets or sets the autoCalcDepthBounds property.
  61473. *
  61474. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61475. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61476. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61477. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61478. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61479. */
  61480. get autoCalcDepthBounds(): boolean;
  61481. set autoCalcDepthBounds(value: boolean);
  61482. /**
  61483. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61484. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61485. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61486. * for setting the refresh rate on the renderer yourself!
  61487. */
  61488. get autoCalcDepthBoundsRefreshRate(): number;
  61489. set autoCalcDepthBoundsRefreshRate(value: number);
  61490. /**
  61491. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61492. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61493. * you change the camera near/far planes!
  61494. */
  61495. splitFrustum(): void;
  61496. private _splitFrustum;
  61497. private _computeMatrices;
  61498. private _computeFrustumInWorldSpace;
  61499. private _computeCascadeFrustum;
  61500. /**
  61501. * Support test.
  61502. */
  61503. static get IsSupported(): boolean;
  61504. /** @hidden */
  61505. static _SceneComponentInitialization: (scene: Scene) => void;
  61506. /**
  61507. * Creates a Cascaded Shadow Generator object.
  61508. * A ShadowGenerator is the required tool to use the shadows.
  61509. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61510. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61511. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61512. * @param light The directional light object generating the shadows.
  61513. * @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.
  61514. */
  61515. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61516. protected _initializeGenerator(): void;
  61517. protected _createTargetRenderTexture(): void;
  61518. protected _initializeShadowMap(): void;
  61519. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61520. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61521. /**
  61522. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61523. * @param defines Defines of the material we want to update
  61524. * @param lightIndex Index of the light in the enabled light list of the material
  61525. */
  61526. prepareDefines(defines: any, lightIndex: number): void;
  61527. /**
  61528. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61529. * defined in the generator but impacting the effect).
  61530. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61531. * @param effect The effect we are binfing the information for
  61532. */
  61533. bindShadowLight(lightIndex: string, effect: Effect): void;
  61534. /**
  61535. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61536. * (eq to view projection * shadow projection matrices)
  61537. * @returns The transform matrix used to create the shadow map
  61538. */
  61539. getTransformMatrix(): Matrix;
  61540. /**
  61541. * Disposes the ShadowGenerator.
  61542. * Returns nothing.
  61543. */
  61544. dispose(): void;
  61545. /**
  61546. * Serializes the shadow generator setup to a json object.
  61547. * @returns The serialized JSON object
  61548. */
  61549. serialize(): any;
  61550. /**
  61551. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61552. * @param parsedShadowGenerator The JSON object to parse
  61553. * @param scene The scene to create the shadow map for
  61554. * @returns The parsed shadow generator
  61555. */
  61556. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61557. }
  61558. }
  61559. declare module BABYLON {
  61560. /**
  61561. * Defines the shadow generator component responsible to manage any shadow generators
  61562. * in a given scene.
  61563. */
  61564. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61565. /**
  61566. * The component name helpfull to identify the component in the list of scene components.
  61567. */
  61568. readonly name: string;
  61569. /**
  61570. * The scene the component belongs to.
  61571. */
  61572. scene: Scene;
  61573. /**
  61574. * Creates a new instance of the component for the given scene
  61575. * @param scene Defines the scene to register the component in
  61576. */
  61577. constructor(scene: Scene);
  61578. /**
  61579. * Registers the component in a given scene
  61580. */
  61581. register(): void;
  61582. /**
  61583. * Rebuilds the elements related to this component in case of
  61584. * context lost for instance.
  61585. */
  61586. rebuild(): void;
  61587. /**
  61588. * Serializes the component data to the specified json object
  61589. * @param serializationObject The object to serialize to
  61590. */
  61591. serialize(serializationObject: any): void;
  61592. /**
  61593. * Adds all the elements from the container to the scene
  61594. * @param container the container holding the elements
  61595. */
  61596. addFromContainer(container: AbstractScene): void;
  61597. /**
  61598. * Removes all the elements in the container from the scene
  61599. * @param container contains the elements to remove
  61600. * @param dispose if the removed element should be disposed (default: false)
  61601. */
  61602. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61603. /**
  61604. * Rebuilds the elements related to this component in case of
  61605. * context lost for instance.
  61606. */
  61607. dispose(): void;
  61608. private _gatherRenderTargets;
  61609. }
  61610. }
  61611. declare module BABYLON {
  61612. /**
  61613. * A point light is a light defined by an unique point in world space.
  61614. * The light is emitted in every direction from this point.
  61615. * A good example of a point light is a standard light bulb.
  61616. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61617. */
  61618. export class PointLight extends ShadowLight {
  61619. private _shadowAngle;
  61620. /**
  61621. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61622. * This specifies what angle the shadow will use to be created.
  61623. *
  61624. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61625. */
  61626. get shadowAngle(): number;
  61627. /**
  61628. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61629. * This specifies what angle the shadow will use to be created.
  61630. *
  61631. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61632. */
  61633. set shadowAngle(value: number);
  61634. /**
  61635. * Gets the direction if it has been set.
  61636. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61637. */
  61638. get direction(): Vector3;
  61639. /**
  61640. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61641. */
  61642. set direction(value: Vector3);
  61643. /**
  61644. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61645. * A PointLight emits the light in every direction.
  61646. * It can cast shadows.
  61647. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61648. * ```javascript
  61649. * var pointLight = new PointLight("pl", camera.position, scene);
  61650. * ```
  61651. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61652. * @param name The light friendly name
  61653. * @param position The position of the point light in the scene
  61654. * @param scene The scene the lights belongs to
  61655. */
  61656. constructor(name: string, position: Vector3, scene: Scene);
  61657. /**
  61658. * Returns the string "PointLight"
  61659. * @returns the class name
  61660. */
  61661. getClassName(): string;
  61662. /**
  61663. * Returns the integer 0.
  61664. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61665. */
  61666. getTypeID(): number;
  61667. /**
  61668. * Specifies wether or not the shadowmap should be a cube texture.
  61669. * @returns true if the shadowmap needs to be a cube texture.
  61670. */
  61671. needCube(): boolean;
  61672. /**
  61673. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61674. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61675. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61676. */
  61677. getShadowDirection(faceIndex?: number): Vector3;
  61678. /**
  61679. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61680. * - fov = PI / 2
  61681. * - aspect ratio : 1.0
  61682. * - z-near and far equal to the active camera minZ and maxZ.
  61683. * Returns the PointLight.
  61684. */
  61685. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61686. protected _buildUniformLayout(): void;
  61687. /**
  61688. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61689. * @param effect The effect to update
  61690. * @param lightIndex The index of the light in the effect to update
  61691. * @returns The point light
  61692. */
  61693. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61695. /**
  61696. * Prepares the list of defines specific to the light type.
  61697. * @param defines the list of defines
  61698. * @param lightIndex defines the index of the light for the effect
  61699. */
  61700. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61701. }
  61702. }
  61703. declare module BABYLON {
  61704. /**
  61705. * Header information of HDR texture files.
  61706. */
  61707. export interface HDRInfo {
  61708. /**
  61709. * The height of the texture in pixels.
  61710. */
  61711. height: number;
  61712. /**
  61713. * The width of the texture in pixels.
  61714. */
  61715. width: number;
  61716. /**
  61717. * The index of the beginning of the data in the binary file.
  61718. */
  61719. dataPosition: number;
  61720. }
  61721. /**
  61722. * This groups tools to convert HDR texture to native colors array.
  61723. */
  61724. export class HDRTools {
  61725. private static Ldexp;
  61726. private static Rgbe2float;
  61727. private static readStringLine;
  61728. /**
  61729. * Reads header information from an RGBE texture stored in a native array.
  61730. * More information on this format are available here:
  61731. * https://en.wikipedia.org/wiki/RGBE_image_format
  61732. *
  61733. * @param uint8array The binary file stored in native array.
  61734. * @return The header information.
  61735. */
  61736. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61737. /**
  61738. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61739. * This RGBE texture needs to store the information as a panorama.
  61740. *
  61741. * More information on this format are available here:
  61742. * https://en.wikipedia.org/wiki/RGBE_image_format
  61743. *
  61744. * @param buffer The binary file stored in an array buffer.
  61745. * @param size The expected size of the extracted cubemap.
  61746. * @return The Cube Map information.
  61747. */
  61748. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61749. /**
  61750. * Returns the pixels data extracted from an RGBE texture.
  61751. * This pixels will be stored left to right up to down in the R G B order in one array.
  61752. *
  61753. * More information on this format are available here:
  61754. * https://en.wikipedia.org/wiki/RGBE_image_format
  61755. *
  61756. * @param uint8array The binary file stored in an array buffer.
  61757. * @param hdrInfo The header information of the file.
  61758. * @return The pixels data in RGB right to left up to down order.
  61759. */
  61760. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61761. private static RGBE_ReadPixels_RLE;
  61762. private static RGBE_ReadPixels_NOT_RLE;
  61763. }
  61764. }
  61765. declare module BABYLON {
  61766. /**
  61767. * Effect Render Options
  61768. */
  61769. export interface IEffectRendererOptions {
  61770. /**
  61771. * Defines the vertices positions.
  61772. */
  61773. positions?: number[];
  61774. /**
  61775. * Defines the indices.
  61776. */
  61777. indices?: number[];
  61778. }
  61779. /**
  61780. * Helper class to render one or more effects.
  61781. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61782. */
  61783. export class EffectRenderer {
  61784. private engine;
  61785. private static _DefaultOptions;
  61786. private _vertexBuffers;
  61787. private _indexBuffer;
  61788. private _fullscreenViewport;
  61789. /**
  61790. * Creates an effect renderer
  61791. * @param engine the engine to use for rendering
  61792. * @param options defines the options of the effect renderer
  61793. */
  61794. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61795. /**
  61796. * Sets the current viewport in normalized coordinates 0-1
  61797. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61798. */
  61799. setViewport(viewport?: Viewport): void;
  61800. /**
  61801. * Binds the embedded attributes buffer to the effect.
  61802. * @param effect Defines the effect to bind the attributes for
  61803. */
  61804. bindBuffers(effect: Effect): void;
  61805. /**
  61806. * Sets the current effect wrapper to use during draw.
  61807. * The effect needs to be ready before calling this api.
  61808. * This also sets the default full screen position attribute.
  61809. * @param effectWrapper Defines the effect to draw with
  61810. */
  61811. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61812. /**
  61813. * Restores engine states
  61814. */
  61815. restoreStates(): void;
  61816. /**
  61817. * Draws a full screen quad.
  61818. */
  61819. draw(): void;
  61820. private isRenderTargetTexture;
  61821. /**
  61822. * renders one or more effects to a specified texture
  61823. * @param effectWrapper the effect to renderer
  61824. * @param outputTexture texture to draw to, if null it will render to the screen.
  61825. */
  61826. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61827. /**
  61828. * Disposes of the effect renderer
  61829. */
  61830. dispose(): void;
  61831. }
  61832. /**
  61833. * Options to create an EffectWrapper
  61834. */
  61835. interface EffectWrapperCreationOptions {
  61836. /**
  61837. * Engine to use to create the effect
  61838. */
  61839. engine: ThinEngine;
  61840. /**
  61841. * Fragment shader for the effect
  61842. */
  61843. fragmentShader: string;
  61844. /**
  61845. * Use the shader store instead of direct source code
  61846. */
  61847. useShaderStore?: boolean;
  61848. /**
  61849. * Vertex shader for the effect
  61850. */
  61851. vertexShader?: string;
  61852. /**
  61853. * Attributes to use in the shader
  61854. */
  61855. attributeNames?: Array<string>;
  61856. /**
  61857. * Uniforms to use in the shader
  61858. */
  61859. uniformNames?: Array<string>;
  61860. /**
  61861. * Texture sampler names to use in the shader
  61862. */
  61863. samplerNames?: Array<string>;
  61864. /**
  61865. * Defines to use in the shader
  61866. */
  61867. defines?: Array<string>;
  61868. /**
  61869. * Callback when effect is compiled
  61870. */
  61871. onCompiled?: Nullable<(effect: Effect) => void>;
  61872. /**
  61873. * The friendly name of the effect displayed in Spector.
  61874. */
  61875. name?: string;
  61876. }
  61877. /**
  61878. * Wraps an effect to be used for rendering
  61879. */
  61880. export class EffectWrapper {
  61881. /**
  61882. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61883. */
  61884. onApplyObservable: Observable<{}>;
  61885. /**
  61886. * The underlying effect
  61887. */
  61888. effect: Effect;
  61889. /**
  61890. * Creates an effect to be renderer
  61891. * @param creationOptions options to create the effect
  61892. */
  61893. constructor(creationOptions: EffectWrapperCreationOptions);
  61894. /**
  61895. * Disposes of the effect wrapper
  61896. */
  61897. dispose(): void;
  61898. }
  61899. }
  61900. declare module BABYLON {
  61901. /** @hidden */
  61902. export var hdrFilteringVertexShader: {
  61903. name: string;
  61904. shader: string;
  61905. };
  61906. }
  61907. declare module BABYLON {
  61908. /** @hidden */
  61909. export var hdrFilteringPixelShader: {
  61910. name: string;
  61911. shader: string;
  61912. };
  61913. }
  61914. declare module BABYLON {
  61915. /**
  61916. * Options for texture filtering
  61917. */
  61918. interface IHDRFilteringOptions {
  61919. /**
  61920. * Scales pixel intensity for the input HDR map.
  61921. */
  61922. hdrScale?: number;
  61923. /**
  61924. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61925. */
  61926. quality?: number;
  61927. }
  61928. /**
  61929. * Filters HDR maps to get correct renderings of PBR reflections
  61930. */
  61931. export class HDRFiltering {
  61932. private _engine;
  61933. private _effectRenderer;
  61934. private _effectWrapper;
  61935. private _lodGenerationOffset;
  61936. private _lodGenerationScale;
  61937. /**
  61938. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61939. * you care about baking speed.
  61940. */
  61941. quality: number;
  61942. /**
  61943. * Scales pixel intensity for the input HDR map.
  61944. */
  61945. hdrScale: number;
  61946. /**
  61947. * Instantiates HDR filter for reflection maps
  61948. *
  61949. * @param engine Thin engine
  61950. * @param options Options
  61951. */
  61952. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61953. private _createRenderTarget;
  61954. private _prefilterInternal;
  61955. private _createEffect;
  61956. /**
  61957. * Get a value indicating if the filter is ready to be used
  61958. * @param texture Texture to filter
  61959. * @returns true if the filter is ready
  61960. */
  61961. isReady(texture: BaseTexture): boolean;
  61962. /**
  61963. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61964. * Prefiltering will be invoked at the end of next rendering pass.
  61965. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61966. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61967. * @param texture Texture to filter
  61968. * @param onFinished Callback when filtering is done
  61969. * @return Promise called when prefiltering is done
  61970. */
  61971. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61972. }
  61973. }
  61974. declare module BABYLON {
  61975. /**
  61976. * This represents a texture coming from an HDR input.
  61977. *
  61978. * The only supported format is currently panorama picture stored in RGBE format.
  61979. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61980. */
  61981. export class HDRCubeTexture extends BaseTexture {
  61982. private static _facesMapping;
  61983. private _generateHarmonics;
  61984. private _noMipmap;
  61985. private _prefilterOnLoad;
  61986. private _textureMatrix;
  61987. private _size;
  61988. private _onLoad;
  61989. private _onError;
  61990. /**
  61991. * The texture URL.
  61992. */
  61993. url: string;
  61994. protected _isBlocking: boolean;
  61995. /**
  61996. * Sets wether or not the texture is blocking during loading.
  61997. */
  61998. set isBlocking(value: boolean);
  61999. /**
  62000. * Gets wether or not the texture is blocking during loading.
  62001. */
  62002. get isBlocking(): boolean;
  62003. protected _rotationY: number;
  62004. /**
  62005. * Sets texture matrix rotation angle around Y axis in radians.
  62006. */
  62007. set rotationY(value: number);
  62008. /**
  62009. * Gets texture matrix rotation angle around Y axis radians.
  62010. */
  62011. get rotationY(): number;
  62012. /**
  62013. * Gets or sets the center of the bounding box associated with the cube texture
  62014. * It must define where the camera used to render the texture was set
  62015. */
  62016. boundingBoxPosition: Vector3;
  62017. private _boundingBoxSize;
  62018. /**
  62019. * Gets or sets the size of the bounding box associated with the cube texture
  62020. * When defined, the cubemap will switch to local mode
  62021. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62022. * @example https://www.babylonjs-playground.com/#RNASML
  62023. */
  62024. set boundingBoxSize(value: Vector3);
  62025. get boundingBoxSize(): Vector3;
  62026. /**
  62027. * Instantiates an HDRTexture from the following parameters.
  62028. *
  62029. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62030. * @param sceneOrEngine The scene or engine the texture will be used in
  62031. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62032. * @param noMipmap Forces to not generate the mipmap if true
  62033. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62034. * @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)
  62035. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62036. */
  62037. 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>);
  62038. /**
  62039. * Get the current class name of the texture useful for serialization or dynamic coding.
  62040. * @returns "HDRCubeTexture"
  62041. */
  62042. getClassName(): string;
  62043. /**
  62044. * Occurs when the file is raw .hdr file.
  62045. */
  62046. private loadTexture;
  62047. clone(): HDRCubeTexture;
  62048. delayLoad(): void;
  62049. /**
  62050. * Get the texture reflection matrix used to rotate/transform the reflection.
  62051. * @returns the reflection matrix
  62052. */
  62053. getReflectionTextureMatrix(): Matrix;
  62054. /**
  62055. * Set the texture reflection matrix used to rotate/transform the reflection.
  62056. * @param value Define the reflection matrix to set
  62057. */
  62058. setReflectionTextureMatrix(value: Matrix): void;
  62059. /**
  62060. * Parses a JSON representation of an HDR Texture in order to create the texture
  62061. * @param parsedTexture Define the JSON representation
  62062. * @param scene Define the scene the texture should be created in
  62063. * @param rootUrl Define the root url in case we need to load relative dependencies
  62064. * @returns the newly created texture after parsing
  62065. */
  62066. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62067. serialize(): any;
  62068. }
  62069. }
  62070. declare module BABYLON {
  62071. /**
  62072. * Class used to control physics engine
  62073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62074. */
  62075. export class PhysicsEngine implements IPhysicsEngine {
  62076. private _physicsPlugin;
  62077. /**
  62078. * Global value used to control the smallest number supported by the simulation
  62079. */
  62080. static Epsilon: number;
  62081. private _impostors;
  62082. private _joints;
  62083. private _subTimeStep;
  62084. /**
  62085. * Gets the gravity vector used by the simulation
  62086. */
  62087. gravity: Vector3;
  62088. /**
  62089. * Factory used to create the default physics plugin.
  62090. * @returns The default physics plugin
  62091. */
  62092. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62093. /**
  62094. * Creates a new Physics Engine
  62095. * @param gravity defines the gravity vector used by the simulation
  62096. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62097. */
  62098. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62099. /**
  62100. * Sets the gravity vector used by the simulation
  62101. * @param gravity defines the gravity vector to use
  62102. */
  62103. setGravity(gravity: Vector3): void;
  62104. /**
  62105. * Set the time step of the physics engine.
  62106. * Default is 1/60.
  62107. * To slow it down, enter 1/600 for example.
  62108. * To speed it up, 1/30
  62109. * @param newTimeStep defines the new timestep to apply to this world.
  62110. */
  62111. setTimeStep(newTimeStep?: number): void;
  62112. /**
  62113. * Get the time step of the physics engine.
  62114. * @returns the current time step
  62115. */
  62116. getTimeStep(): number;
  62117. /**
  62118. * Set the sub time step of the physics engine.
  62119. * Default is 0 meaning there is no sub steps
  62120. * To increase physics resolution precision, set a small value (like 1 ms)
  62121. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62122. */
  62123. setSubTimeStep(subTimeStep?: number): void;
  62124. /**
  62125. * Get the sub time step of the physics engine.
  62126. * @returns the current sub time step
  62127. */
  62128. getSubTimeStep(): number;
  62129. /**
  62130. * Release all resources
  62131. */
  62132. dispose(): void;
  62133. /**
  62134. * Gets the name of the current physics plugin
  62135. * @returns the name of the plugin
  62136. */
  62137. getPhysicsPluginName(): string;
  62138. /**
  62139. * Adding a new impostor for the impostor tracking.
  62140. * This will be done by the impostor itself.
  62141. * @param impostor the impostor to add
  62142. */
  62143. addImpostor(impostor: PhysicsImpostor): void;
  62144. /**
  62145. * Remove an impostor from the engine.
  62146. * This impostor and its mesh will not longer be updated by the physics engine.
  62147. * @param impostor the impostor to remove
  62148. */
  62149. removeImpostor(impostor: PhysicsImpostor): void;
  62150. /**
  62151. * Add a joint to the physics engine
  62152. * @param mainImpostor defines the main impostor to which the joint is added.
  62153. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62154. * @param joint defines the joint that will connect both impostors.
  62155. */
  62156. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62157. /**
  62158. * Removes a joint from the simulation
  62159. * @param mainImpostor defines the impostor used with the joint
  62160. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62161. * @param joint defines the joint to remove
  62162. */
  62163. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62164. /**
  62165. * Called by the scene. No need to call it.
  62166. * @param delta defines the timespam between frames
  62167. */
  62168. _step(delta: number): void;
  62169. /**
  62170. * Gets the current plugin used to run the simulation
  62171. * @returns current plugin
  62172. */
  62173. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62174. /**
  62175. * Gets the list of physic impostors
  62176. * @returns an array of PhysicsImpostor
  62177. */
  62178. getImpostors(): Array<PhysicsImpostor>;
  62179. /**
  62180. * Gets the impostor for a physics enabled object
  62181. * @param object defines the object impersonated by the impostor
  62182. * @returns the PhysicsImpostor or null if not found
  62183. */
  62184. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62185. /**
  62186. * Gets the impostor for a physics body object
  62187. * @param body defines physics body used by the impostor
  62188. * @returns the PhysicsImpostor or null if not found
  62189. */
  62190. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62191. /**
  62192. * Does a raycast in the physics world
  62193. * @param from when should the ray start?
  62194. * @param to when should the ray end?
  62195. * @returns PhysicsRaycastResult
  62196. */
  62197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62198. }
  62199. }
  62200. declare module BABYLON {
  62201. /** @hidden */
  62202. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62203. private _useDeltaForWorldStep;
  62204. world: any;
  62205. name: string;
  62206. private _physicsMaterials;
  62207. private _fixedTimeStep;
  62208. private _cannonRaycastResult;
  62209. private _raycastResult;
  62210. private _physicsBodysToRemoveAfterStep;
  62211. private _firstFrame;
  62212. BJSCANNON: any;
  62213. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62214. setGravity(gravity: Vector3): void;
  62215. setTimeStep(timeStep: number): void;
  62216. getTimeStep(): number;
  62217. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62218. private _removeMarkedPhysicsBodiesFromWorld;
  62219. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62220. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62221. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62222. private _processChildMeshes;
  62223. removePhysicsBody(impostor: PhysicsImpostor): void;
  62224. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62225. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62226. private _addMaterial;
  62227. private _checkWithEpsilon;
  62228. private _createShape;
  62229. private _createHeightmap;
  62230. private _minus90X;
  62231. private _plus90X;
  62232. private _tmpPosition;
  62233. private _tmpDeltaPosition;
  62234. private _tmpUnityRotation;
  62235. private _updatePhysicsBodyTransformation;
  62236. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62237. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62238. isSupported(): boolean;
  62239. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62240. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62241. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62242. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62243. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62244. getBodyMass(impostor: PhysicsImpostor): number;
  62245. getBodyFriction(impostor: PhysicsImpostor): number;
  62246. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62247. getBodyRestitution(impostor: PhysicsImpostor): number;
  62248. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62249. sleepBody(impostor: PhysicsImpostor): void;
  62250. wakeUpBody(impostor: PhysicsImpostor): void;
  62251. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62252. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62253. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62254. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62255. getRadius(impostor: PhysicsImpostor): number;
  62256. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62257. dispose(): void;
  62258. private _extendNamespace;
  62259. /**
  62260. * Does a raycast in the physics world
  62261. * @param from when should the ray start?
  62262. * @param to when should the ray end?
  62263. * @returns PhysicsRaycastResult
  62264. */
  62265. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. /** @hidden */
  62270. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62271. private _useDeltaForWorldStep;
  62272. world: any;
  62273. name: string;
  62274. BJSOIMO: any;
  62275. private _raycastResult;
  62276. private _fixedTimeStep;
  62277. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62278. setGravity(gravity: Vector3): void;
  62279. setTimeStep(timeStep: number): void;
  62280. getTimeStep(): number;
  62281. private _tmpImpostorsArray;
  62282. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62283. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62284. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62285. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62286. private _tmpPositionVector;
  62287. removePhysicsBody(impostor: PhysicsImpostor): void;
  62288. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62289. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62290. isSupported(): boolean;
  62291. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62293. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62294. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62295. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62296. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62297. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62298. getBodyMass(impostor: PhysicsImpostor): number;
  62299. getBodyFriction(impostor: PhysicsImpostor): number;
  62300. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62301. getBodyRestitution(impostor: PhysicsImpostor): number;
  62302. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62303. sleepBody(impostor: PhysicsImpostor): void;
  62304. wakeUpBody(impostor: PhysicsImpostor): void;
  62305. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62306. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62307. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62308. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62309. getRadius(impostor: PhysicsImpostor): number;
  62310. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62311. dispose(): void;
  62312. /**
  62313. * Does a raycast in the physics world
  62314. * @param from when should the ray start?
  62315. * @param to when should the ray end?
  62316. * @returns PhysicsRaycastResult
  62317. */
  62318. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62319. }
  62320. }
  62321. declare module BABYLON {
  62322. /**
  62323. * AmmoJS Physics plugin
  62324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62325. * @see https://github.com/kripken/ammo.js/
  62326. */
  62327. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62328. private _useDeltaForWorldStep;
  62329. /**
  62330. * Reference to the Ammo library
  62331. */
  62332. bjsAMMO: any;
  62333. /**
  62334. * Created ammoJS world which physics bodies are added to
  62335. */
  62336. world: any;
  62337. /**
  62338. * Name of the plugin
  62339. */
  62340. name: string;
  62341. private _timeStep;
  62342. private _fixedTimeStep;
  62343. private _maxSteps;
  62344. private _tmpQuaternion;
  62345. private _tmpAmmoTransform;
  62346. private _tmpAmmoQuaternion;
  62347. private _tmpAmmoConcreteContactResultCallback;
  62348. private _collisionConfiguration;
  62349. private _dispatcher;
  62350. private _overlappingPairCache;
  62351. private _solver;
  62352. private _softBodySolver;
  62353. private _tmpAmmoVectorA;
  62354. private _tmpAmmoVectorB;
  62355. private _tmpAmmoVectorC;
  62356. private _tmpAmmoVectorD;
  62357. private _tmpContactCallbackResult;
  62358. private _tmpAmmoVectorRCA;
  62359. private _tmpAmmoVectorRCB;
  62360. private _raycastResult;
  62361. private _tmpContactPoint;
  62362. private static readonly DISABLE_COLLISION_FLAG;
  62363. private static readonly KINEMATIC_FLAG;
  62364. private static readonly DISABLE_DEACTIVATION_FLAG;
  62365. /**
  62366. * Initializes the ammoJS plugin
  62367. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62368. * @param ammoInjection can be used to inject your own ammo reference
  62369. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62370. */
  62371. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62372. /**
  62373. * Sets the gravity of the physics world (m/(s^2))
  62374. * @param gravity Gravity to set
  62375. */
  62376. setGravity(gravity: Vector3): void;
  62377. /**
  62378. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62379. * @param timeStep timestep to use in seconds
  62380. */
  62381. setTimeStep(timeStep: number): void;
  62382. /**
  62383. * 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)
  62384. * @param fixedTimeStep fixedTimeStep to use in seconds
  62385. */
  62386. setFixedTimeStep(fixedTimeStep: number): void;
  62387. /**
  62388. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62389. * @param maxSteps the maximum number of steps by the physics engine per frame
  62390. */
  62391. setMaxSteps(maxSteps: number): void;
  62392. /**
  62393. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62394. * @returns the current timestep in seconds
  62395. */
  62396. getTimeStep(): number;
  62397. /**
  62398. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62399. */
  62400. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62401. private _isImpostorInContact;
  62402. private _isImpostorPairInContact;
  62403. private _stepSimulation;
  62404. /**
  62405. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62406. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62407. * After the step the babylon meshes are set to the position of the physics imposters
  62408. * @param delta amount of time to step forward
  62409. * @param impostors array of imposters to update before/after the step
  62410. */
  62411. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62412. /**
  62413. * Update babylon mesh to match physics world object
  62414. * @param impostor imposter to match
  62415. */
  62416. private _afterSoftStep;
  62417. /**
  62418. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62419. * @param impostor imposter to match
  62420. */
  62421. private _ropeStep;
  62422. /**
  62423. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62424. * @param impostor imposter to match
  62425. */
  62426. private _softbodyOrClothStep;
  62427. private _tmpMatrix;
  62428. /**
  62429. * Applies an impulse on the imposter
  62430. * @param impostor imposter to apply impulse to
  62431. * @param force amount of force to be applied to the imposter
  62432. * @param contactPoint the location to apply the impulse on the imposter
  62433. */
  62434. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62435. /**
  62436. * Applies a force on the imposter
  62437. * @param impostor imposter to apply force
  62438. * @param force amount of force to be applied to the imposter
  62439. * @param contactPoint the location to apply the force on the imposter
  62440. */
  62441. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62442. /**
  62443. * Creates a physics body using the plugin
  62444. * @param impostor the imposter to create the physics body on
  62445. */
  62446. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62447. /**
  62448. * Removes the physics body from the imposter and disposes of the body's memory
  62449. * @param impostor imposter to remove the physics body from
  62450. */
  62451. removePhysicsBody(impostor: PhysicsImpostor): void;
  62452. /**
  62453. * Generates a joint
  62454. * @param impostorJoint the imposter joint to create the joint with
  62455. */
  62456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62457. /**
  62458. * Removes a joint
  62459. * @param impostorJoint the imposter joint to remove the joint from
  62460. */
  62461. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62462. private _addMeshVerts;
  62463. /**
  62464. * Initialise the soft body vertices to match its object's (mesh) vertices
  62465. * Softbody vertices (nodes) are in world space and to match this
  62466. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62467. * @param impostor to create the softbody for
  62468. */
  62469. private _softVertexData;
  62470. /**
  62471. * Create an impostor's soft body
  62472. * @param impostor to create the softbody for
  62473. */
  62474. private _createSoftbody;
  62475. /**
  62476. * Create cloth for an impostor
  62477. * @param impostor to create the softbody for
  62478. */
  62479. private _createCloth;
  62480. /**
  62481. * Create rope for an impostor
  62482. * @param impostor to create the softbody for
  62483. */
  62484. private _createRope;
  62485. /**
  62486. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62487. * @param impostor to create the custom physics shape for
  62488. */
  62489. private _createCustom;
  62490. private _addHullVerts;
  62491. private _createShape;
  62492. /**
  62493. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62494. * @param impostor imposter containing the physics body and babylon object
  62495. */
  62496. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62497. /**
  62498. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62499. * @param impostor imposter containing the physics body and babylon object
  62500. * @param newPosition new position
  62501. * @param newRotation new rotation
  62502. */
  62503. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62504. /**
  62505. * If this plugin is supported
  62506. * @returns true if its supported
  62507. */
  62508. isSupported(): boolean;
  62509. /**
  62510. * Sets the linear velocity of the physics body
  62511. * @param impostor imposter to set the velocity on
  62512. * @param velocity velocity to set
  62513. */
  62514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62515. /**
  62516. * Sets the angular velocity of the physics body
  62517. * @param impostor imposter to set the velocity on
  62518. * @param velocity velocity to set
  62519. */
  62520. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62521. /**
  62522. * gets the linear velocity
  62523. * @param impostor imposter to get linear velocity from
  62524. * @returns linear velocity
  62525. */
  62526. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62527. /**
  62528. * gets the angular velocity
  62529. * @param impostor imposter to get angular velocity from
  62530. * @returns angular velocity
  62531. */
  62532. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62533. /**
  62534. * Sets the mass of physics body
  62535. * @param impostor imposter to set the mass on
  62536. * @param mass mass to set
  62537. */
  62538. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62539. /**
  62540. * Gets the mass of the physics body
  62541. * @param impostor imposter to get the mass from
  62542. * @returns mass
  62543. */
  62544. getBodyMass(impostor: PhysicsImpostor): number;
  62545. /**
  62546. * Gets friction of the impostor
  62547. * @param impostor impostor to get friction from
  62548. * @returns friction value
  62549. */
  62550. getBodyFriction(impostor: PhysicsImpostor): number;
  62551. /**
  62552. * Sets friction of the impostor
  62553. * @param impostor impostor to set friction on
  62554. * @param friction friction value
  62555. */
  62556. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62557. /**
  62558. * Gets restitution of the impostor
  62559. * @param impostor impostor to get restitution from
  62560. * @returns restitution value
  62561. */
  62562. getBodyRestitution(impostor: PhysicsImpostor): number;
  62563. /**
  62564. * Sets resitution of the impostor
  62565. * @param impostor impostor to set resitution on
  62566. * @param restitution resitution value
  62567. */
  62568. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62569. /**
  62570. * Gets pressure inside the impostor
  62571. * @param impostor impostor to get pressure from
  62572. * @returns pressure value
  62573. */
  62574. getBodyPressure(impostor: PhysicsImpostor): number;
  62575. /**
  62576. * Sets pressure inside a soft body impostor
  62577. * Cloth and rope must remain 0 pressure
  62578. * @param impostor impostor to set pressure on
  62579. * @param pressure pressure value
  62580. */
  62581. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62582. /**
  62583. * Gets stiffness of the impostor
  62584. * @param impostor impostor to get stiffness from
  62585. * @returns pressure value
  62586. */
  62587. getBodyStiffness(impostor: PhysicsImpostor): number;
  62588. /**
  62589. * Sets stiffness of the impostor
  62590. * @param impostor impostor to set stiffness on
  62591. * @param stiffness stiffness value from 0 to 1
  62592. */
  62593. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62594. /**
  62595. * Gets velocityIterations of the impostor
  62596. * @param impostor impostor to get velocity iterations from
  62597. * @returns velocityIterations value
  62598. */
  62599. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62600. /**
  62601. * Sets velocityIterations of the impostor
  62602. * @param impostor impostor to set velocity iterations on
  62603. * @param velocityIterations velocityIterations value
  62604. */
  62605. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62606. /**
  62607. * Gets positionIterations of the impostor
  62608. * @param impostor impostor to get position iterations from
  62609. * @returns positionIterations value
  62610. */
  62611. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62612. /**
  62613. * Sets positionIterations of the impostor
  62614. * @param impostor impostor to set position on
  62615. * @param positionIterations positionIterations value
  62616. */
  62617. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62618. /**
  62619. * Append an anchor to a cloth object
  62620. * @param impostor is the cloth impostor to add anchor to
  62621. * @param otherImpostor is the rigid impostor to anchor to
  62622. * @param width ratio across width from 0 to 1
  62623. * @param height ratio up height from 0 to 1
  62624. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62625. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62626. */
  62627. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62628. /**
  62629. * Append an hook to a rope object
  62630. * @param impostor is the rope impostor to add hook to
  62631. * @param otherImpostor is the rigid impostor to hook to
  62632. * @param length ratio along the rope from 0 to 1
  62633. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62634. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62635. */
  62636. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62637. /**
  62638. * Sleeps the physics body and stops it from being active
  62639. * @param impostor impostor to sleep
  62640. */
  62641. sleepBody(impostor: PhysicsImpostor): void;
  62642. /**
  62643. * Activates the physics body
  62644. * @param impostor impostor to activate
  62645. */
  62646. wakeUpBody(impostor: PhysicsImpostor): void;
  62647. /**
  62648. * Updates the distance parameters of the joint
  62649. * @param joint joint to update
  62650. * @param maxDistance maximum distance of the joint
  62651. * @param minDistance minimum distance of the joint
  62652. */
  62653. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62654. /**
  62655. * Sets a motor on the joint
  62656. * @param joint joint to set motor on
  62657. * @param speed speed of the motor
  62658. * @param maxForce maximum force of the motor
  62659. * @param motorIndex index of the motor
  62660. */
  62661. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62662. /**
  62663. * Sets the motors limit
  62664. * @param joint joint to set limit on
  62665. * @param upperLimit upper limit
  62666. * @param lowerLimit lower limit
  62667. */
  62668. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62669. /**
  62670. * Syncs the position and rotation of a mesh with the impostor
  62671. * @param mesh mesh to sync
  62672. * @param impostor impostor to update the mesh with
  62673. */
  62674. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62675. /**
  62676. * Gets the radius of the impostor
  62677. * @param impostor impostor to get radius from
  62678. * @returns the radius
  62679. */
  62680. getRadius(impostor: PhysicsImpostor): number;
  62681. /**
  62682. * Gets the box size of the impostor
  62683. * @param impostor impostor to get box size from
  62684. * @param result the resulting box size
  62685. */
  62686. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62687. /**
  62688. * Disposes of the impostor
  62689. */
  62690. dispose(): void;
  62691. /**
  62692. * Does a raycast in the physics world
  62693. * @param from when should the ray start?
  62694. * @param to when should the ray end?
  62695. * @returns PhysicsRaycastResult
  62696. */
  62697. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62698. }
  62699. }
  62700. declare module BABYLON {
  62701. interface AbstractScene {
  62702. /**
  62703. * The list of reflection probes added to the scene
  62704. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62705. */
  62706. reflectionProbes: Array<ReflectionProbe>;
  62707. /**
  62708. * Removes the given reflection probe from this scene.
  62709. * @param toRemove The reflection probe to remove
  62710. * @returns The index of the removed reflection probe
  62711. */
  62712. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62713. /**
  62714. * Adds the given reflection probe to this scene.
  62715. * @param newReflectionProbe The reflection probe to add
  62716. */
  62717. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62718. }
  62719. /**
  62720. * Class used to generate realtime reflection / refraction cube textures
  62721. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62722. */
  62723. export class ReflectionProbe {
  62724. /** defines the name of the probe */
  62725. name: string;
  62726. private _scene;
  62727. private _renderTargetTexture;
  62728. private _projectionMatrix;
  62729. private _viewMatrix;
  62730. private _target;
  62731. private _add;
  62732. private _attachedMesh;
  62733. private _invertYAxis;
  62734. /** Gets or sets probe position (center of the cube map) */
  62735. position: Vector3;
  62736. /**
  62737. * Creates a new reflection probe
  62738. * @param name defines the name of the probe
  62739. * @param size defines the texture resolution (for each face)
  62740. * @param scene defines the hosting scene
  62741. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62742. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62743. */
  62744. constructor(
  62745. /** defines the name of the probe */
  62746. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62747. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62748. get samples(): number;
  62749. set samples(value: number);
  62750. /** Gets or sets the refresh rate to use (on every frame by default) */
  62751. get refreshRate(): number;
  62752. set refreshRate(value: number);
  62753. /**
  62754. * Gets the hosting scene
  62755. * @returns a Scene
  62756. */
  62757. getScene(): Scene;
  62758. /** Gets the internal CubeTexture used to render to */
  62759. get cubeTexture(): RenderTargetTexture;
  62760. /** Gets the list of meshes to render */
  62761. get renderList(): Nullable<AbstractMesh[]>;
  62762. /**
  62763. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62764. * @param mesh defines the mesh to attach to
  62765. */
  62766. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62767. /**
  62768. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62769. * @param renderingGroupId The rendering group id corresponding to its index
  62770. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62771. */
  62772. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62773. /**
  62774. * Clean all associated resources
  62775. */
  62776. dispose(): void;
  62777. /**
  62778. * Converts the reflection probe information to a readable string for debug purpose.
  62779. * @param fullDetails Supports for multiple levels of logging within scene loading
  62780. * @returns the human readable reflection probe info
  62781. */
  62782. toString(fullDetails?: boolean): string;
  62783. /**
  62784. * Get the class name of the relfection probe.
  62785. * @returns "ReflectionProbe"
  62786. */
  62787. getClassName(): string;
  62788. /**
  62789. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62790. * @returns The JSON representation of the texture
  62791. */
  62792. serialize(): any;
  62793. /**
  62794. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62795. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62796. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62797. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62798. * @returns The parsed reflection probe if successful
  62799. */
  62800. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62801. }
  62802. }
  62803. declare module BABYLON {
  62804. /** @hidden */
  62805. export var _BabylonLoaderRegistered: boolean;
  62806. /**
  62807. * Helps setting up some configuration for the babylon file loader.
  62808. */
  62809. export class BabylonFileLoaderConfiguration {
  62810. /**
  62811. * The loader does not allow injecting custom physix engine into the plugins.
  62812. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62813. * So you could set this variable to your engine import to make it work.
  62814. */
  62815. static LoaderInjectedPhysicsEngine: any;
  62816. }
  62817. }
  62818. declare module BABYLON {
  62819. /**
  62820. * The Physically based simple base material of BJS.
  62821. *
  62822. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62823. * It is used as the base class for both the specGloss and metalRough conventions.
  62824. */
  62825. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62826. /**
  62827. * Number of Simultaneous lights allowed on the material.
  62828. */
  62829. maxSimultaneousLights: number;
  62830. /**
  62831. * If sets to true, disables all the lights affecting the material.
  62832. */
  62833. disableLighting: boolean;
  62834. /**
  62835. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62836. */
  62837. environmentTexture: BaseTexture;
  62838. /**
  62839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62840. */
  62841. invertNormalMapX: boolean;
  62842. /**
  62843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62844. */
  62845. invertNormalMapY: boolean;
  62846. /**
  62847. * Normal map used in the model.
  62848. */
  62849. normalTexture: BaseTexture;
  62850. /**
  62851. * Emissivie color used to self-illuminate the model.
  62852. */
  62853. emissiveColor: Color3;
  62854. /**
  62855. * Emissivie texture used to self-illuminate the model.
  62856. */
  62857. emissiveTexture: BaseTexture;
  62858. /**
  62859. * Occlusion Channel Strenght.
  62860. */
  62861. occlusionStrength: number;
  62862. /**
  62863. * Occlusion Texture of the material (adding extra occlusion effects).
  62864. */
  62865. occlusionTexture: BaseTexture;
  62866. /**
  62867. * Defines the alpha limits in alpha test mode.
  62868. */
  62869. alphaCutOff: number;
  62870. /**
  62871. * Gets the current double sided mode.
  62872. */
  62873. get doubleSided(): boolean;
  62874. /**
  62875. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62876. */
  62877. set doubleSided(value: boolean);
  62878. /**
  62879. * Stores the pre-calculated light information of a mesh in a texture.
  62880. */
  62881. lightmapTexture: BaseTexture;
  62882. /**
  62883. * If true, the light map contains occlusion information instead of lighting info.
  62884. */
  62885. useLightmapAsShadowmap: boolean;
  62886. /**
  62887. * Instantiates a new PBRMaterial instance.
  62888. *
  62889. * @param name The material name
  62890. * @param scene The scene the material will be use in.
  62891. */
  62892. constructor(name: string, scene: Scene);
  62893. getClassName(): string;
  62894. }
  62895. }
  62896. declare module BABYLON {
  62897. /**
  62898. * The PBR material of BJS following the metal roughness convention.
  62899. *
  62900. * This fits to the PBR convention in the GLTF definition:
  62901. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62902. */
  62903. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62904. /**
  62905. * The base color has two different interpretations depending on the value of metalness.
  62906. * When the material is a metal, the base color is the specific measured reflectance value
  62907. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62908. * of the material.
  62909. */
  62910. baseColor: Color3;
  62911. /**
  62912. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62913. * well as opacity information in the alpha channel.
  62914. */
  62915. baseTexture: BaseTexture;
  62916. /**
  62917. * Specifies the metallic scalar value of the material.
  62918. * Can also be used to scale the metalness values of the metallic texture.
  62919. */
  62920. metallic: number;
  62921. /**
  62922. * Specifies the roughness scalar value of the material.
  62923. * Can also be used to scale the roughness values of the metallic texture.
  62924. */
  62925. roughness: number;
  62926. /**
  62927. * Texture containing both the metallic value in the B channel and the
  62928. * roughness value in the G channel to keep better precision.
  62929. */
  62930. metallicRoughnessTexture: BaseTexture;
  62931. /**
  62932. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62933. *
  62934. * @param name The material name
  62935. * @param scene The scene the material will be use in.
  62936. */
  62937. constructor(name: string, scene: Scene);
  62938. /**
  62939. * Return the currrent class name of the material.
  62940. */
  62941. getClassName(): string;
  62942. /**
  62943. * Makes a duplicate of the current material.
  62944. * @param name - name to use for the new material.
  62945. */
  62946. clone(name: string): PBRMetallicRoughnessMaterial;
  62947. /**
  62948. * Serialize the material to a parsable JSON object.
  62949. */
  62950. serialize(): any;
  62951. /**
  62952. * Parses a JSON object correponding to the serialize function.
  62953. */
  62954. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62955. }
  62956. }
  62957. declare module BABYLON {
  62958. /**
  62959. * The PBR material of BJS following the specular glossiness convention.
  62960. *
  62961. * This fits to the PBR convention in the GLTF definition:
  62962. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62963. */
  62964. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62965. /**
  62966. * Specifies the diffuse color of the material.
  62967. */
  62968. diffuseColor: Color3;
  62969. /**
  62970. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62971. * channel.
  62972. */
  62973. diffuseTexture: BaseTexture;
  62974. /**
  62975. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62976. */
  62977. specularColor: Color3;
  62978. /**
  62979. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62980. */
  62981. glossiness: number;
  62982. /**
  62983. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62984. */
  62985. specularGlossinessTexture: BaseTexture;
  62986. /**
  62987. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62988. *
  62989. * @param name The material name
  62990. * @param scene The scene the material will be use in.
  62991. */
  62992. constructor(name: string, scene: Scene);
  62993. /**
  62994. * Return the currrent class name of the material.
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * Makes a duplicate of the current material.
  62999. * @param name - name to use for the new material.
  63000. */
  63001. clone(name: string): PBRSpecularGlossinessMaterial;
  63002. /**
  63003. * Serialize the material to a parsable JSON object.
  63004. */
  63005. serialize(): any;
  63006. /**
  63007. * Parses a JSON object correponding to the serialize function.
  63008. */
  63009. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63010. }
  63011. }
  63012. declare module BABYLON {
  63013. /**
  63014. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63015. * It can help converting any input color in a desired output one. This can then be used to create effects
  63016. * from sepia, black and white to sixties or futuristic rendering...
  63017. *
  63018. * The only supported format is currently 3dl.
  63019. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63020. */
  63021. export class ColorGradingTexture extends BaseTexture {
  63022. /**
  63023. * The texture URL.
  63024. */
  63025. url: string;
  63026. /**
  63027. * Empty line regex stored for GC.
  63028. */
  63029. private static _noneEmptyLineRegex;
  63030. private _textureMatrix;
  63031. private _onLoad;
  63032. /**
  63033. * Instantiates a ColorGradingTexture from the following parameters.
  63034. *
  63035. * @param url The location of the color gradind data (currently only supporting 3dl)
  63036. * @param sceneOrEngine The scene or engine the texture will be used in
  63037. * @param onLoad defines a callback triggered when the texture has been loaded
  63038. */
  63039. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63040. /**
  63041. * Fires the onload event from the constructor if requested.
  63042. */
  63043. private _triggerOnLoad;
  63044. /**
  63045. * Returns the texture matrix used in most of the material.
  63046. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63047. */
  63048. getTextureMatrix(): Matrix;
  63049. /**
  63050. * Occurs when the file being loaded is a .3dl LUT file.
  63051. */
  63052. private load3dlTexture;
  63053. /**
  63054. * Starts the loading process of the texture.
  63055. */
  63056. private loadTexture;
  63057. /**
  63058. * Clones the color gradind texture.
  63059. */
  63060. clone(): ColorGradingTexture;
  63061. /**
  63062. * Called during delayed load for textures.
  63063. */
  63064. delayLoad(): void;
  63065. /**
  63066. * Parses a color grading texture serialized by Babylon.
  63067. * @param parsedTexture The texture information being parsedTexture
  63068. * @param scene The scene to load the texture in
  63069. * @param rootUrl The root url of the data assets to load
  63070. * @return A color gradind texture
  63071. */
  63072. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63073. /**
  63074. * Serializes the LUT texture to json format.
  63075. */
  63076. serialize(): any;
  63077. }
  63078. }
  63079. declare module BABYLON {
  63080. /**
  63081. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63082. */
  63083. export class EquiRectangularCubeTexture extends BaseTexture {
  63084. /** The six faces of the cube. */
  63085. private static _FacesMapping;
  63086. private _noMipmap;
  63087. private _onLoad;
  63088. private _onError;
  63089. /** The size of the cubemap. */
  63090. private _size;
  63091. /** The buffer of the image. */
  63092. private _buffer;
  63093. /** The width of the input image. */
  63094. private _width;
  63095. /** The height of the input image. */
  63096. private _height;
  63097. /** The URL to the image. */
  63098. url: string;
  63099. /**
  63100. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63101. * @param url The location of the image
  63102. * @param scene The scene the texture will be used in
  63103. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63104. * @param noMipmap Forces to not generate the mipmap if true
  63105. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63106. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63107. * @param onLoad — defines a callback called when texture is loaded
  63108. * @param onError — defines a callback called if there is an error
  63109. */
  63110. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63111. /**
  63112. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63113. */
  63114. private loadImage;
  63115. /**
  63116. * Convert the image buffer into a cubemap and create a CubeTexture.
  63117. */
  63118. private loadTexture;
  63119. /**
  63120. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63121. * @param buffer The ArrayBuffer that should be converted.
  63122. * @returns The buffer as Float32Array.
  63123. */
  63124. private getFloat32ArrayFromArrayBuffer;
  63125. /**
  63126. * Get the current class name of the texture useful for serialization or dynamic coding.
  63127. * @returns "EquiRectangularCubeTexture"
  63128. */
  63129. getClassName(): string;
  63130. /**
  63131. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63132. * @returns A clone of the current EquiRectangularCubeTexture.
  63133. */
  63134. clone(): EquiRectangularCubeTexture;
  63135. }
  63136. }
  63137. declare module BABYLON {
  63138. /**
  63139. * Defines the options related to the creation of an HtmlElementTexture
  63140. */
  63141. export interface IHtmlElementTextureOptions {
  63142. /**
  63143. * Defines wether mip maps should be created or not.
  63144. */
  63145. generateMipMaps?: boolean;
  63146. /**
  63147. * Defines the sampling mode of the texture.
  63148. */
  63149. samplingMode?: number;
  63150. /**
  63151. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63152. */
  63153. engine: Nullable<ThinEngine>;
  63154. /**
  63155. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63156. */
  63157. scene: Nullable<Scene>;
  63158. }
  63159. /**
  63160. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63161. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63162. * is automatically managed.
  63163. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63164. * in your application.
  63165. *
  63166. * As the update is not automatic, you need to call them manually.
  63167. */
  63168. export class HtmlElementTexture extends BaseTexture {
  63169. /**
  63170. * The texture URL.
  63171. */
  63172. element: HTMLVideoElement | HTMLCanvasElement;
  63173. private static readonly DefaultOptions;
  63174. private _textureMatrix;
  63175. private _isVideo;
  63176. private _generateMipMaps;
  63177. private _samplingMode;
  63178. /**
  63179. * Instantiates a HtmlElementTexture from the following parameters.
  63180. *
  63181. * @param name Defines the name of the texture
  63182. * @param element Defines the video or canvas the texture is filled with
  63183. * @param options Defines the other none mandatory texture creation options
  63184. */
  63185. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63186. private _createInternalTexture;
  63187. /**
  63188. * Returns the texture matrix used in most of the material.
  63189. */
  63190. getTextureMatrix(): Matrix;
  63191. /**
  63192. * Updates the content of the texture.
  63193. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63194. */
  63195. update(invertY?: Nullable<boolean>): void;
  63196. }
  63197. }
  63198. declare module BABYLON {
  63199. /**
  63200. * Based on jsTGALoader - Javascript loader for TGA file
  63201. * By Vincent Thibault
  63202. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63203. */
  63204. export class TGATools {
  63205. private static _TYPE_INDEXED;
  63206. private static _TYPE_RGB;
  63207. private static _TYPE_GREY;
  63208. private static _TYPE_RLE_INDEXED;
  63209. private static _TYPE_RLE_RGB;
  63210. private static _TYPE_RLE_GREY;
  63211. private static _ORIGIN_MASK;
  63212. private static _ORIGIN_SHIFT;
  63213. private static _ORIGIN_BL;
  63214. private static _ORIGIN_BR;
  63215. private static _ORIGIN_UL;
  63216. private static _ORIGIN_UR;
  63217. /**
  63218. * Gets the header of a TGA file
  63219. * @param data defines the TGA data
  63220. * @returns the header
  63221. */
  63222. static GetTGAHeader(data: Uint8Array): any;
  63223. /**
  63224. * Uploads TGA content to a Babylon Texture
  63225. * @hidden
  63226. */
  63227. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63228. /** @hidden */
  63229. 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;
  63230. /** @hidden */
  63231. 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;
  63232. /** @hidden */
  63233. 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;
  63234. /** @hidden */
  63235. 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;
  63236. /** @hidden */
  63237. 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;
  63238. /** @hidden */
  63239. 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;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. /**
  63244. * Implementation of the TGA Texture Loader.
  63245. * @hidden
  63246. */
  63247. export class _TGATextureLoader implements IInternalTextureLoader {
  63248. /**
  63249. * Defines wether the loader supports cascade loading the different faces.
  63250. */
  63251. readonly supportCascades: boolean;
  63252. /**
  63253. * This returns if the loader support the current file information.
  63254. * @param extension defines the file extension of the file being loaded
  63255. * @returns true if the loader can load the specified file
  63256. */
  63257. canLoad(extension: string): boolean;
  63258. /**
  63259. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63260. * @param data contains the texture data
  63261. * @param texture defines the BabylonJS internal texture
  63262. * @param createPolynomials will be true if polynomials have been requested
  63263. * @param onLoad defines the callback to trigger once the texture is ready
  63264. * @param onError defines the callback to trigger in case of error
  63265. */
  63266. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63267. /**
  63268. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63269. * @param data contains the texture data
  63270. * @param texture defines the BabylonJS internal texture
  63271. * @param callback defines the method to call once ready to upload
  63272. */
  63273. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63274. }
  63275. }
  63276. declare module BABYLON {
  63277. /**
  63278. * Info about the .basis files
  63279. */
  63280. class BasisFileInfo {
  63281. /**
  63282. * If the file has alpha
  63283. */
  63284. hasAlpha: boolean;
  63285. /**
  63286. * Info about each image of the basis file
  63287. */
  63288. images: Array<{
  63289. levels: Array<{
  63290. width: number;
  63291. height: number;
  63292. transcodedPixels: ArrayBufferView;
  63293. }>;
  63294. }>;
  63295. }
  63296. /**
  63297. * Result of transcoding a basis file
  63298. */
  63299. class TranscodeResult {
  63300. /**
  63301. * Info about the .basis file
  63302. */
  63303. fileInfo: BasisFileInfo;
  63304. /**
  63305. * Format to use when loading the file
  63306. */
  63307. format: number;
  63308. }
  63309. /**
  63310. * Configuration options for the Basis transcoder
  63311. */
  63312. export class BasisTranscodeConfiguration {
  63313. /**
  63314. * Supported compression formats used to determine the supported output format of the transcoder
  63315. */
  63316. supportedCompressionFormats?: {
  63317. /**
  63318. * etc1 compression format
  63319. */
  63320. etc1?: boolean;
  63321. /**
  63322. * s3tc compression format
  63323. */
  63324. s3tc?: boolean;
  63325. /**
  63326. * pvrtc compression format
  63327. */
  63328. pvrtc?: boolean;
  63329. /**
  63330. * etc2 compression format
  63331. */
  63332. etc2?: boolean;
  63333. };
  63334. /**
  63335. * If mipmap levels should be loaded for transcoded images (Default: true)
  63336. */
  63337. loadMipmapLevels?: boolean;
  63338. /**
  63339. * Index of a single image to load (Default: all images)
  63340. */
  63341. loadSingleImage?: number;
  63342. }
  63343. /**
  63344. * Used to load .Basis files
  63345. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63346. */
  63347. export class BasisTools {
  63348. private static _IgnoreSupportedFormats;
  63349. /**
  63350. * URL to use when loading the basis transcoder
  63351. */
  63352. static JSModuleURL: string;
  63353. /**
  63354. * URL to use when loading the wasm module for the transcoder
  63355. */
  63356. static WasmModuleURL: string;
  63357. /**
  63358. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63359. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63360. * @returns internal format corresponding to the Basis format
  63361. */
  63362. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63363. private static _WorkerPromise;
  63364. private static _Worker;
  63365. private static _actionId;
  63366. private static _CreateWorkerAsync;
  63367. /**
  63368. * Transcodes a loaded image file to compressed pixel data
  63369. * @param data image data to transcode
  63370. * @param config configuration options for the transcoding
  63371. * @returns a promise resulting in the transcoded image
  63372. */
  63373. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63374. /**
  63375. * Loads a texture from the transcode result
  63376. * @param texture texture load to
  63377. * @param transcodeResult the result of transcoding the basis file to load from
  63378. */
  63379. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63380. }
  63381. }
  63382. declare module BABYLON {
  63383. /**
  63384. * Loader for .basis file format
  63385. */
  63386. export class _BasisTextureLoader implements IInternalTextureLoader {
  63387. /**
  63388. * Defines whether the loader supports cascade loading the different faces.
  63389. */
  63390. readonly supportCascades: boolean;
  63391. /**
  63392. * This returns if the loader support the current file information.
  63393. * @param extension defines the file extension of the file being loaded
  63394. * @returns true if the loader can load the specified file
  63395. */
  63396. canLoad(extension: string): boolean;
  63397. /**
  63398. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63399. * @param data contains the texture data
  63400. * @param texture defines the BabylonJS internal texture
  63401. * @param createPolynomials will be true if polynomials have been requested
  63402. * @param onLoad defines the callback to trigger once the texture is ready
  63403. * @param onError defines the callback to trigger in case of error
  63404. */
  63405. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63406. /**
  63407. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63408. * @param data contains the texture data
  63409. * @param texture defines the BabylonJS internal texture
  63410. * @param callback defines the method to call once ready to upload
  63411. */
  63412. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63413. }
  63414. }
  63415. declare module BABYLON {
  63416. /**
  63417. * Defines the basic options interface of a TexturePacker Frame
  63418. */
  63419. export interface ITexturePackerFrame {
  63420. /**
  63421. * The frame ID
  63422. */
  63423. id: number;
  63424. /**
  63425. * The frames Scale
  63426. */
  63427. scale: Vector2;
  63428. /**
  63429. * The Frames offset
  63430. */
  63431. offset: Vector2;
  63432. }
  63433. /**
  63434. * This is a support class for frame Data on texture packer sets.
  63435. */
  63436. export class TexturePackerFrame implements ITexturePackerFrame {
  63437. /**
  63438. * The frame ID
  63439. */
  63440. id: number;
  63441. /**
  63442. * The frames Scale
  63443. */
  63444. scale: Vector2;
  63445. /**
  63446. * The Frames offset
  63447. */
  63448. offset: Vector2;
  63449. /**
  63450. * Initializes a texture package frame.
  63451. * @param id The numerical frame identifier
  63452. * @param scale Scalar Vector2 for UV frame
  63453. * @param offset Vector2 for the frame position in UV units.
  63454. * @returns TexturePackerFrame
  63455. */
  63456. constructor(id: number, scale: Vector2, offset: Vector2);
  63457. }
  63458. }
  63459. declare module BABYLON {
  63460. /**
  63461. * Defines the basic options interface of a TexturePacker
  63462. */
  63463. export interface ITexturePackerOptions {
  63464. /**
  63465. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63466. */
  63467. map?: string[];
  63468. /**
  63469. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63470. */
  63471. uvsIn?: string;
  63472. /**
  63473. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63474. */
  63475. uvsOut?: string;
  63476. /**
  63477. * number representing the layout style. Defaults to LAYOUT_STRIP
  63478. */
  63479. layout?: number;
  63480. /**
  63481. * number of columns if using custom column count layout(2). This defaults to 4.
  63482. */
  63483. colnum?: number;
  63484. /**
  63485. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63486. */
  63487. updateInputMeshes?: boolean;
  63488. /**
  63489. * boolean flag to dispose all the source textures. Defaults to true.
  63490. */
  63491. disposeSources?: boolean;
  63492. /**
  63493. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63494. */
  63495. fillBlanks?: boolean;
  63496. /**
  63497. * string value representing the context fill style color. Defaults to 'black'.
  63498. */
  63499. customFillColor?: string;
  63500. /**
  63501. * Width and Height Value of each Frame in the TexturePacker Sets
  63502. */
  63503. frameSize?: number;
  63504. /**
  63505. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63506. */
  63507. paddingRatio?: number;
  63508. /**
  63509. * Number that declares the fill method for the padding gutter.
  63510. */
  63511. paddingMode?: number;
  63512. /**
  63513. * If in SUBUV_COLOR padding mode what color to use.
  63514. */
  63515. paddingColor?: Color3 | Color4;
  63516. }
  63517. /**
  63518. * Defines the basic interface of a TexturePacker JSON File
  63519. */
  63520. export interface ITexturePackerJSON {
  63521. /**
  63522. * The frame ID
  63523. */
  63524. name: string;
  63525. /**
  63526. * The base64 channel data
  63527. */
  63528. sets: any;
  63529. /**
  63530. * The options of the Packer
  63531. */
  63532. options: ITexturePackerOptions;
  63533. /**
  63534. * The frame data of the Packer
  63535. */
  63536. frames: Array<number>;
  63537. }
  63538. /**
  63539. * This is a support class that generates a series of packed texture sets.
  63540. * @see https://doc.babylonjs.com/babylon101/materials
  63541. */
  63542. export class TexturePacker {
  63543. /** Packer Layout Constant 0 */
  63544. static readonly LAYOUT_STRIP: number;
  63545. /** Packer Layout Constant 1 */
  63546. static readonly LAYOUT_POWER2: number;
  63547. /** Packer Layout Constant 2 */
  63548. static readonly LAYOUT_COLNUM: number;
  63549. /** Packer Layout Constant 0 */
  63550. static readonly SUBUV_WRAP: number;
  63551. /** Packer Layout Constant 1 */
  63552. static readonly SUBUV_EXTEND: number;
  63553. /** Packer Layout Constant 2 */
  63554. static readonly SUBUV_COLOR: number;
  63555. /** The Name of the Texture Package */
  63556. name: string;
  63557. /** The scene scope of the TexturePacker */
  63558. scene: Scene;
  63559. /** The Meshes to target */
  63560. meshes: AbstractMesh[];
  63561. /** Arguments passed with the Constructor */
  63562. options: ITexturePackerOptions;
  63563. /** The promise that is started upon initialization */
  63564. promise: Nullable<Promise<TexturePacker | string>>;
  63565. /** The Container object for the channel sets that are generated */
  63566. sets: object;
  63567. /** The Container array for the frames that are generated */
  63568. frames: TexturePackerFrame[];
  63569. /** The expected number of textures the system is parsing. */
  63570. private _expecting;
  63571. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63572. private _paddingValue;
  63573. /**
  63574. * Initializes a texture package series from an array of meshes or a single mesh.
  63575. * @param name The name of the package
  63576. * @param meshes The target meshes to compose the package from
  63577. * @param options The arguments that texture packer should follow while building.
  63578. * @param scene The scene which the textures are scoped to.
  63579. * @returns TexturePacker
  63580. */
  63581. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63582. /**
  63583. * Starts the package process
  63584. * @param resolve The promises resolution function
  63585. * @returns TexturePacker
  63586. */
  63587. private _createFrames;
  63588. /**
  63589. * Calculates the Size of the Channel Sets
  63590. * @returns Vector2
  63591. */
  63592. private _calculateSize;
  63593. /**
  63594. * Calculates the UV data for the frames.
  63595. * @param baseSize the base frameSize
  63596. * @param padding the base frame padding
  63597. * @param dtSize size of the Dynamic Texture for that channel
  63598. * @param dtUnits is 1/dtSize
  63599. * @param update flag to update the input meshes
  63600. */
  63601. private _calculateMeshUVFrames;
  63602. /**
  63603. * Calculates the frames Offset.
  63604. * @param index of the frame
  63605. * @returns Vector2
  63606. */
  63607. private _getFrameOffset;
  63608. /**
  63609. * Updates a Mesh to the frame data
  63610. * @param mesh that is the target
  63611. * @param frameID or the frame index
  63612. */
  63613. private _updateMeshUV;
  63614. /**
  63615. * Updates a Meshes materials to use the texture packer channels
  63616. * @param m is the mesh to target
  63617. * @param force all channels on the packer to be set.
  63618. */
  63619. private _updateTextureReferences;
  63620. /**
  63621. * Public method to set a Mesh to a frame
  63622. * @param m that is the target
  63623. * @param frameID or the frame index
  63624. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63625. */
  63626. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63627. /**
  63628. * Starts the async promise to compile the texture packer.
  63629. * @returns Promise<void>
  63630. */
  63631. processAsync(): Promise<void>;
  63632. /**
  63633. * Disposes all textures associated with this packer
  63634. */
  63635. dispose(): void;
  63636. /**
  63637. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63638. * @param imageType is the image type to use.
  63639. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63640. */
  63641. download(imageType?: string, quality?: number): void;
  63642. /**
  63643. * Public method to load a texturePacker JSON file.
  63644. * @param data of the JSON file in string format.
  63645. */
  63646. updateFromJSON(data: string): void;
  63647. }
  63648. }
  63649. declare module BABYLON {
  63650. /**
  63651. * 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.
  63652. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63653. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63654. */
  63655. export class CustomProceduralTexture extends ProceduralTexture {
  63656. private _animate;
  63657. private _time;
  63658. private _config;
  63659. private _texturePath;
  63660. /**
  63661. * Instantiates a new Custom Procedural Texture.
  63662. * 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.
  63663. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63664. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63665. * @param name Define the name of the texture
  63666. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63667. * @param size Define the size of the texture to create
  63668. * @param scene Define the scene the texture belongs to
  63669. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63670. * @param generateMipMaps Define if the texture should creates mip maps or not
  63671. */
  63672. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63673. private _loadJson;
  63674. /**
  63675. * Is the texture ready to be used ? (rendered at least once)
  63676. * @returns true if ready, otherwise, false.
  63677. */
  63678. isReady(): boolean;
  63679. /**
  63680. * Render the texture to its associated render target.
  63681. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63682. */
  63683. render(useCameraPostProcess?: boolean): void;
  63684. /**
  63685. * Update the list of dependant textures samplers in the shader.
  63686. */
  63687. updateTextures(): void;
  63688. /**
  63689. * Update the uniform values of the procedural texture in the shader.
  63690. */
  63691. updateShaderUniforms(): void;
  63692. /**
  63693. * Define if the texture animates or not.
  63694. */
  63695. get animate(): boolean;
  63696. set animate(value: boolean);
  63697. }
  63698. }
  63699. declare module BABYLON {
  63700. /** @hidden */
  63701. export var noisePixelShader: {
  63702. name: string;
  63703. shader: string;
  63704. };
  63705. }
  63706. declare module BABYLON {
  63707. /**
  63708. * Class used to generate noise procedural textures
  63709. */
  63710. export class NoiseProceduralTexture extends ProceduralTexture {
  63711. /** Gets or sets the start time (default is 0) */
  63712. time: number;
  63713. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63714. brightness: number;
  63715. /** Defines the number of octaves to process */
  63716. octaves: number;
  63717. /** Defines the level of persistence (0.8 by default) */
  63718. persistence: number;
  63719. /** Gets or sets animation speed factor (default is 1) */
  63720. animationSpeedFactor: number;
  63721. /**
  63722. * Creates a new NoiseProceduralTexture
  63723. * @param name defines the name fo the texture
  63724. * @param size defines the size of the texture (default is 256)
  63725. * @param scene defines the hosting scene
  63726. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63727. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63728. */
  63729. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63730. private _updateShaderUniforms;
  63731. protected _getDefines(): string;
  63732. /** Generate the current state of the procedural texture */
  63733. render(useCameraPostProcess?: boolean): void;
  63734. /**
  63735. * Serializes this noise procedural texture
  63736. * @returns a serialized noise procedural texture object
  63737. */
  63738. serialize(): any;
  63739. /**
  63740. * Clone the texture.
  63741. * @returns the cloned texture
  63742. */
  63743. clone(): NoiseProceduralTexture;
  63744. /**
  63745. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63746. * @param parsedTexture defines parsed texture data
  63747. * @param scene defines the current scene
  63748. * @param rootUrl defines the root URL containing noise procedural texture information
  63749. * @returns a parsed NoiseProceduralTexture
  63750. */
  63751. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63752. }
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Raw cube texture where the raw buffers are passed in
  63757. */
  63758. export class RawCubeTexture extends CubeTexture {
  63759. /**
  63760. * Creates a cube texture where the raw buffers are passed in.
  63761. * @param scene defines the scene the texture is attached to
  63762. * @param data defines the array of data to use to create each face
  63763. * @param size defines the size of the textures
  63764. * @param format defines the format of the data
  63765. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63766. * @param generateMipMaps defines if the engine should generate the mip levels
  63767. * @param invertY defines if data must be stored with Y axis inverted
  63768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63769. * @param compression defines the compression used (null by default)
  63770. */
  63771. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63772. /**
  63773. * Updates the raw cube texture.
  63774. * @param data defines the data to store
  63775. * @param format defines the data format
  63776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63777. * @param invertY defines if data must be stored with Y axis inverted
  63778. * @param compression defines the compression used (null by default)
  63779. * @param level defines which level of the texture to update
  63780. */
  63781. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63782. /**
  63783. * Updates a raw cube texture with RGBD encoded data.
  63784. * @param data defines the array of data [mipmap][face] to use to create each face
  63785. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63788. * @returns a promsie that resolves when the operation is complete
  63789. */
  63790. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63791. /**
  63792. * Clones the raw cube texture.
  63793. * @return a new cube texture
  63794. */
  63795. clone(): CubeTexture;
  63796. /** @hidden */
  63797. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63798. }
  63799. }
  63800. declare module BABYLON {
  63801. /**
  63802. * Class used to store 2D array textures containing user data
  63803. */
  63804. export class RawTexture2DArray extends Texture {
  63805. /** Gets or sets the texture format to use */
  63806. format: number;
  63807. /**
  63808. * Create a new RawTexture2DArray
  63809. * @param data defines the data of the texture
  63810. * @param width defines the width of the texture
  63811. * @param height defines the height of the texture
  63812. * @param depth defines the number of layers of the texture
  63813. * @param format defines the texture format to use
  63814. * @param scene defines the hosting scene
  63815. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63816. * @param invertY defines if texture must be stored with Y axis inverted
  63817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63818. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63819. */
  63820. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63821. /** Gets or sets the texture format to use */
  63822. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63823. /**
  63824. * Update the texture with new data
  63825. * @param data defines the data to store in the texture
  63826. */
  63827. update(data: ArrayBufferView): void;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /**
  63832. * Class used to store 3D textures containing user data
  63833. */
  63834. export class RawTexture3D extends Texture {
  63835. /** Gets or sets the texture format to use */
  63836. format: number;
  63837. /**
  63838. * Create a new RawTexture3D
  63839. * @param data defines the data of the texture
  63840. * @param width defines the width of the texture
  63841. * @param height defines the height of the texture
  63842. * @param depth defines the depth of the texture
  63843. * @param format defines the texture format to use
  63844. * @param scene defines the hosting scene
  63845. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63846. * @param invertY defines if texture must be stored with Y axis inverted
  63847. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63848. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63849. */
  63850. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63851. /** Gets or sets the texture format to use */
  63852. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63853. /**
  63854. * Update the texture with new data
  63855. * @param data defines the data to store in the texture
  63856. */
  63857. update(data: ArrayBufferView): void;
  63858. }
  63859. }
  63860. declare module BABYLON {
  63861. /**
  63862. * Creates a refraction texture used by refraction channel of the standard material.
  63863. * It is like a mirror but to see through a material.
  63864. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63865. */
  63866. export class RefractionTexture extends RenderTargetTexture {
  63867. /**
  63868. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63869. * 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.
  63870. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63871. */
  63872. refractionPlane: Plane;
  63873. /**
  63874. * Define how deep under the surface we should see.
  63875. */
  63876. depth: number;
  63877. /**
  63878. * Creates a refraction texture used by refraction channel of the standard material.
  63879. * It is like a mirror but to see through a material.
  63880. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63881. * @param name Define the texture name
  63882. * @param size Define the size of the underlying texture
  63883. * @param scene Define the scene the refraction belongs to
  63884. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63885. */
  63886. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63887. /**
  63888. * Clone the refraction texture.
  63889. * @returns the cloned texture
  63890. */
  63891. clone(): RefractionTexture;
  63892. /**
  63893. * Serialize the texture to a JSON representation you could use in Parse later on
  63894. * @returns the serialized JSON representation
  63895. */
  63896. serialize(): any;
  63897. }
  63898. }
  63899. declare module BABYLON {
  63900. /**
  63901. * Block used to add support for vertex skinning (bones)
  63902. */
  63903. export class BonesBlock extends NodeMaterialBlock {
  63904. /**
  63905. * Creates a new BonesBlock
  63906. * @param name defines the block name
  63907. */
  63908. constructor(name: string);
  63909. /**
  63910. * Initialize the block and prepare the context for build
  63911. * @param state defines the state that will be used for the build
  63912. */
  63913. initialize(state: NodeMaterialBuildState): void;
  63914. /**
  63915. * Gets the current class name
  63916. * @returns the class name
  63917. */
  63918. getClassName(): string;
  63919. /**
  63920. * Gets the matrix indices input component
  63921. */
  63922. get matricesIndices(): NodeMaterialConnectionPoint;
  63923. /**
  63924. * Gets the matrix weights input component
  63925. */
  63926. get matricesWeights(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the extra matrix indices input component
  63929. */
  63930. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the extra matrix weights input component
  63933. */
  63934. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63935. /**
  63936. * Gets the world input component
  63937. */
  63938. get world(): NodeMaterialConnectionPoint;
  63939. /**
  63940. * Gets the output component
  63941. */
  63942. get output(): NodeMaterialConnectionPoint;
  63943. autoConfigure(material: NodeMaterial): void;
  63944. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63947. protected _buildBlock(state: NodeMaterialBuildState): this;
  63948. }
  63949. }
  63950. declare module BABYLON {
  63951. /**
  63952. * Block used to add support for instances
  63953. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63954. */
  63955. export class InstancesBlock extends NodeMaterialBlock {
  63956. /**
  63957. * Creates a new InstancesBlock
  63958. * @param name defines the block name
  63959. */
  63960. constructor(name: string);
  63961. /**
  63962. * Gets the current class name
  63963. * @returns the class name
  63964. */
  63965. getClassName(): string;
  63966. /**
  63967. * Gets the first world row input component
  63968. */
  63969. get world0(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the second world row input component
  63972. */
  63973. get world1(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the third world row input component
  63976. */
  63977. get world2(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the forth world row input component
  63980. */
  63981. get world3(): NodeMaterialConnectionPoint;
  63982. /**
  63983. * Gets the world input component
  63984. */
  63985. get world(): NodeMaterialConnectionPoint;
  63986. /**
  63987. * Gets the output component
  63988. */
  63989. get output(): NodeMaterialConnectionPoint;
  63990. /**
  63991. * Gets the isntanceID component
  63992. */
  63993. get instanceID(): NodeMaterialConnectionPoint;
  63994. autoConfigure(material: NodeMaterial): void;
  63995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63996. protected _buildBlock(state: NodeMaterialBuildState): this;
  63997. }
  63998. }
  63999. declare module BABYLON {
  64000. /**
  64001. * Block used to add morph targets support to vertex shader
  64002. */
  64003. export class MorphTargetsBlock extends NodeMaterialBlock {
  64004. private _repeatableContentAnchor;
  64005. /**
  64006. * Create a new MorphTargetsBlock
  64007. * @param name defines the block name
  64008. */
  64009. constructor(name: string);
  64010. /**
  64011. * Gets the current class name
  64012. * @returns the class name
  64013. */
  64014. getClassName(): string;
  64015. /**
  64016. * Gets the position input component
  64017. */
  64018. get position(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the normal input component
  64021. */
  64022. get normal(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the tangent input component
  64025. */
  64026. get tangent(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the tangent input component
  64029. */
  64030. get uv(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the position output component
  64033. */
  64034. get positionOutput(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the normal output component
  64037. */
  64038. get normalOutput(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the tangent output component
  64041. */
  64042. get tangentOutput(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the tangent output component
  64045. */
  64046. get uvOutput(): NodeMaterialConnectionPoint;
  64047. initialize(state: NodeMaterialBuildState): void;
  64048. autoConfigure(material: NodeMaterial): void;
  64049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64050. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64051. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64052. protected _buildBlock(state: NodeMaterialBuildState): this;
  64053. }
  64054. }
  64055. declare module BABYLON {
  64056. /**
  64057. * Block used to get data information from a light
  64058. */
  64059. export class LightInformationBlock extends NodeMaterialBlock {
  64060. private _lightDataUniformName;
  64061. private _lightColorUniformName;
  64062. private _lightTypeDefineName;
  64063. /**
  64064. * Gets or sets the light associated with this block
  64065. */
  64066. light: Nullable<Light>;
  64067. /**
  64068. * Creates a new LightInformationBlock
  64069. * @param name defines the block name
  64070. */
  64071. constructor(name: string);
  64072. /**
  64073. * Gets the current class name
  64074. * @returns the class name
  64075. */
  64076. getClassName(): string;
  64077. /**
  64078. * Gets the world position input component
  64079. */
  64080. get worldPosition(): NodeMaterialConnectionPoint;
  64081. /**
  64082. * Gets the direction output component
  64083. */
  64084. get direction(): NodeMaterialConnectionPoint;
  64085. /**
  64086. * Gets the direction output component
  64087. */
  64088. get color(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the direction output component
  64091. */
  64092. get intensity(): NodeMaterialConnectionPoint;
  64093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64095. protected _buildBlock(state: NodeMaterialBuildState): this;
  64096. serialize(): any;
  64097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64098. }
  64099. }
  64100. declare module BABYLON {
  64101. /**
  64102. * Block used to add image processing support to fragment shader
  64103. */
  64104. export class ImageProcessingBlock extends NodeMaterialBlock {
  64105. /**
  64106. * Create a new ImageProcessingBlock
  64107. * @param name defines the block name
  64108. */
  64109. constructor(name: string);
  64110. /**
  64111. * Gets the current class name
  64112. * @returns the class name
  64113. */
  64114. getClassName(): string;
  64115. /**
  64116. * Gets the color input component
  64117. */
  64118. get color(): NodeMaterialConnectionPoint;
  64119. /**
  64120. * Gets the output component
  64121. */
  64122. get output(): NodeMaterialConnectionPoint;
  64123. /**
  64124. * Initialize the block and prepare the context for build
  64125. * @param state defines the state that will be used for the build
  64126. */
  64127. initialize(state: NodeMaterialBuildState): void;
  64128. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64130. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64131. protected _buildBlock(state: NodeMaterialBuildState): this;
  64132. }
  64133. }
  64134. declare module BABYLON {
  64135. /**
  64136. * Block used to pertub normals based on a normal map
  64137. */
  64138. export class PerturbNormalBlock extends NodeMaterialBlock {
  64139. private _tangentSpaceParameterName;
  64140. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64141. invertX: boolean;
  64142. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64143. invertY: boolean;
  64144. /**
  64145. * Create a new PerturbNormalBlock
  64146. * @param name defines the block name
  64147. */
  64148. constructor(name: string);
  64149. /**
  64150. * Gets the current class name
  64151. * @returns the class name
  64152. */
  64153. getClassName(): string;
  64154. /**
  64155. * Gets the world position input component
  64156. */
  64157. get worldPosition(): NodeMaterialConnectionPoint;
  64158. /**
  64159. * Gets the world normal input component
  64160. */
  64161. get worldNormal(): NodeMaterialConnectionPoint;
  64162. /**
  64163. * Gets the world tangent input component
  64164. */
  64165. get worldTangent(): NodeMaterialConnectionPoint;
  64166. /**
  64167. * Gets the uv input component
  64168. */
  64169. get uv(): NodeMaterialConnectionPoint;
  64170. /**
  64171. * Gets the normal map color input component
  64172. */
  64173. get normalMapColor(): NodeMaterialConnectionPoint;
  64174. /**
  64175. * Gets the strength input component
  64176. */
  64177. get strength(): NodeMaterialConnectionPoint;
  64178. /**
  64179. * Gets the output component
  64180. */
  64181. get output(): NodeMaterialConnectionPoint;
  64182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64184. autoConfigure(material: NodeMaterial): void;
  64185. protected _buildBlock(state: NodeMaterialBuildState): this;
  64186. protected _dumpPropertiesCode(): string;
  64187. serialize(): any;
  64188. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64189. }
  64190. }
  64191. declare module BABYLON {
  64192. /**
  64193. * Block used to discard a pixel if a value is smaller than a cutoff
  64194. */
  64195. export class DiscardBlock extends NodeMaterialBlock {
  64196. /**
  64197. * Create a new DiscardBlock
  64198. * @param name defines the block name
  64199. */
  64200. constructor(name: string);
  64201. /**
  64202. * Gets the current class name
  64203. * @returns the class name
  64204. */
  64205. getClassName(): string;
  64206. /**
  64207. * Gets the color input component
  64208. */
  64209. get value(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the cutoff input component
  64212. */
  64213. get cutoff(): NodeMaterialConnectionPoint;
  64214. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64215. }
  64216. }
  64217. declare module BABYLON {
  64218. /**
  64219. * Block used to test if the fragment shader is front facing
  64220. */
  64221. export class FrontFacingBlock extends NodeMaterialBlock {
  64222. /**
  64223. * Creates a new FrontFacingBlock
  64224. * @param name defines the block name
  64225. */
  64226. constructor(name: string);
  64227. /**
  64228. * Gets the current class name
  64229. * @returns the class name
  64230. */
  64231. getClassName(): string;
  64232. /**
  64233. * Gets the output component
  64234. */
  64235. get output(): NodeMaterialConnectionPoint;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. }
  64238. }
  64239. declare module BABYLON {
  64240. /**
  64241. * Block used to get the derivative value on x and y of a given input
  64242. */
  64243. export class DerivativeBlock extends NodeMaterialBlock {
  64244. /**
  64245. * Create a new DerivativeBlock
  64246. * @param name defines the block name
  64247. */
  64248. constructor(name: string);
  64249. /**
  64250. * Gets the current class name
  64251. * @returns the class name
  64252. */
  64253. getClassName(): string;
  64254. /**
  64255. * Gets the input component
  64256. */
  64257. get input(): NodeMaterialConnectionPoint;
  64258. /**
  64259. * Gets the derivative output on x
  64260. */
  64261. get dx(): NodeMaterialConnectionPoint;
  64262. /**
  64263. * Gets the derivative output on y
  64264. */
  64265. get dy(): NodeMaterialConnectionPoint;
  64266. protected _buildBlock(state: NodeMaterialBuildState): this;
  64267. }
  64268. }
  64269. declare module BABYLON {
  64270. /**
  64271. * Block used to make gl_FragCoord available
  64272. */
  64273. export class FragCoordBlock extends NodeMaterialBlock {
  64274. /**
  64275. * Creates a new FragCoordBlock
  64276. * @param name defines the block name
  64277. */
  64278. constructor(name: string);
  64279. /**
  64280. * Gets the current class name
  64281. * @returns the class name
  64282. */
  64283. getClassName(): string;
  64284. /**
  64285. * Gets the xy component
  64286. */
  64287. get xy(): NodeMaterialConnectionPoint;
  64288. /**
  64289. * Gets the xyz component
  64290. */
  64291. get xyz(): NodeMaterialConnectionPoint;
  64292. /**
  64293. * Gets the xyzw component
  64294. */
  64295. get xyzw(): NodeMaterialConnectionPoint;
  64296. /**
  64297. * Gets the x component
  64298. */
  64299. get x(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the y component
  64302. */
  64303. get y(): NodeMaterialConnectionPoint;
  64304. /**
  64305. * Gets the z component
  64306. */
  64307. get z(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the w component
  64310. */
  64311. get output(): NodeMaterialConnectionPoint;
  64312. protected writeOutputs(state: NodeMaterialBuildState): string;
  64313. protected _buildBlock(state: NodeMaterialBuildState): this;
  64314. }
  64315. }
  64316. declare module BABYLON {
  64317. /**
  64318. * Block used to get the screen sizes
  64319. */
  64320. export class ScreenSizeBlock extends NodeMaterialBlock {
  64321. private _varName;
  64322. private _scene;
  64323. /**
  64324. * Creates a new ScreenSizeBlock
  64325. * @param name defines the block name
  64326. */
  64327. constructor(name: string);
  64328. /**
  64329. * Gets the current class name
  64330. * @returns the class name
  64331. */
  64332. getClassName(): string;
  64333. /**
  64334. * Gets the xy component
  64335. */
  64336. get xy(): NodeMaterialConnectionPoint;
  64337. /**
  64338. * Gets the x component
  64339. */
  64340. get x(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the y component
  64343. */
  64344. get y(): NodeMaterialConnectionPoint;
  64345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64346. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64347. protected _buildBlock(state: NodeMaterialBuildState): this;
  64348. }
  64349. }
  64350. declare module BABYLON {
  64351. /**
  64352. * Block used to add support for scene fog
  64353. */
  64354. export class FogBlock extends NodeMaterialBlock {
  64355. private _fogDistanceName;
  64356. private _fogParameters;
  64357. /**
  64358. * Create a new FogBlock
  64359. * @param name defines the block name
  64360. */
  64361. constructor(name: string);
  64362. /**
  64363. * Gets the current class name
  64364. * @returns the class name
  64365. */
  64366. getClassName(): string;
  64367. /**
  64368. * Gets the world position input component
  64369. */
  64370. get worldPosition(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the view input component
  64373. */
  64374. get view(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the color input component
  64377. */
  64378. get input(): NodeMaterialConnectionPoint;
  64379. /**
  64380. * Gets the fog color input component
  64381. */
  64382. get fogColor(): NodeMaterialConnectionPoint;
  64383. /**
  64384. * Gets the output component
  64385. */
  64386. get output(): NodeMaterialConnectionPoint;
  64387. autoConfigure(material: NodeMaterial): void;
  64388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64390. protected _buildBlock(state: NodeMaterialBuildState): this;
  64391. }
  64392. }
  64393. declare module BABYLON {
  64394. /**
  64395. * Block used to add light in the fragment shader
  64396. */
  64397. export class LightBlock extends NodeMaterialBlock {
  64398. private _lightId;
  64399. /**
  64400. * Gets or sets the light associated with this block
  64401. */
  64402. light: Nullable<Light>;
  64403. /**
  64404. * Create a new LightBlock
  64405. * @param name defines the block name
  64406. */
  64407. constructor(name: string);
  64408. /**
  64409. * Gets the current class name
  64410. * @returns the class name
  64411. */
  64412. getClassName(): string;
  64413. /**
  64414. * Gets the world position input component
  64415. */
  64416. get worldPosition(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the world normal input component
  64419. */
  64420. get worldNormal(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the camera (or eye) position component
  64423. */
  64424. get cameraPosition(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the glossiness component
  64427. */
  64428. get glossiness(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the glossinness power component
  64431. */
  64432. get glossPower(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the diffuse color component
  64435. */
  64436. get diffuseColor(): NodeMaterialConnectionPoint;
  64437. /**
  64438. * Gets the specular color component
  64439. */
  64440. get specularColor(): NodeMaterialConnectionPoint;
  64441. /**
  64442. * Gets the view matrix component
  64443. */
  64444. get view(): NodeMaterialConnectionPoint;
  64445. /**
  64446. * Gets the diffuse output component
  64447. */
  64448. get diffuseOutput(): NodeMaterialConnectionPoint;
  64449. /**
  64450. * Gets the specular output component
  64451. */
  64452. get specularOutput(): NodeMaterialConnectionPoint;
  64453. /**
  64454. * Gets the shadow output component
  64455. */
  64456. get shadow(): NodeMaterialConnectionPoint;
  64457. autoConfigure(material: NodeMaterial): void;
  64458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64459. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64461. private _injectVertexCode;
  64462. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64463. serialize(): any;
  64464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64465. }
  64466. }
  64467. declare module BABYLON {
  64468. /**
  64469. * Block used to read a reflection texture from a sampler
  64470. */
  64471. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64472. /**
  64473. * Create a new ReflectionTextureBlock
  64474. * @param name defines the block name
  64475. */
  64476. constructor(name: string);
  64477. /**
  64478. * Gets the current class name
  64479. * @returns the class name
  64480. */
  64481. getClassName(): string;
  64482. /**
  64483. * Gets the world position input component
  64484. */
  64485. get position(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the world position input component
  64488. */
  64489. get worldPosition(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the world normal input component
  64492. */
  64493. get worldNormal(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the world input component
  64496. */
  64497. get world(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the camera (or eye) position component
  64500. */
  64501. get cameraPosition(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the view input component
  64504. */
  64505. get view(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the rgb output component
  64508. */
  64509. get rgb(): NodeMaterialConnectionPoint;
  64510. /**
  64511. * Gets the rgba output component
  64512. */
  64513. get rgba(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the r output component
  64516. */
  64517. get r(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the g output component
  64520. */
  64521. get g(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the b output component
  64524. */
  64525. get b(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the a output component
  64528. */
  64529. get a(): NodeMaterialConnectionPoint;
  64530. autoConfigure(material: NodeMaterial): void;
  64531. protected _buildBlock(state: NodeMaterialBuildState): this;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Block used to add 2 vectors
  64537. */
  64538. export class AddBlock extends NodeMaterialBlock {
  64539. /**
  64540. * Creates a new AddBlock
  64541. * @param name defines the block name
  64542. */
  64543. constructor(name: string);
  64544. /**
  64545. * Gets the current class name
  64546. * @returns the class name
  64547. */
  64548. getClassName(): string;
  64549. /**
  64550. * Gets the left operand input component
  64551. */
  64552. get left(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the right operand input component
  64555. */
  64556. get right(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the output component
  64559. */
  64560. get output(): NodeMaterialConnectionPoint;
  64561. protected _buildBlock(state: NodeMaterialBuildState): this;
  64562. }
  64563. }
  64564. declare module BABYLON {
  64565. /**
  64566. * Block used to scale a vector by a float
  64567. */
  64568. export class ScaleBlock extends NodeMaterialBlock {
  64569. /**
  64570. * Creates a new ScaleBlock
  64571. * @param name defines the block name
  64572. */
  64573. constructor(name: string);
  64574. /**
  64575. * Gets the current class name
  64576. * @returns the class name
  64577. */
  64578. getClassName(): string;
  64579. /**
  64580. * Gets the input component
  64581. */
  64582. get input(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the factor input component
  64585. */
  64586. get factor(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the output component
  64589. */
  64590. get output(): NodeMaterialConnectionPoint;
  64591. protected _buildBlock(state: NodeMaterialBuildState): this;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /**
  64596. * Block used to clamp a float
  64597. */
  64598. export class ClampBlock extends NodeMaterialBlock {
  64599. /** Gets or sets the minimum range */
  64600. minimum: number;
  64601. /** Gets or sets the maximum range */
  64602. maximum: number;
  64603. /**
  64604. * Creates a new ClampBlock
  64605. * @param name defines the block name
  64606. */
  64607. constructor(name: string);
  64608. /**
  64609. * Gets the current class name
  64610. * @returns the class name
  64611. */
  64612. getClassName(): string;
  64613. /**
  64614. * Gets the value input component
  64615. */
  64616. get value(): NodeMaterialConnectionPoint;
  64617. /**
  64618. * Gets the output component
  64619. */
  64620. get output(): NodeMaterialConnectionPoint;
  64621. protected _buildBlock(state: NodeMaterialBuildState): this;
  64622. protected _dumpPropertiesCode(): string;
  64623. serialize(): any;
  64624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /**
  64629. * Block used to apply a cross product between 2 vectors
  64630. */
  64631. export class CrossBlock extends NodeMaterialBlock {
  64632. /**
  64633. * Creates a new CrossBlock
  64634. * @param name defines the block name
  64635. */
  64636. constructor(name: string);
  64637. /**
  64638. * Gets the current class name
  64639. * @returns the class name
  64640. */
  64641. getClassName(): string;
  64642. /**
  64643. * Gets the left operand input component
  64644. */
  64645. get left(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the right operand input component
  64648. */
  64649. get right(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the output component
  64652. */
  64653. get output(): NodeMaterialConnectionPoint;
  64654. protected _buildBlock(state: NodeMaterialBuildState): this;
  64655. }
  64656. }
  64657. declare module BABYLON {
  64658. /**
  64659. * Block used to apply a dot product between 2 vectors
  64660. */
  64661. export class DotBlock extends NodeMaterialBlock {
  64662. /**
  64663. * Creates a new DotBlock
  64664. * @param name defines the block name
  64665. */
  64666. constructor(name: string);
  64667. /**
  64668. * Gets the current class name
  64669. * @returns the class name
  64670. */
  64671. getClassName(): string;
  64672. /**
  64673. * Gets the left operand input component
  64674. */
  64675. get left(): NodeMaterialConnectionPoint;
  64676. /**
  64677. * Gets the right operand input component
  64678. */
  64679. get right(): NodeMaterialConnectionPoint;
  64680. /**
  64681. * Gets the output component
  64682. */
  64683. get output(): NodeMaterialConnectionPoint;
  64684. protected _buildBlock(state: NodeMaterialBuildState): this;
  64685. }
  64686. }
  64687. declare module BABYLON {
  64688. /**
  64689. * Block used to normalize a vector
  64690. */
  64691. export class NormalizeBlock extends NodeMaterialBlock {
  64692. /**
  64693. * Creates a new NormalizeBlock
  64694. * @param name defines the block name
  64695. */
  64696. constructor(name: string);
  64697. /**
  64698. * Gets the current class name
  64699. * @returns the class name
  64700. */
  64701. getClassName(): string;
  64702. /**
  64703. * Gets the input component
  64704. */
  64705. get input(): NodeMaterialConnectionPoint;
  64706. /**
  64707. * Gets the output component
  64708. */
  64709. get output(): NodeMaterialConnectionPoint;
  64710. protected _buildBlock(state: NodeMaterialBuildState): this;
  64711. }
  64712. }
  64713. declare module BABYLON {
  64714. /**
  64715. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64716. */
  64717. export class ColorMergerBlock extends NodeMaterialBlock {
  64718. /**
  64719. * Create a new ColorMergerBlock
  64720. * @param name defines the block name
  64721. */
  64722. constructor(name: string);
  64723. /**
  64724. * Gets the current class name
  64725. * @returns the class name
  64726. */
  64727. getClassName(): string;
  64728. /**
  64729. * Gets the rgb component (input)
  64730. */
  64731. get rgbIn(): NodeMaterialConnectionPoint;
  64732. /**
  64733. * Gets the r component (input)
  64734. */
  64735. get r(): NodeMaterialConnectionPoint;
  64736. /**
  64737. * Gets the g component (input)
  64738. */
  64739. get g(): NodeMaterialConnectionPoint;
  64740. /**
  64741. * Gets the b component (input)
  64742. */
  64743. get b(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the a component (input)
  64746. */
  64747. get a(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the rgba component (output)
  64750. */
  64751. get rgba(): NodeMaterialConnectionPoint;
  64752. /**
  64753. * Gets the rgb component (output)
  64754. */
  64755. get rgbOut(): NodeMaterialConnectionPoint;
  64756. /**
  64757. * Gets the rgb component (output)
  64758. * @deprecated Please use rgbOut instead.
  64759. */
  64760. get rgb(): NodeMaterialConnectionPoint;
  64761. protected _buildBlock(state: NodeMaterialBuildState): this;
  64762. }
  64763. }
  64764. declare module BABYLON {
  64765. /**
  64766. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64767. */
  64768. export class VectorSplitterBlock extends NodeMaterialBlock {
  64769. /**
  64770. * Create a new VectorSplitterBlock
  64771. * @param name defines the block name
  64772. */
  64773. constructor(name: string);
  64774. /**
  64775. * Gets the current class name
  64776. * @returns the class name
  64777. */
  64778. getClassName(): string;
  64779. /**
  64780. * Gets the xyzw component (input)
  64781. */
  64782. get xyzw(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the xyz component (input)
  64785. */
  64786. get xyzIn(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the xy component (input)
  64789. */
  64790. get xyIn(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the xyz component (output)
  64793. */
  64794. get xyzOut(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the xy component (output)
  64797. */
  64798. get xyOut(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the x component (output)
  64801. */
  64802. get x(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the y component (output)
  64805. */
  64806. get y(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the z component (output)
  64809. */
  64810. get z(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the w component (output)
  64813. */
  64814. get w(): NodeMaterialConnectionPoint;
  64815. protected _inputRename(name: string): string;
  64816. protected _outputRename(name: string): string;
  64817. protected _buildBlock(state: NodeMaterialBuildState): this;
  64818. }
  64819. }
  64820. declare module BABYLON {
  64821. /**
  64822. * Block used to lerp between 2 values
  64823. */
  64824. export class LerpBlock extends NodeMaterialBlock {
  64825. /**
  64826. * Creates a new LerpBlock
  64827. * @param name defines the block name
  64828. */
  64829. constructor(name: string);
  64830. /**
  64831. * Gets the current class name
  64832. * @returns the class name
  64833. */
  64834. getClassName(): string;
  64835. /**
  64836. * Gets the left operand input component
  64837. */
  64838. get left(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the right operand input component
  64841. */
  64842. get right(): NodeMaterialConnectionPoint;
  64843. /**
  64844. * Gets the gradient operand input component
  64845. */
  64846. get gradient(): NodeMaterialConnectionPoint;
  64847. /**
  64848. * Gets the output component
  64849. */
  64850. get output(): NodeMaterialConnectionPoint;
  64851. protected _buildBlock(state: NodeMaterialBuildState): this;
  64852. }
  64853. }
  64854. declare module BABYLON {
  64855. /**
  64856. * Block used to divide 2 vectors
  64857. */
  64858. export class DivideBlock extends NodeMaterialBlock {
  64859. /**
  64860. * Creates a new DivideBlock
  64861. * @param name defines the block name
  64862. */
  64863. constructor(name: string);
  64864. /**
  64865. * Gets the current class name
  64866. * @returns the class name
  64867. */
  64868. getClassName(): string;
  64869. /**
  64870. * Gets the left operand input component
  64871. */
  64872. get left(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the right operand input component
  64875. */
  64876. get right(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the output component
  64879. */
  64880. get output(): NodeMaterialConnectionPoint;
  64881. protected _buildBlock(state: NodeMaterialBuildState): this;
  64882. }
  64883. }
  64884. declare module BABYLON {
  64885. /**
  64886. * Block used to subtract 2 vectors
  64887. */
  64888. export class SubtractBlock extends NodeMaterialBlock {
  64889. /**
  64890. * Creates a new SubtractBlock
  64891. * @param name defines the block name
  64892. */
  64893. constructor(name: string);
  64894. /**
  64895. * Gets the current class name
  64896. * @returns the class name
  64897. */
  64898. getClassName(): string;
  64899. /**
  64900. * Gets the left operand input component
  64901. */
  64902. get left(): NodeMaterialConnectionPoint;
  64903. /**
  64904. * Gets the right operand input component
  64905. */
  64906. get right(): NodeMaterialConnectionPoint;
  64907. /**
  64908. * Gets the output component
  64909. */
  64910. get output(): NodeMaterialConnectionPoint;
  64911. protected _buildBlock(state: NodeMaterialBuildState): this;
  64912. }
  64913. }
  64914. declare module BABYLON {
  64915. /**
  64916. * Block used to step a value
  64917. */
  64918. export class StepBlock extends NodeMaterialBlock {
  64919. /**
  64920. * Creates a new StepBlock
  64921. * @param name defines the block name
  64922. */
  64923. constructor(name: string);
  64924. /**
  64925. * Gets the current class name
  64926. * @returns the class name
  64927. */
  64928. getClassName(): string;
  64929. /**
  64930. * Gets the value operand input component
  64931. */
  64932. get value(): NodeMaterialConnectionPoint;
  64933. /**
  64934. * Gets the edge operand input component
  64935. */
  64936. get edge(): NodeMaterialConnectionPoint;
  64937. /**
  64938. * Gets the output component
  64939. */
  64940. get output(): NodeMaterialConnectionPoint;
  64941. protected _buildBlock(state: NodeMaterialBuildState): this;
  64942. }
  64943. }
  64944. declare module BABYLON {
  64945. /**
  64946. * Block used to get the opposite (1 - x) of a value
  64947. */
  64948. export class OneMinusBlock extends NodeMaterialBlock {
  64949. /**
  64950. * Creates a new OneMinusBlock
  64951. * @param name defines the block name
  64952. */
  64953. constructor(name: string);
  64954. /**
  64955. * Gets the current class name
  64956. * @returns the class name
  64957. */
  64958. getClassName(): string;
  64959. /**
  64960. * Gets the input component
  64961. */
  64962. get input(): NodeMaterialConnectionPoint;
  64963. /**
  64964. * Gets the output component
  64965. */
  64966. get output(): NodeMaterialConnectionPoint;
  64967. protected _buildBlock(state: NodeMaterialBuildState): this;
  64968. }
  64969. }
  64970. declare module BABYLON {
  64971. /**
  64972. * Block used to get the view direction
  64973. */
  64974. export class ViewDirectionBlock extends NodeMaterialBlock {
  64975. /**
  64976. * Creates a new ViewDirectionBlock
  64977. * @param name defines the block name
  64978. */
  64979. constructor(name: string);
  64980. /**
  64981. * Gets the current class name
  64982. * @returns the class name
  64983. */
  64984. getClassName(): string;
  64985. /**
  64986. * Gets the world position component
  64987. */
  64988. get worldPosition(): NodeMaterialConnectionPoint;
  64989. /**
  64990. * Gets the camera position component
  64991. */
  64992. get cameraPosition(): NodeMaterialConnectionPoint;
  64993. /**
  64994. * Gets the output component
  64995. */
  64996. get output(): NodeMaterialConnectionPoint;
  64997. autoConfigure(material: NodeMaterial): void;
  64998. protected _buildBlock(state: NodeMaterialBuildState): this;
  64999. }
  65000. }
  65001. declare module BABYLON {
  65002. /**
  65003. * Block used to compute fresnel value
  65004. */
  65005. export class FresnelBlock extends NodeMaterialBlock {
  65006. /**
  65007. * Create a new FresnelBlock
  65008. * @param name defines the block name
  65009. */
  65010. constructor(name: string);
  65011. /**
  65012. * Gets the current class name
  65013. * @returns the class name
  65014. */
  65015. getClassName(): string;
  65016. /**
  65017. * Gets the world normal input component
  65018. */
  65019. get worldNormal(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the view direction input component
  65022. */
  65023. get viewDirection(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the bias input component
  65026. */
  65027. get bias(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the camera (or eye) position component
  65030. */
  65031. get power(): NodeMaterialConnectionPoint;
  65032. /**
  65033. * Gets the fresnel output component
  65034. */
  65035. get fresnel(): NodeMaterialConnectionPoint;
  65036. autoConfigure(material: NodeMaterial): void;
  65037. protected _buildBlock(state: NodeMaterialBuildState): this;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * Block used to get the max of 2 values
  65043. */
  65044. export class MaxBlock extends NodeMaterialBlock {
  65045. /**
  65046. * Creates a new MaxBlock
  65047. * @param name defines the block name
  65048. */
  65049. constructor(name: string);
  65050. /**
  65051. * Gets the current class name
  65052. * @returns the class name
  65053. */
  65054. getClassName(): string;
  65055. /**
  65056. * Gets the left operand input component
  65057. */
  65058. get left(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the right operand input component
  65061. */
  65062. get right(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the output component
  65065. */
  65066. get output(): NodeMaterialConnectionPoint;
  65067. protected _buildBlock(state: NodeMaterialBuildState): this;
  65068. }
  65069. }
  65070. declare module BABYLON {
  65071. /**
  65072. * Block used to get the min of 2 values
  65073. */
  65074. export class MinBlock extends NodeMaterialBlock {
  65075. /**
  65076. * Creates a new MinBlock
  65077. * @param name defines the block name
  65078. */
  65079. constructor(name: string);
  65080. /**
  65081. * Gets the current class name
  65082. * @returns the class name
  65083. */
  65084. getClassName(): string;
  65085. /**
  65086. * Gets the left operand input component
  65087. */
  65088. get left(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the right operand input component
  65091. */
  65092. get right(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the output component
  65095. */
  65096. get output(): NodeMaterialConnectionPoint;
  65097. protected _buildBlock(state: NodeMaterialBuildState): this;
  65098. }
  65099. }
  65100. declare module BABYLON {
  65101. /**
  65102. * Block used to get the distance between 2 values
  65103. */
  65104. export class DistanceBlock extends NodeMaterialBlock {
  65105. /**
  65106. * Creates a new DistanceBlock
  65107. * @param name defines the block name
  65108. */
  65109. constructor(name: string);
  65110. /**
  65111. * Gets the current class name
  65112. * @returns the class name
  65113. */
  65114. getClassName(): string;
  65115. /**
  65116. * Gets the left operand input component
  65117. */
  65118. get left(): NodeMaterialConnectionPoint;
  65119. /**
  65120. * Gets the right operand input component
  65121. */
  65122. get right(): NodeMaterialConnectionPoint;
  65123. /**
  65124. * Gets the output component
  65125. */
  65126. get output(): NodeMaterialConnectionPoint;
  65127. protected _buildBlock(state: NodeMaterialBuildState): this;
  65128. }
  65129. }
  65130. declare module BABYLON {
  65131. /**
  65132. * Block used to get the length of a vector
  65133. */
  65134. export class LengthBlock extends NodeMaterialBlock {
  65135. /**
  65136. * Creates a new LengthBlock
  65137. * @param name defines the block name
  65138. */
  65139. constructor(name: string);
  65140. /**
  65141. * Gets the current class name
  65142. * @returns the class name
  65143. */
  65144. getClassName(): string;
  65145. /**
  65146. * Gets the value input component
  65147. */
  65148. get value(): NodeMaterialConnectionPoint;
  65149. /**
  65150. * Gets the output component
  65151. */
  65152. get output(): NodeMaterialConnectionPoint;
  65153. protected _buildBlock(state: NodeMaterialBuildState): this;
  65154. }
  65155. }
  65156. declare module BABYLON {
  65157. /**
  65158. * Block used to get negative version of a value (i.e. x * -1)
  65159. */
  65160. export class NegateBlock extends NodeMaterialBlock {
  65161. /**
  65162. * Creates a new NegateBlock
  65163. * @param name defines the block name
  65164. */
  65165. constructor(name: string);
  65166. /**
  65167. * Gets the current class name
  65168. * @returns the class name
  65169. */
  65170. getClassName(): string;
  65171. /**
  65172. * Gets the value input component
  65173. */
  65174. get value(): NodeMaterialConnectionPoint;
  65175. /**
  65176. * Gets the output component
  65177. */
  65178. get output(): NodeMaterialConnectionPoint;
  65179. protected _buildBlock(state: NodeMaterialBuildState): this;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /**
  65184. * Block used to get the value of the first parameter raised to the power of the second
  65185. */
  65186. export class PowBlock extends NodeMaterialBlock {
  65187. /**
  65188. * Creates a new PowBlock
  65189. * @param name defines the block name
  65190. */
  65191. constructor(name: string);
  65192. /**
  65193. * Gets the current class name
  65194. * @returns the class name
  65195. */
  65196. getClassName(): string;
  65197. /**
  65198. * Gets the value operand input component
  65199. */
  65200. get value(): NodeMaterialConnectionPoint;
  65201. /**
  65202. * Gets the power operand input component
  65203. */
  65204. get power(): NodeMaterialConnectionPoint;
  65205. /**
  65206. * Gets the output component
  65207. */
  65208. get output(): NodeMaterialConnectionPoint;
  65209. protected _buildBlock(state: NodeMaterialBuildState): this;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Block used to get a random number
  65215. */
  65216. export class RandomNumberBlock extends NodeMaterialBlock {
  65217. /**
  65218. * Creates a new RandomNumberBlock
  65219. * @param name defines the block name
  65220. */
  65221. constructor(name: string);
  65222. /**
  65223. * Gets the current class name
  65224. * @returns the class name
  65225. */
  65226. getClassName(): string;
  65227. /**
  65228. * Gets the seed input component
  65229. */
  65230. get seed(): NodeMaterialConnectionPoint;
  65231. /**
  65232. * Gets the output component
  65233. */
  65234. get output(): NodeMaterialConnectionPoint;
  65235. protected _buildBlock(state: NodeMaterialBuildState): this;
  65236. }
  65237. }
  65238. declare module BABYLON {
  65239. /**
  65240. * Block used to compute arc tangent of 2 values
  65241. */
  65242. export class ArcTan2Block extends NodeMaterialBlock {
  65243. /**
  65244. * Creates a new ArcTan2Block
  65245. * @param name defines the block name
  65246. */
  65247. constructor(name: string);
  65248. /**
  65249. * Gets the current class name
  65250. * @returns the class name
  65251. */
  65252. getClassName(): string;
  65253. /**
  65254. * Gets the x operand input component
  65255. */
  65256. get x(): NodeMaterialConnectionPoint;
  65257. /**
  65258. * Gets the y operand input component
  65259. */
  65260. get y(): NodeMaterialConnectionPoint;
  65261. /**
  65262. * Gets the output component
  65263. */
  65264. get output(): NodeMaterialConnectionPoint;
  65265. protected _buildBlock(state: NodeMaterialBuildState): this;
  65266. }
  65267. }
  65268. declare module BABYLON {
  65269. /**
  65270. * Block used to smooth step a value
  65271. */
  65272. export class SmoothStepBlock extends NodeMaterialBlock {
  65273. /**
  65274. * Creates a new SmoothStepBlock
  65275. * @param name defines the block name
  65276. */
  65277. constructor(name: string);
  65278. /**
  65279. * Gets the current class name
  65280. * @returns the class name
  65281. */
  65282. getClassName(): string;
  65283. /**
  65284. * Gets the value operand input component
  65285. */
  65286. get value(): NodeMaterialConnectionPoint;
  65287. /**
  65288. * Gets the first edge operand input component
  65289. */
  65290. get edge0(): NodeMaterialConnectionPoint;
  65291. /**
  65292. * Gets the second edge operand input component
  65293. */
  65294. get edge1(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the output component
  65297. */
  65298. get output(): NodeMaterialConnectionPoint;
  65299. protected _buildBlock(state: NodeMaterialBuildState): this;
  65300. }
  65301. }
  65302. declare module BABYLON {
  65303. /**
  65304. * Block used to get the reciprocal (1 / x) of a value
  65305. */
  65306. export class ReciprocalBlock extends NodeMaterialBlock {
  65307. /**
  65308. * Creates a new ReciprocalBlock
  65309. * @param name defines the block name
  65310. */
  65311. constructor(name: string);
  65312. /**
  65313. * Gets the current class name
  65314. * @returns the class name
  65315. */
  65316. getClassName(): string;
  65317. /**
  65318. * Gets the input component
  65319. */
  65320. get input(): NodeMaterialConnectionPoint;
  65321. /**
  65322. * Gets the output component
  65323. */
  65324. get output(): NodeMaterialConnectionPoint;
  65325. protected _buildBlock(state: NodeMaterialBuildState): this;
  65326. }
  65327. }
  65328. declare module BABYLON {
  65329. /**
  65330. * Block used to replace a color by another one
  65331. */
  65332. export class ReplaceColorBlock extends NodeMaterialBlock {
  65333. /**
  65334. * Creates a new ReplaceColorBlock
  65335. * @param name defines the block name
  65336. */
  65337. constructor(name: string);
  65338. /**
  65339. * Gets the current class name
  65340. * @returns the class name
  65341. */
  65342. getClassName(): string;
  65343. /**
  65344. * Gets the value input component
  65345. */
  65346. get value(): NodeMaterialConnectionPoint;
  65347. /**
  65348. * Gets the reference input component
  65349. */
  65350. get reference(): NodeMaterialConnectionPoint;
  65351. /**
  65352. * Gets the distance input component
  65353. */
  65354. get distance(): NodeMaterialConnectionPoint;
  65355. /**
  65356. * Gets the replacement input component
  65357. */
  65358. get replacement(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the output component
  65361. */
  65362. get output(): NodeMaterialConnectionPoint;
  65363. protected _buildBlock(state: NodeMaterialBuildState): this;
  65364. }
  65365. }
  65366. declare module BABYLON {
  65367. /**
  65368. * Block used to posterize a value
  65369. * @see https://en.wikipedia.org/wiki/Posterization
  65370. */
  65371. export class PosterizeBlock extends NodeMaterialBlock {
  65372. /**
  65373. * Creates a new PosterizeBlock
  65374. * @param name defines the block name
  65375. */
  65376. constructor(name: string);
  65377. /**
  65378. * Gets the current class name
  65379. * @returns the class name
  65380. */
  65381. getClassName(): string;
  65382. /**
  65383. * Gets the value input component
  65384. */
  65385. get value(): NodeMaterialConnectionPoint;
  65386. /**
  65387. * Gets the steps input component
  65388. */
  65389. get steps(): NodeMaterialConnectionPoint;
  65390. /**
  65391. * Gets the output component
  65392. */
  65393. get output(): NodeMaterialConnectionPoint;
  65394. protected _buildBlock(state: NodeMaterialBuildState): this;
  65395. }
  65396. }
  65397. declare module BABYLON {
  65398. /**
  65399. * Operations supported by the Wave block
  65400. */
  65401. export enum WaveBlockKind {
  65402. /** SawTooth */
  65403. SawTooth = 0,
  65404. /** Square */
  65405. Square = 1,
  65406. /** Triangle */
  65407. Triangle = 2
  65408. }
  65409. /**
  65410. * Block used to apply wave operation to floats
  65411. */
  65412. export class WaveBlock extends NodeMaterialBlock {
  65413. /**
  65414. * Gets or sets the kibnd of wave to be applied by the block
  65415. */
  65416. kind: WaveBlockKind;
  65417. /**
  65418. * Creates a new WaveBlock
  65419. * @param name defines the block name
  65420. */
  65421. constructor(name: string);
  65422. /**
  65423. * Gets the current class name
  65424. * @returns the class name
  65425. */
  65426. getClassName(): string;
  65427. /**
  65428. * Gets the input component
  65429. */
  65430. get input(): NodeMaterialConnectionPoint;
  65431. /**
  65432. * Gets the output component
  65433. */
  65434. get output(): NodeMaterialConnectionPoint;
  65435. protected _buildBlock(state: NodeMaterialBuildState): this;
  65436. serialize(): any;
  65437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65438. }
  65439. }
  65440. declare module BABYLON {
  65441. /**
  65442. * Class used to store a color step for the GradientBlock
  65443. */
  65444. export class GradientBlockColorStep {
  65445. private _step;
  65446. /**
  65447. * Gets value indicating which step this color is associated with (between 0 and 1)
  65448. */
  65449. get step(): number;
  65450. /**
  65451. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65452. */
  65453. set step(val: number);
  65454. private _color;
  65455. /**
  65456. * Gets the color associated with this step
  65457. */
  65458. get color(): Color3;
  65459. /**
  65460. * Sets the color associated with this step
  65461. */
  65462. set color(val: Color3);
  65463. /**
  65464. * Creates a new GradientBlockColorStep
  65465. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65466. * @param color defines the color associated with this step
  65467. */
  65468. constructor(step: number, color: Color3);
  65469. }
  65470. /**
  65471. * Block used to return a color from a gradient based on an input value between 0 and 1
  65472. */
  65473. export class GradientBlock extends NodeMaterialBlock {
  65474. /**
  65475. * Gets or sets the list of color steps
  65476. */
  65477. colorSteps: GradientBlockColorStep[];
  65478. /** Gets an observable raised when the value is changed */
  65479. onValueChangedObservable: Observable<GradientBlock>;
  65480. /** calls observable when the value is changed*/
  65481. colorStepsUpdated(): void;
  65482. /**
  65483. * Creates a new GradientBlock
  65484. * @param name defines the block name
  65485. */
  65486. constructor(name: string);
  65487. /**
  65488. * Gets the current class name
  65489. * @returns the class name
  65490. */
  65491. getClassName(): string;
  65492. /**
  65493. * Gets the gradient input component
  65494. */
  65495. get gradient(): NodeMaterialConnectionPoint;
  65496. /**
  65497. * Gets the output component
  65498. */
  65499. get output(): NodeMaterialConnectionPoint;
  65500. private _writeColorConstant;
  65501. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65502. serialize(): any;
  65503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65504. protected _dumpPropertiesCode(): string;
  65505. }
  65506. }
  65507. declare module BABYLON {
  65508. /**
  65509. * Block used to normalize lerp between 2 values
  65510. */
  65511. export class NLerpBlock extends NodeMaterialBlock {
  65512. /**
  65513. * Creates a new NLerpBlock
  65514. * @param name defines the block name
  65515. */
  65516. constructor(name: string);
  65517. /**
  65518. * Gets the current class name
  65519. * @returns the class name
  65520. */
  65521. getClassName(): string;
  65522. /**
  65523. * Gets the left operand input component
  65524. */
  65525. get left(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the right operand input component
  65528. */
  65529. get right(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the gradient operand input component
  65532. */
  65533. get gradient(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the output component
  65536. */
  65537. get output(): NodeMaterialConnectionPoint;
  65538. protected _buildBlock(state: NodeMaterialBuildState): this;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /**
  65543. * block used to Generate a Worley Noise 3D Noise Pattern
  65544. */
  65545. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65546. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65547. manhattanDistance: boolean;
  65548. /**
  65549. * Creates a new WorleyNoise3DBlock
  65550. * @param name defines the block name
  65551. */
  65552. constructor(name: string);
  65553. /**
  65554. * Gets the current class name
  65555. * @returns the class name
  65556. */
  65557. getClassName(): string;
  65558. /**
  65559. * Gets the seed input component
  65560. */
  65561. get seed(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the jitter input component
  65564. */
  65565. get jitter(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the output component
  65568. */
  65569. get output(): NodeMaterialConnectionPoint;
  65570. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65571. /**
  65572. * Exposes the properties to the UI?
  65573. */
  65574. protected _dumpPropertiesCode(): string;
  65575. /**
  65576. * Exposes the properties to the Seralize?
  65577. */
  65578. serialize(): any;
  65579. /**
  65580. * Exposes the properties to the deseralize?
  65581. */
  65582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65583. }
  65584. }
  65585. declare module BABYLON {
  65586. /**
  65587. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65588. */
  65589. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65590. /**
  65591. * Creates a new SimplexPerlin3DBlock
  65592. * @param name defines the block name
  65593. */
  65594. constructor(name: string);
  65595. /**
  65596. * Gets the current class name
  65597. * @returns the class name
  65598. */
  65599. getClassName(): string;
  65600. /**
  65601. * Gets the seed operand input component
  65602. */
  65603. get seed(): NodeMaterialConnectionPoint;
  65604. /**
  65605. * Gets the output component
  65606. */
  65607. get output(): NodeMaterialConnectionPoint;
  65608. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65609. }
  65610. }
  65611. declare module BABYLON {
  65612. /**
  65613. * Block used to blend normals
  65614. */
  65615. export class NormalBlendBlock extends NodeMaterialBlock {
  65616. /**
  65617. * Creates a new NormalBlendBlock
  65618. * @param name defines the block name
  65619. */
  65620. constructor(name: string);
  65621. /**
  65622. * Gets the current class name
  65623. * @returns the class name
  65624. */
  65625. getClassName(): string;
  65626. /**
  65627. * Gets the first input component
  65628. */
  65629. get normalMap0(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the second input component
  65632. */
  65633. get normalMap1(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the output component
  65636. */
  65637. get output(): NodeMaterialConnectionPoint;
  65638. protected _buildBlock(state: NodeMaterialBuildState): this;
  65639. }
  65640. }
  65641. declare module BABYLON {
  65642. /**
  65643. * Block used to rotate a 2d vector by a given angle
  65644. */
  65645. export class Rotate2dBlock extends NodeMaterialBlock {
  65646. /**
  65647. * Creates a new Rotate2dBlock
  65648. * @param name defines the block name
  65649. */
  65650. constructor(name: string);
  65651. /**
  65652. * Gets the current class name
  65653. * @returns the class name
  65654. */
  65655. getClassName(): string;
  65656. /**
  65657. * Gets the input vector
  65658. */
  65659. get input(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the input angle
  65662. */
  65663. get angle(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the output component
  65666. */
  65667. get output(): NodeMaterialConnectionPoint;
  65668. autoConfigure(material: NodeMaterial): void;
  65669. protected _buildBlock(state: NodeMaterialBuildState): this;
  65670. }
  65671. }
  65672. declare module BABYLON {
  65673. /**
  65674. * Block used to get the reflected vector from a direction and a normal
  65675. */
  65676. export class ReflectBlock extends NodeMaterialBlock {
  65677. /**
  65678. * Creates a new ReflectBlock
  65679. * @param name defines the block name
  65680. */
  65681. constructor(name: string);
  65682. /**
  65683. * Gets the current class name
  65684. * @returns the class name
  65685. */
  65686. getClassName(): string;
  65687. /**
  65688. * Gets the incident component
  65689. */
  65690. get incident(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the normal component
  65693. */
  65694. get normal(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the output component
  65697. */
  65698. get output(): NodeMaterialConnectionPoint;
  65699. protected _buildBlock(state: NodeMaterialBuildState): this;
  65700. }
  65701. }
  65702. declare module BABYLON {
  65703. /**
  65704. * Block used to get the refracted vector from a direction and a normal
  65705. */
  65706. export class RefractBlock extends NodeMaterialBlock {
  65707. /**
  65708. * Creates a new RefractBlock
  65709. * @param name defines the block name
  65710. */
  65711. constructor(name: string);
  65712. /**
  65713. * Gets the current class name
  65714. * @returns the class name
  65715. */
  65716. getClassName(): string;
  65717. /**
  65718. * Gets the incident component
  65719. */
  65720. get incident(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the normal component
  65723. */
  65724. get normal(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Gets the index of refraction component
  65727. */
  65728. get ior(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the output component
  65731. */
  65732. get output(): NodeMaterialConnectionPoint;
  65733. protected _buildBlock(state: NodeMaterialBuildState): this;
  65734. }
  65735. }
  65736. declare module BABYLON {
  65737. /**
  65738. * Block used to desaturate a color
  65739. */
  65740. export class DesaturateBlock extends NodeMaterialBlock {
  65741. /**
  65742. * Creates a new DesaturateBlock
  65743. * @param name defines the block name
  65744. */
  65745. constructor(name: string);
  65746. /**
  65747. * Gets the current class name
  65748. * @returns the class name
  65749. */
  65750. getClassName(): string;
  65751. /**
  65752. * Gets the color operand input component
  65753. */
  65754. get color(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the level operand input component
  65757. */
  65758. get level(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the output component
  65761. */
  65762. get output(): NodeMaterialConnectionPoint;
  65763. protected _buildBlock(state: NodeMaterialBuildState): this;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * Block used to implement the reflection module of the PBR material
  65769. */
  65770. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65771. /** @hidden */
  65772. _defineLODReflectionAlpha: string;
  65773. /** @hidden */
  65774. _defineLinearSpecularReflection: string;
  65775. private _vEnvironmentIrradianceName;
  65776. /** @hidden */
  65777. _vReflectionMicrosurfaceInfosName: string;
  65778. /** @hidden */
  65779. _vReflectionInfosName: string;
  65780. /** @hidden */
  65781. _vReflectionFilteringInfoName: string;
  65782. private _scene;
  65783. /**
  65784. * The properties below are set by the main PBR block prior to calling methods of this class.
  65785. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65786. * It's less burden on the user side in the editor part.
  65787. */
  65788. /** @hidden */
  65789. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65790. /** @hidden */
  65791. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65792. /** @hidden */
  65793. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65794. /** @hidden */
  65795. viewConnectionPoint: NodeMaterialConnectionPoint;
  65796. /**
  65797. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65798. * diffuse part of the IBL.
  65799. */
  65800. useSphericalHarmonics: boolean;
  65801. /**
  65802. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65803. */
  65804. forceIrradianceInFragment: boolean;
  65805. /**
  65806. * Create a new ReflectionBlock
  65807. * @param name defines the block name
  65808. */
  65809. constructor(name: string);
  65810. /**
  65811. * Gets the current class name
  65812. * @returns the class name
  65813. */
  65814. getClassName(): string;
  65815. /**
  65816. * Gets the position input component
  65817. */
  65818. get position(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the world position input component
  65821. */
  65822. get worldPosition(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the world normal input component
  65825. */
  65826. get worldNormal(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the world input component
  65829. */
  65830. get world(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the camera (or eye) position component
  65833. */
  65834. get cameraPosition(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the view input component
  65837. */
  65838. get view(): NodeMaterialConnectionPoint;
  65839. /**
  65840. * Gets the color input component
  65841. */
  65842. get color(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the reflection object output component
  65845. */
  65846. get reflection(): NodeMaterialConnectionPoint;
  65847. /**
  65848. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65849. */
  65850. get hasTexture(): boolean;
  65851. /**
  65852. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65853. */
  65854. get reflectionColor(): string;
  65855. protected _getTexture(): Nullable<BaseTexture>;
  65856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65858. /**
  65859. * Gets the code to inject in the vertex shader
  65860. * @param state current state of the node material building
  65861. * @returns the shader code
  65862. */
  65863. handleVertexSide(state: NodeMaterialBuildState): string;
  65864. /**
  65865. * Gets the main code of the block (fragment side)
  65866. * @param state current state of the node material building
  65867. * @param normalVarName name of the existing variable corresponding to the normal
  65868. * @returns the shader code
  65869. */
  65870. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65871. protected _buildBlock(state: NodeMaterialBuildState): this;
  65872. protected _dumpPropertiesCode(): string;
  65873. serialize(): any;
  65874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65875. }
  65876. }
  65877. declare module BABYLON {
  65878. /**
  65879. * Block used to implement the sheen module of the PBR material
  65880. */
  65881. export class SheenBlock extends NodeMaterialBlock {
  65882. /**
  65883. * Create a new SheenBlock
  65884. * @param name defines the block name
  65885. */
  65886. constructor(name: string);
  65887. /**
  65888. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65889. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65890. * making it easier to setup and tweak the effect
  65891. */
  65892. albedoScaling: boolean;
  65893. /**
  65894. * Defines if the sheen is linked to the sheen color.
  65895. */
  65896. linkSheenWithAlbedo: boolean;
  65897. /**
  65898. * Initialize the block and prepare the context for build
  65899. * @param state defines the state that will be used for the build
  65900. */
  65901. initialize(state: NodeMaterialBuildState): void;
  65902. /**
  65903. * Gets the current class name
  65904. * @returns the class name
  65905. */
  65906. getClassName(): string;
  65907. /**
  65908. * Gets the intensity input component
  65909. */
  65910. get intensity(): NodeMaterialConnectionPoint;
  65911. /**
  65912. * Gets the color input component
  65913. */
  65914. get color(): NodeMaterialConnectionPoint;
  65915. /**
  65916. * Gets the roughness input component
  65917. */
  65918. get roughness(): NodeMaterialConnectionPoint;
  65919. /**
  65920. * Gets the sheen object output component
  65921. */
  65922. get sheen(): NodeMaterialConnectionPoint;
  65923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65924. /**
  65925. * Gets the main code of the block (fragment side)
  65926. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65927. * @returns the shader code
  65928. */
  65929. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65930. protected _buildBlock(state: NodeMaterialBuildState): this;
  65931. protected _dumpPropertiesCode(): string;
  65932. serialize(): any;
  65933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65934. }
  65935. }
  65936. declare module BABYLON {
  65937. /**
  65938. * Block used to implement the anisotropy module of the PBR material
  65939. */
  65940. export class AnisotropyBlock extends NodeMaterialBlock {
  65941. /**
  65942. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65943. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65944. * It's less burden on the user side in the editor part.
  65945. */
  65946. /** @hidden */
  65947. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65948. /** @hidden */
  65949. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65950. /**
  65951. * Create a new AnisotropyBlock
  65952. * @param name defines the block name
  65953. */
  65954. constructor(name: string);
  65955. /**
  65956. * Initialize the block and prepare the context for build
  65957. * @param state defines the state that will be used for the build
  65958. */
  65959. initialize(state: NodeMaterialBuildState): void;
  65960. /**
  65961. * Gets the current class name
  65962. * @returns the class name
  65963. */
  65964. getClassName(): string;
  65965. /**
  65966. * Gets the intensity input component
  65967. */
  65968. get intensity(): NodeMaterialConnectionPoint;
  65969. /**
  65970. * Gets the direction input component
  65971. */
  65972. get direction(): NodeMaterialConnectionPoint;
  65973. /**
  65974. * Gets the uv input component
  65975. */
  65976. get uv(): NodeMaterialConnectionPoint;
  65977. /**
  65978. * Gets the worldTangent input component
  65979. */
  65980. get worldTangent(): NodeMaterialConnectionPoint;
  65981. /**
  65982. * Gets the anisotropy object output component
  65983. */
  65984. get anisotropy(): NodeMaterialConnectionPoint;
  65985. private _generateTBNSpace;
  65986. /**
  65987. * Gets the main code of the block (fragment side)
  65988. * @param state current state of the node material building
  65989. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65990. * @returns the shader code
  65991. */
  65992. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65994. protected _buildBlock(state: NodeMaterialBuildState): this;
  65995. }
  65996. }
  65997. declare module BABYLON {
  65998. /**
  65999. * Block used to implement the clear coat module of the PBR material
  66000. */
  66001. export class ClearCoatBlock extends NodeMaterialBlock {
  66002. private _scene;
  66003. /**
  66004. * Create a new ClearCoatBlock
  66005. * @param name defines the block name
  66006. */
  66007. constructor(name: string);
  66008. /**
  66009. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66010. */
  66011. remapF0OnInterfaceChange: boolean;
  66012. /**
  66013. * Initialize the block and prepare the context for build
  66014. * @param state defines the state that will be used for the build
  66015. */
  66016. initialize(state: NodeMaterialBuildState): void;
  66017. /**
  66018. * Gets the current class name
  66019. * @returns the class name
  66020. */
  66021. getClassName(): string;
  66022. /**
  66023. * Gets the intensity input component
  66024. */
  66025. get intensity(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the roughness input component
  66028. */
  66029. get roughness(): NodeMaterialConnectionPoint;
  66030. /**
  66031. * Gets the ior input component
  66032. */
  66033. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66034. /**
  66035. * Gets the bump texture input component
  66036. */
  66037. get normalMapColor(): NodeMaterialConnectionPoint;
  66038. /**
  66039. * Gets the uv input component
  66040. */
  66041. get uv(): NodeMaterialConnectionPoint;
  66042. /**
  66043. * Gets the tint color input component
  66044. */
  66045. get tintColor(): NodeMaterialConnectionPoint;
  66046. /**
  66047. * Gets the tint "at distance" input component
  66048. */
  66049. get tintAtDistance(): NodeMaterialConnectionPoint;
  66050. /**
  66051. * Gets the tint thickness input component
  66052. */
  66053. get tintThickness(): NodeMaterialConnectionPoint;
  66054. /**
  66055. * Gets the world tangent input component
  66056. */
  66057. get worldTangent(): NodeMaterialConnectionPoint;
  66058. /**
  66059. * Gets the clear coat object output component
  66060. */
  66061. get clearcoat(): NodeMaterialConnectionPoint;
  66062. autoConfigure(material: NodeMaterial): void;
  66063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66065. private _generateTBNSpace;
  66066. /**
  66067. * Gets the main code of the block (fragment side)
  66068. * @param state current state of the node material building
  66069. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66070. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66071. * @param worldPosVarName name of the variable holding the world position
  66072. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66073. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66074. * @param worldNormalVarName name of the variable holding the world normal
  66075. * @returns the shader code
  66076. */
  66077. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66078. protected _buildBlock(state: NodeMaterialBuildState): this;
  66079. protected _dumpPropertiesCode(): string;
  66080. serialize(): any;
  66081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66082. }
  66083. }
  66084. declare module BABYLON {
  66085. /**
  66086. * Block used to implement the sub surface module of the PBR material
  66087. */
  66088. export class SubSurfaceBlock extends NodeMaterialBlock {
  66089. /**
  66090. * Create a new SubSurfaceBlock
  66091. * @param name defines the block name
  66092. */
  66093. constructor(name: string);
  66094. /**
  66095. * Initialize the block and prepare the context for build
  66096. * @param state defines the state that will be used for the build
  66097. */
  66098. initialize(state: NodeMaterialBuildState): void;
  66099. /**
  66100. * Gets the current class name
  66101. * @returns the class name
  66102. */
  66103. getClassName(): string;
  66104. /**
  66105. * Gets the thickness component
  66106. */
  66107. get thickness(): NodeMaterialConnectionPoint;
  66108. /**
  66109. * Gets the tint color input component
  66110. */
  66111. get tintColor(): NodeMaterialConnectionPoint;
  66112. /**
  66113. * Gets the translucency intensity input component
  66114. */
  66115. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66116. /**
  66117. * Gets the translucency diffusion distance input component
  66118. */
  66119. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66120. /**
  66121. * Gets the refraction object parameters
  66122. */
  66123. get refraction(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the sub surface object output component
  66126. */
  66127. get subsurface(): NodeMaterialConnectionPoint;
  66128. autoConfigure(material: NodeMaterial): void;
  66129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66130. /**
  66131. * Gets the main code of the block (fragment side)
  66132. * @param state current state of the node material building
  66133. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66134. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66135. * @param worldPosVarName name of the variable holding the world position
  66136. * @returns the shader code
  66137. */
  66138. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66139. protected _buildBlock(state: NodeMaterialBuildState): this;
  66140. }
  66141. }
  66142. declare module BABYLON {
  66143. /**
  66144. * Block used to implement the PBR metallic/roughness model
  66145. */
  66146. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66147. /**
  66148. * Gets or sets the light associated with this block
  66149. */
  66150. light: Nullable<Light>;
  66151. private _lightId;
  66152. private _scene;
  66153. private _environmentBRDFTexture;
  66154. private _environmentBrdfSamplerName;
  66155. private _vNormalWName;
  66156. private _invertNormalName;
  66157. private _metallicReflectanceColor;
  66158. private _metallicF0Factor;
  66159. private _vMetallicReflectanceFactorsName;
  66160. /**
  66161. * Create a new ReflectionBlock
  66162. * @param name defines the block name
  66163. */
  66164. constructor(name: string);
  66165. /**
  66166. * Intensity of the direct lights e.g. the four lights available in your scene.
  66167. * This impacts both the direct diffuse and specular highlights.
  66168. */
  66169. directIntensity: number;
  66170. /**
  66171. * Intensity of the environment e.g. how much the environment will light the object
  66172. * either through harmonics for rough material or through the refelction for shiny ones.
  66173. */
  66174. environmentIntensity: number;
  66175. /**
  66176. * This is a special control allowing the reduction of the specular highlights coming from the
  66177. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66178. */
  66179. specularIntensity: number;
  66180. /**
  66181. * Defines the falloff type used in this material.
  66182. * It by default is Physical.
  66183. */
  66184. lightFalloff: number;
  66185. /**
  66186. * Specifies that alpha test should be used
  66187. */
  66188. useAlphaTest: boolean;
  66189. /**
  66190. * Defines the alpha limits in alpha test mode.
  66191. */
  66192. alphaTestCutoff: number;
  66193. /**
  66194. * Specifies that alpha blending should be used
  66195. */
  66196. useAlphaBlending: boolean;
  66197. /**
  66198. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66199. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66200. */
  66201. useRadianceOverAlpha: boolean;
  66202. /**
  66203. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66204. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66205. */
  66206. useSpecularOverAlpha: boolean;
  66207. /**
  66208. * Enables specular anti aliasing in the PBR shader.
  66209. * It will both interacts on the Geometry for analytical and IBL lighting.
  66210. * It also prefilter the roughness map based on the bump values.
  66211. */
  66212. enableSpecularAntiAliasing: boolean;
  66213. /**
  66214. * Enables realtime filtering on the texture.
  66215. */
  66216. realTimeFiltering: boolean;
  66217. /**
  66218. * Quality switch for realtime filtering
  66219. */
  66220. realTimeFilteringQuality: number;
  66221. /**
  66222. * Defines if the material uses energy conservation.
  66223. */
  66224. useEnergyConservation: boolean;
  66225. /**
  66226. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66227. * too much the area relying on ambient texture to define their ambient occlusion.
  66228. */
  66229. useRadianceOcclusion: boolean;
  66230. /**
  66231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66232. * makes the reflect vector face the model (under horizon).
  66233. */
  66234. useHorizonOcclusion: boolean;
  66235. /**
  66236. * If set to true, no lighting calculations will be applied.
  66237. */
  66238. unlit: boolean;
  66239. /**
  66240. * Force normal to face away from face.
  66241. */
  66242. forceNormalForward: boolean;
  66243. /**
  66244. * Defines the material debug mode.
  66245. * It helps seeing only some components of the material while troubleshooting.
  66246. */
  66247. debugMode: number;
  66248. /**
  66249. * Specify from where on screen the debug mode should start.
  66250. * The value goes from -1 (full screen) to 1 (not visible)
  66251. * It helps with side by side comparison against the final render
  66252. * This defaults to 0
  66253. */
  66254. debugLimit: number;
  66255. /**
  66256. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66257. * You can use the factor to better multiply the final value.
  66258. */
  66259. debugFactor: number;
  66260. /**
  66261. * Initialize the block and prepare the context for build
  66262. * @param state defines the state that will be used for the build
  66263. */
  66264. initialize(state: NodeMaterialBuildState): void;
  66265. /**
  66266. * Gets the current class name
  66267. * @returns the class name
  66268. */
  66269. getClassName(): string;
  66270. /**
  66271. * Gets the world position input component
  66272. */
  66273. get worldPosition(): NodeMaterialConnectionPoint;
  66274. /**
  66275. * Gets the world normal input component
  66276. */
  66277. get worldNormal(): NodeMaterialConnectionPoint;
  66278. /**
  66279. * Gets the view matrix parameter
  66280. */
  66281. get view(): NodeMaterialConnectionPoint;
  66282. /**
  66283. * Gets the camera position input component
  66284. */
  66285. get cameraPosition(): NodeMaterialConnectionPoint;
  66286. /**
  66287. * Gets the perturbed normal input component
  66288. */
  66289. get perturbedNormal(): NodeMaterialConnectionPoint;
  66290. /**
  66291. * Gets the base color input component
  66292. */
  66293. get baseColor(): NodeMaterialConnectionPoint;
  66294. /**
  66295. * Gets the metallic input component
  66296. */
  66297. get metallic(): NodeMaterialConnectionPoint;
  66298. /**
  66299. * Gets the roughness input component
  66300. */
  66301. get roughness(): NodeMaterialConnectionPoint;
  66302. /**
  66303. * Gets the ambient occlusion input component
  66304. */
  66305. get ambientOcc(): NodeMaterialConnectionPoint;
  66306. /**
  66307. * Gets the opacity input component
  66308. */
  66309. get opacity(): NodeMaterialConnectionPoint;
  66310. /**
  66311. * Gets the index of refraction input component
  66312. */
  66313. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the ambient color input component
  66316. */
  66317. get ambientColor(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the reflection object parameters
  66320. */
  66321. get reflection(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the clear coat object parameters
  66324. */
  66325. get clearcoat(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the sheen object parameters
  66328. */
  66329. get sheen(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the sub surface object parameters
  66332. */
  66333. get subsurface(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the anisotropy object parameters
  66336. */
  66337. get anisotropy(): NodeMaterialConnectionPoint;
  66338. /**
  66339. * Gets the ambient output component
  66340. */
  66341. get ambientClr(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the diffuse output component
  66344. */
  66345. get diffuseDir(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the specular output component
  66348. */
  66349. get specularDir(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the clear coat output component
  66352. */
  66353. get clearcoatDir(): NodeMaterialConnectionPoint;
  66354. /**
  66355. * Gets the sheen output component
  66356. */
  66357. get sheenDir(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the indirect diffuse output component
  66360. */
  66361. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the indirect specular output component
  66364. */
  66365. get specularIndirect(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the indirect clear coat output component
  66368. */
  66369. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the indirect sheen output component
  66372. */
  66373. get sheenIndirect(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the refraction output component
  66376. */
  66377. get refraction(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the global lighting output component
  66380. */
  66381. get lighting(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the shadow output component
  66384. */
  66385. get shadow(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the alpha output component
  66388. */
  66389. get alpha(): NodeMaterialConnectionPoint;
  66390. autoConfigure(material: NodeMaterial): void;
  66391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66392. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66394. private _injectVertexCode;
  66395. private _getAlbedoOpacityCode;
  66396. private _getAmbientOcclusionCode;
  66397. private _getReflectivityCode;
  66398. protected _buildBlock(state: NodeMaterialBuildState): this;
  66399. protected _dumpPropertiesCode(): string;
  66400. serialize(): any;
  66401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66402. }
  66403. }
  66404. declare module BABYLON {
  66405. /**
  66406. * Block used to compute value of one parameter modulo another
  66407. */
  66408. export class ModBlock extends NodeMaterialBlock {
  66409. /**
  66410. * Creates a new ModBlock
  66411. * @param name defines the block name
  66412. */
  66413. constructor(name: string);
  66414. /**
  66415. * Gets the current class name
  66416. * @returns the class name
  66417. */
  66418. getClassName(): string;
  66419. /**
  66420. * Gets the left operand input component
  66421. */
  66422. get left(): NodeMaterialConnectionPoint;
  66423. /**
  66424. * Gets the right operand input component
  66425. */
  66426. get right(): NodeMaterialConnectionPoint;
  66427. /**
  66428. * Gets the output component
  66429. */
  66430. get output(): NodeMaterialConnectionPoint;
  66431. protected _buildBlock(state: NodeMaterialBuildState): this;
  66432. }
  66433. }
  66434. declare module BABYLON {
  66435. /**
  66436. * Configuration for Draco compression
  66437. */
  66438. export interface IDracoCompressionConfiguration {
  66439. /**
  66440. * Configuration for the decoder.
  66441. */
  66442. decoder: {
  66443. /**
  66444. * The url to the WebAssembly module.
  66445. */
  66446. wasmUrl?: string;
  66447. /**
  66448. * The url to the WebAssembly binary.
  66449. */
  66450. wasmBinaryUrl?: string;
  66451. /**
  66452. * The url to the fallback JavaScript module.
  66453. */
  66454. fallbackUrl?: string;
  66455. };
  66456. }
  66457. /**
  66458. * Draco compression (https://google.github.io/draco/)
  66459. *
  66460. * This class wraps the Draco module.
  66461. *
  66462. * **Encoder**
  66463. *
  66464. * The encoder is not currently implemented.
  66465. *
  66466. * **Decoder**
  66467. *
  66468. * 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.
  66469. *
  66470. * To update the configuration, use the following code:
  66471. * ```javascript
  66472. * DracoCompression.Configuration = {
  66473. * decoder: {
  66474. * wasmUrl: "<url to the WebAssembly library>",
  66475. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66476. * fallbackUrl: "<url to the fallback JavaScript library>",
  66477. * }
  66478. * };
  66479. * ```
  66480. *
  66481. * 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.
  66482. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66483. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66484. *
  66485. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66486. * ```javascript
  66487. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66488. * ```
  66489. *
  66490. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66491. */
  66492. export class DracoCompression implements IDisposable {
  66493. private _workerPoolPromise?;
  66494. private _decoderModulePromise?;
  66495. /**
  66496. * The configuration. Defaults to the following urls:
  66497. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66498. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66499. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66500. */
  66501. static Configuration: IDracoCompressionConfiguration;
  66502. /**
  66503. * Returns true if the decoder configuration is available.
  66504. */
  66505. static get DecoderAvailable(): boolean;
  66506. /**
  66507. * Default number of workers to create when creating the draco compression object.
  66508. */
  66509. static DefaultNumWorkers: number;
  66510. private static GetDefaultNumWorkers;
  66511. private static _Default;
  66512. /**
  66513. * Default instance for the draco compression object.
  66514. */
  66515. static get Default(): DracoCompression;
  66516. /**
  66517. * Constructor
  66518. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66519. */
  66520. constructor(numWorkers?: number);
  66521. /**
  66522. * Stop all async operations and release resources.
  66523. */
  66524. dispose(): void;
  66525. /**
  66526. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66527. * @returns a promise that resolves when ready
  66528. */
  66529. whenReadyAsync(): Promise<void>;
  66530. /**
  66531. * Decode Draco compressed mesh data to vertex data.
  66532. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66533. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66534. * @returns A promise that resolves with the decoded vertex data
  66535. */
  66536. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66537. [kind: string]: number;
  66538. }): Promise<VertexData>;
  66539. }
  66540. }
  66541. declare module BABYLON {
  66542. /**
  66543. * Class for building Constructive Solid Geometry
  66544. */
  66545. export class CSG {
  66546. private polygons;
  66547. /**
  66548. * The world matrix
  66549. */
  66550. matrix: Matrix;
  66551. /**
  66552. * Stores the position
  66553. */
  66554. position: Vector3;
  66555. /**
  66556. * Stores the rotation
  66557. */
  66558. rotation: Vector3;
  66559. /**
  66560. * Stores the rotation quaternion
  66561. */
  66562. rotationQuaternion: Nullable<Quaternion>;
  66563. /**
  66564. * Stores the scaling vector
  66565. */
  66566. scaling: Vector3;
  66567. /**
  66568. * Convert the Mesh to CSG
  66569. * @param mesh The Mesh to convert to CSG
  66570. * @returns A new CSG from the Mesh
  66571. */
  66572. static FromMesh(mesh: Mesh): CSG;
  66573. /**
  66574. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66575. * @param polygons Polygons used to construct a CSG solid
  66576. */
  66577. private static FromPolygons;
  66578. /**
  66579. * Clones, or makes a deep copy, of the CSG
  66580. * @returns A new CSG
  66581. */
  66582. clone(): CSG;
  66583. /**
  66584. * Unions this CSG with another CSG
  66585. * @param csg The CSG to union against this CSG
  66586. * @returns The unioned CSG
  66587. */
  66588. union(csg: CSG): CSG;
  66589. /**
  66590. * Unions this CSG with another CSG in place
  66591. * @param csg The CSG to union against this CSG
  66592. */
  66593. unionInPlace(csg: CSG): void;
  66594. /**
  66595. * Subtracts this CSG with another CSG
  66596. * @param csg The CSG to subtract against this CSG
  66597. * @returns A new CSG
  66598. */
  66599. subtract(csg: CSG): CSG;
  66600. /**
  66601. * Subtracts this CSG with another CSG in place
  66602. * @param csg The CSG to subtact against this CSG
  66603. */
  66604. subtractInPlace(csg: CSG): void;
  66605. /**
  66606. * Intersect this CSG with another CSG
  66607. * @param csg The CSG to intersect against this CSG
  66608. * @returns A new CSG
  66609. */
  66610. intersect(csg: CSG): CSG;
  66611. /**
  66612. * Intersects this CSG with another CSG in place
  66613. * @param csg The CSG to intersect against this CSG
  66614. */
  66615. intersectInPlace(csg: CSG): void;
  66616. /**
  66617. * Return a new CSG solid with solid and empty space switched. This solid is
  66618. * not modified.
  66619. * @returns A new CSG solid with solid and empty space switched
  66620. */
  66621. inverse(): CSG;
  66622. /**
  66623. * Inverses the CSG in place
  66624. */
  66625. inverseInPlace(): void;
  66626. /**
  66627. * This is used to keep meshes transformations so they can be restored
  66628. * when we build back a Babylon Mesh
  66629. * NB : All CSG operations are performed in world coordinates
  66630. * @param csg The CSG to copy the transform attributes from
  66631. * @returns This CSG
  66632. */
  66633. copyTransformAttributes(csg: CSG): CSG;
  66634. /**
  66635. * Build Raw mesh from CSG
  66636. * Coordinates here are in world space
  66637. * @param name The name of the mesh geometry
  66638. * @param scene The Scene
  66639. * @param keepSubMeshes Specifies if the submeshes should be kept
  66640. * @returns A new Mesh
  66641. */
  66642. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66643. /**
  66644. * Build Mesh from CSG taking material and transforms into account
  66645. * @param name The name of the Mesh
  66646. * @param material The material of the Mesh
  66647. * @param scene The Scene
  66648. * @param keepSubMeshes Specifies if submeshes should be kept
  66649. * @returns The new Mesh
  66650. */
  66651. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66652. }
  66653. }
  66654. declare module BABYLON {
  66655. /**
  66656. * Class used to create a trail following a mesh
  66657. */
  66658. export class TrailMesh extends Mesh {
  66659. private _generator;
  66660. private _autoStart;
  66661. private _running;
  66662. private _diameter;
  66663. private _length;
  66664. private _sectionPolygonPointsCount;
  66665. private _sectionVectors;
  66666. private _sectionNormalVectors;
  66667. private _beforeRenderObserver;
  66668. /**
  66669. * @constructor
  66670. * @param name The value used by scene.getMeshByName() to do a lookup.
  66671. * @param generator The mesh or transform node to generate a trail.
  66672. * @param scene The scene to add this mesh to.
  66673. * @param diameter Diameter of trailing mesh. Default is 1.
  66674. * @param length Length of trailing mesh. Default is 60.
  66675. * @param autoStart Automatically start trailing mesh. Default true.
  66676. */
  66677. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66678. /**
  66679. * "TrailMesh"
  66680. * @returns "TrailMesh"
  66681. */
  66682. getClassName(): string;
  66683. private _createMesh;
  66684. /**
  66685. * Start trailing mesh.
  66686. */
  66687. start(): void;
  66688. /**
  66689. * Stop trailing mesh.
  66690. */
  66691. stop(): void;
  66692. /**
  66693. * Update trailing mesh geometry.
  66694. */
  66695. update(): void;
  66696. /**
  66697. * Returns a new TrailMesh object.
  66698. * @param name is a string, the name given to the new mesh
  66699. * @param newGenerator use new generator object for cloned trail mesh
  66700. * @returns a new mesh
  66701. */
  66702. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66703. /**
  66704. * Serializes this trail mesh
  66705. * @param serializationObject object to write serialization to
  66706. */
  66707. serialize(serializationObject: any): void;
  66708. /**
  66709. * Parses a serialized trail mesh
  66710. * @param parsedMesh the serialized mesh
  66711. * @param scene the scene to create the trail mesh in
  66712. * @returns the created trail mesh
  66713. */
  66714. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66715. }
  66716. }
  66717. declare module BABYLON {
  66718. /**
  66719. * Class containing static functions to help procedurally build meshes
  66720. */
  66721. export class TiledBoxBuilder {
  66722. /**
  66723. * Creates a box mesh
  66724. * 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)
  66725. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66727. * * 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
  66728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66729. * @param name defines the name of the mesh
  66730. * @param options defines the options used to create the mesh
  66731. * @param scene defines the hosting scene
  66732. * @returns the box mesh
  66733. */
  66734. static CreateTiledBox(name: string, options: {
  66735. pattern?: number;
  66736. width?: number;
  66737. height?: number;
  66738. depth?: number;
  66739. tileSize?: number;
  66740. tileWidth?: number;
  66741. tileHeight?: number;
  66742. alignHorizontal?: number;
  66743. alignVertical?: number;
  66744. faceUV?: Vector4[];
  66745. faceColors?: Color4[];
  66746. sideOrientation?: number;
  66747. updatable?: boolean;
  66748. }, scene?: Nullable<Scene>): Mesh;
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /**
  66753. * Class containing static functions to help procedurally build meshes
  66754. */
  66755. export class TorusKnotBuilder {
  66756. /**
  66757. * Creates a torus knot mesh
  66758. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66759. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66760. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66761. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66763. * * 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
  66764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66765. * @param name defines the name of the mesh
  66766. * @param options defines the options used to create the mesh
  66767. * @param scene defines the hosting scene
  66768. * @returns the torus knot mesh
  66769. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66770. */
  66771. static CreateTorusKnot(name: string, options: {
  66772. radius?: number;
  66773. tube?: number;
  66774. radialSegments?: number;
  66775. tubularSegments?: number;
  66776. p?: number;
  66777. q?: number;
  66778. updatable?: boolean;
  66779. sideOrientation?: number;
  66780. frontUVs?: Vector4;
  66781. backUVs?: Vector4;
  66782. }, scene: any): Mesh;
  66783. }
  66784. }
  66785. declare module BABYLON {
  66786. /**
  66787. * Polygon
  66788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66789. */
  66790. export class Polygon {
  66791. /**
  66792. * Creates a rectangle
  66793. * @param xmin bottom X coord
  66794. * @param ymin bottom Y coord
  66795. * @param xmax top X coord
  66796. * @param ymax top Y coord
  66797. * @returns points that make the resulting rectation
  66798. */
  66799. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66800. /**
  66801. * Creates a circle
  66802. * @param radius radius of circle
  66803. * @param cx scale in x
  66804. * @param cy scale in y
  66805. * @param numberOfSides number of sides that make up the circle
  66806. * @returns points that make the resulting circle
  66807. */
  66808. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66809. /**
  66810. * Creates a polygon from input string
  66811. * @param input Input polygon data
  66812. * @returns the parsed points
  66813. */
  66814. static Parse(input: string): Vector2[];
  66815. /**
  66816. * Starts building a polygon from x and y coordinates
  66817. * @param x x coordinate
  66818. * @param y y coordinate
  66819. * @returns the started path2
  66820. */
  66821. static StartingAt(x: number, y: number): Path2;
  66822. }
  66823. /**
  66824. * Builds a polygon
  66825. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66826. */
  66827. export class PolygonMeshBuilder {
  66828. private _points;
  66829. private _outlinepoints;
  66830. private _holes;
  66831. private _name;
  66832. private _scene;
  66833. private _epoints;
  66834. private _eholes;
  66835. private _addToepoint;
  66836. /**
  66837. * Babylon reference to the earcut plugin.
  66838. */
  66839. bjsEarcut: any;
  66840. /**
  66841. * Creates a PolygonMeshBuilder
  66842. * @param name name of the builder
  66843. * @param contours Path of the polygon
  66844. * @param scene scene to add to when creating the mesh
  66845. * @param earcutInjection can be used to inject your own earcut reference
  66846. */
  66847. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66848. /**
  66849. * Adds a whole within the polygon
  66850. * @param hole Array of points defining the hole
  66851. * @returns this
  66852. */
  66853. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66854. /**
  66855. * Creates the polygon
  66856. * @param updatable If the mesh should be updatable
  66857. * @param depth The depth of the mesh created
  66858. * @returns the created mesh
  66859. */
  66860. build(updatable?: boolean, depth?: number): Mesh;
  66861. /**
  66862. * Creates the polygon
  66863. * @param depth The depth of the mesh created
  66864. * @returns the created VertexData
  66865. */
  66866. buildVertexData(depth?: number): VertexData;
  66867. /**
  66868. * Adds a side to the polygon
  66869. * @param positions points that make the polygon
  66870. * @param normals normals of the polygon
  66871. * @param uvs uvs of the polygon
  66872. * @param indices indices of the polygon
  66873. * @param bounds bounds of the polygon
  66874. * @param points points of the polygon
  66875. * @param depth depth of the polygon
  66876. * @param flip flip of the polygon
  66877. */
  66878. private addSide;
  66879. }
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * Class containing static functions to help procedurally build meshes
  66884. */
  66885. export class PolygonBuilder {
  66886. /**
  66887. * Creates a polygon mesh
  66888. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66889. * * 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
  66890. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66892. * * 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)
  66893. * * Remember you can only change the shape positions, not their number when updating a polygon
  66894. * @param name defines the name of the mesh
  66895. * @param options defines the options used to create the mesh
  66896. * @param scene defines the hosting scene
  66897. * @param earcutInjection can be used to inject your own earcut reference
  66898. * @returns the polygon mesh
  66899. */
  66900. static CreatePolygon(name: string, options: {
  66901. shape: Vector3[];
  66902. holes?: Vector3[][];
  66903. depth?: number;
  66904. faceUV?: Vector4[];
  66905. faceColors?: Color4[];
  66906. updatable?: boolean;
  66907. sideOrientation?: number;
  66908. frontUVs?: Vector4;
  66909. backUVs?: Vector4;
  66910. wrap?: boolean;
  66911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66912. /**
  66913. * Creates an extruded polygon mesh, with depth in the Y direction.
  66914. * * 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)
  66915. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66916. * @param name defines the name of the mesh
  66917. * @param options defines the options used to create the mesh
  66918. * @param scene defines the hosting scene
  66919. * @param earcutInjection can be used to inject your own earcut reference
  66920. * @returns the polygon mesh
  66921. */
  66922. static ExtrudePolygon(name: string, options: {
  66923. shape: Vector3[];
  66924. holes?: Vector3[][];
  66925. depth?: number;
  66926. faceUV?: Vector4[];
  66927. faceColors?: Color4[];
  66928. updatable?: boolean;
  66929. sideOrientation?: number;
  66930. frontUVs?: Vector4;
  66931. backUVs?: Vector4;
  66932. wrap?: boolean;
  66933. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66934. }
  66935. }
  66936. declare module BABYLON {
  66937. /**
  66938. * Class containing static functions to help procedurally build meshes
  66939. */
  66940. export class LatheBuilder {
  66941. /**
  66942. * Creates lathe mesh.
  66943. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66944. * * 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
  66945. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66946. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66947. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66948. * * 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
  66949. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66950. * * 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
  66951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66952. * * 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
  66953. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66955. * @param name defines the name of the mesh
  66956. * @param options defines the options used to create the mesh
  66957. * @param scene defines the hosting scene
  66958. * @returns the lathe mesh
  66959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66960. */
  66961. static CreateLathe(name: string, options: {
  66962. shape: Vector3[];
  66963. radius?: number;
  66964. tessellation?: number;
  66965. clip?: number;
  66966. arc?: number;
  66967. closed?: boolean;
  66968. updatable?: boolean;
  66969. sideOrientation?: number;
  66970. frontUVs?: Vector4;
  66971. backUVs?: Vector4;
  66972. cap?: number;
  66973. invertUV?: boolean;
  66974. }, scene?: Nullable<Scene>): Mesh;
  66975. }
  66976. }
  66977. declare module BABYLON {
  66978. /**
  66979. * Class containing static functions to help procedurally build meshes
  66980. */
  66981. export class TiledPlaneBuilder {
  66982. /**
  66983. * Creates a tiled plane mesh
  66984. * * The parameter `pattern` will, depending on value, do nothing or
  66985. * * * flip (reflect about central vertical) alternate tiles across and up
  66986. * * * flip every tile on alternate rows
  66987. * * * rotate (180 degs) alternate tiles across and up
  66988. * * * rotate every tile on alternate rows
  66989. * * * flip and rotate alternate tiles across and up
  66990. * * * flip and rotate every tile on alternate rows
  66991. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66992. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66993. * * 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
  66994. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66995. * * 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)
  66996. * * 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)
  66997. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66998. * @param name defines the name of the mesh
  66999. * @param options defines the options used to create the mesh
  67000. * @param scene defines the hosting scene
  67001. * @returns the box mesh
  67002. */
  67003. static CreateTiledPlane(name: string, options: {
  67004. pattern?: number;
  67005. tileSize?: number;
  67006. tileWidth?: number;
  67007. tileHeight?: number;
  67008. size?: number;
  67009. width?: number;
  67010. height?: number;
  67011. alignHorizontal?: number;
  67012. alignVertical?: number;
  67013. sideOrientation?: number;
  67014. frontUVs?: Vector4;
  67015. backUVs?: Vector4;
  67016. updatable?: boolean;
  67017. }, scene?: Nullable<Scene>): Mesh;
  67018. }
  67019. }
  67020. declare module BABYLON {
  67021. /**
  67022. * Class containing static functions to help procedurally build meshes
  67023. */
  67024. export class TubeBuilder {
  67025. /**
  67026. * Creates a tube mesh.
  67027. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67028. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67029. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67030. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67031. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67032. * * 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)
  67033. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67034. * * 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
  67035. * * 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
  67036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67037. * * 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
  67038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67040. * @param name defines the name of the mesh
  67041. * @param options defines the options used to create the mesh
  67042. * @param scene defines the hosting scene
  67043. * @returns the tube mesh
  67044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67045. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67046. */
  67047. static CreateTube(name: string, options: {
  67048. path: Vector3[];
  67049. radius?: number;
  67050. tessellation?: number;
  67051. radiusFunction?: {
  67052. (i: number, distance: number): number;
  67053. };
  67054. cap?: number;
  67055. arc?: number;
  67056. updatable?: boolean;
  67057. sideOrientation?: number;
  67058. frontUVs?: Vector4;
  67059. backUVs?: Vector4;
  67060. instance?: Mesh;
  67061. invertUV?: boolean;
  67062. }, scene?: Nullable<Scene>): Mesh;
  67063. }
  67064. }
  67065. declare module BABYLON {
  67066. /**
  67067. * Class containing static functions to help procedurally build meshes
  67068. */
  67069. export class IcoSphereBuilder {
  67070. /**
  67071. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67072. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67073. * * 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`)
  67074. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67075. * * 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
  67076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67077. * * 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
  67078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67079. * @param name defines the name of the mesh
  67080. * @param options defines the options used to create the mesh
  67081. * @param scene defines the hosting scene
  67082. * @returns the icosahedron mesh
  67083. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67084. */
  67085. static CreateIcoSphere(name: string, options: {
  67086. radius?: number;
  67087. radiusX?: number;
  67088. radiusY?: number;
  67089. radiusZ?: number;
  67090. flat?: boolean;
  67091. subdivisions?: number;
  67092. sideOrientation?: number;
  67093. frontUVs?: Vector4;
  67094. backUVs?: Vector4;
  67095. updatable?: boolean;
  67096. }, scene?: Nullable<Scene>): Mesh;
  67097. }
  67098. }
  67099. declare module BABYLON {
  67100. /**
  67101. * Class containing static functions to help procedurally build meshes
  67102. */
  67103. export class DecalBuilder {
  67104. /**
  67105. * Creates a decal mesh.
  67106. * 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
  67107. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67108. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67109. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67110. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67111. * @param name defines the name of the mesh
  67112. * @param sourceMesh defines the mesh where the decal must be applied
  67113. * @param options defines the options used to create the mesh
  67114. * @param scene defines the hosting scene
  67115. * @returns the decal mesh
  67116. * @see https://doc.babylonjs.com/how_to/decals
  67117. */
  67118. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67119. position?: Vector3;
  67120. normal?: Vector3;
  67121. size?: Vector3;
  67122. angle?: number;
  67123. }): Mesh;
  67124. }
  67125. }
  67126. declare module BABYLON {
  67127. /**
  67128. * Class containing static functions to help procedurally build meshes
  67129. */
  67130. export class MeshBuilder {
  67131. /**
  67132. * Creates a box mesh
  67133. * * The parameter `size` sets the size (float) of each box side (default 1)
  67134. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67135. * * 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)
  67136. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67138. * * 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
  67139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67140. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67141. * @param name defines the name of the mesh
  67142. * @param options defines the options used to create the mesh
  67143. * @param scene defines the hosting scene
  67144. * @returns the box mesh
  67145. */
  67146. static CreateBox(name: string, options: {
  67147. size?: number;
  67148. width?: number;
  67149. height?: number;
  67150. depth?: number;
  67151. faceUV?: Vector4[];
  67152. faceColors?: Color4[];
  67153. sideOrientation?: number;
  67154. frontUVs?: Vector4;
  67155. backUVs?: Vector4;
  67156. wrap?: boolean;
  67157. topBaseAt?: number;
  67158. bottomBaseAt?: number;
  67159. updatable?: boolean;
  67160. }, scene?: Nullable<Scene>): Mesh;
  67161. /**
  67162. * Creates a tiled box mesh
  67163. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67165. * @param name defines the name of the mesh
  67166. * @param options defines the options used to create the mesh
  67167. * @param scene defines the hosting scene
  67168. * @returns the tiled box mesh
  67169. */
  67170. static CreateTiledBox(name: string, options: {
  67171. pattern?: number;
  67172. size?: number;
  67173. width?: number;
  67174. height?: number;
  67175. depth: number;
  67176. tileSize?: number;
  67177. tileWidth?: number;
  67178. tileHeight?: number;
  67179. faceUV?: Vector4[];
  67180. faceColors?: Color4[];
  67181. alignHorizontal?: number;
  67182. alignVertical?: number;
  67183. sideOrientation?: number;
  67184. updatable?: boolean;
  67185. }, scene?: Nullable<Scene>): Mesh;
  67186. /**
  67187. * Creates a sphere mesh
  67188. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67189. * * 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`)
  67190. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67191. * * 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
  67192. * * 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)
  67193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67194. * * 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
  67195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67196. * @param name defines the name of the mesh
  67197. * @param options defines the options used to create the mesh
  67198. * @param scene defines the hosting scene
  67199. * @returns the sphere mesh
  67200. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67201. */
  67202. static CreateSphere(name: string, options: {
  67203. segments?: number;
  67204. diameter?: number;
  67205. diameterX?: number;
  67206. diameterY?: number;
  67207. diameterZ?: number;
  67208. arc?: number;
  67209. slice?: number;
  67210. sideOrientation?: number;
  67211. frontUVs?: Vector4;
  67212. backUVs?: Vector4;
  67213. updatable?: boolean;
  67214. }, scene?: Nullable<Scene>): Mesh;
  67215. /**
  67216. * Creates a plane polygonal mesh. By default, this is a disc
  67217. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67218. * * 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
  67219. * * 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
  67220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67221. * * 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
  67222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67223. * @param name defines the name of the mesh
  67224. * @param options defines the options used to create the mesh
  67225. * @param scene defines the hosting scene
  67226. * @returns the plane polygonal mesh
  67227. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67228. */
  67229. static CreateDisc(name: string, options: {
  67230. radius?: number;
  67231. tessellation?: number;
  67232. arc?: number;
  67233. updatable?: boolean;
  67234. sideOrientation?: number;
  67235. frontUVs?: Vector4;
  67236. backUVs?: Vector4;
  67237. }, scene?: Nullable<Scene>): Mesh;
  67238. /**
  67239. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67240. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67241. * * 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`)
  67242. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67243. * * 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
  67244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67245. * * 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
  67246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67247. * @param name defines the name of the mesh
  67248. * @param options defines the options used to create the mesh
  67249. * @param scene defines the hosting scene
  67250. * @returns the icosahedron mesh
  67251. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67252. */
  67253. static CreateIcoSphere(name: string, options: {
  67254. radius?: number;
  67255. radiusX?: number;
  67256. radiusY?: number;
  67257. radiusZ?: number;
  67258. flat?: boolean;
  67259. subdivisions?: number;
  67260. sideOrientation?: number;
  67261. frontUVs?: Vector4;
  67262. backUVs?: Vector4;
  67263. updatable?: boolean;
  67264. }, scene?: Nullable<Scene>): Mesh;
  67265. /**
  67266. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67267. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67268. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67269. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67270. * * 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
  67271. * * 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
  67272. * * 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
  67273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67274. * * 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
  67275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67276. * * 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
  67277. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67278. * * 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
  67279. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67281. * @param name defines the name of the mesh
  67282. * @param options defines the options used to create the mesh
  67283. * @param scene defines the hosting scene
  67284. * @returns the ribbon mesh
  67285. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67287. */
  67288. static CreateRibbon(name: string, options: {
  67289. pathArray: Vector3[][];
  67290. closeArray?: boolean;
  67291. closePath?: boolean;
  67292. offset?: number;
  67293. updatable?: boolean;
  67294. sideOrientation?: number;
  67295. frontUVs?: Vector4;
  67296. backUVs?: Vector4;
  67297. instance?: Mesh;
  67298. invertUV?: boolean;
  67299. uvs?: Vector2[];
  67300. colors?: Color4[];
  67301. }, scene?: Nullable<Scene>): Mesh;
  67302. /**
  67303. * Creates a cylinder or a cone mesh
  67304. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67305. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67306. * * 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.
  67307. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67308. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67309. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67310. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67311. * * 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).
  67312. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67313. * * 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).
  67314. * * 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
  67315. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67316. * * 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
  67317. * * 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.
  67318. * * If `enclose` is false, a ring surface is one element.
  67319. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67320. * * 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
  67321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67322. * * 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
  67323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67324. * @param name defines the name of the mesh
  67325. * @param options defines the options used to create the mesh
  67326. * @param scene defines the hosting scene
  67327. * @returns the cylinder mesh
  67328. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67329. */
  67330. static CreateCylinder(name: string, options: {
  67331. height?: number;
  67332. diameterTop?: number;
  67333. diameterBottom?: number;
  67334. diameter?: number;
  67335. tessellation?: number;
  67336. subdivisions?: number;
  67337. arc?: number;
  67338. faceColors?: Color4[];
  67339. faceUV?: Vector4[];
  67340. updatable?: boolean;
  67341. hasRings?: boolean;
  67342. enclose?: boolean;
  67343. cap?: number;
  67344. sideOrientation?: number;
  67345. frontUVs?: Vector4;
  67346. backUVs?: Vector4;
  67347. }, scene?: Nullable<Scene>): Mesh;
  67348. /**
  67349. * Creates a torus mesh
  67350. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67351. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67352. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67354. * * 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
  67355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67356. * @param name defines the name of the mesh
  67357. * @param options defines the options used to create the mesh
  67358. * @param scene defines the hosting scene
  67359. * @returns the torus mesh
  67360. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67361. */
  67362. static CreateTorus(name: string, options: {
  67363. diameter?: number;
  67364. thickness?: number;
  67365. tessellation?: number;
  67366. updatable?: boolean;
  67367. sideOrientation?: number;
  67368. frontUVs?: Vector4;
  67369. backUVs?: Vector4;
  67370. }, scene?: Nullable<Scene>): Mesh;
  67371. /**
  67372. * Creates a torus knot mesh
  67373. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67374. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67375. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67376. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67378. * * 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
  67379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67380. * @param name defines the name of the mesh
  67381. * @param options defines the options used to create the mesh
  67382. * @param scene defines the hosting scene
  67383. * @returns the torus knot mesh
  67384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67385. */
  67386. static CreateTorusKnot(name: string, options: {
  67387. radius?: number;
  67388. tube?: number;
  67389. radialSegments?: number;
  67390. tubularSegments?: number;
  67391. p?: number;
  67392. q?: number;
  67393. updatable?: boolean;
  67394. sideOrientation?: number;
  67395. frontUVs?: Vector4;
  67396. backUVs?: Vector4;
  67397. }, scene?: Nullable<Scene>): Mesh;
  67398. /**
  67399. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67400. * * 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
  67401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67402. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67403. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67404. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67405. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67406. * * 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
  67407. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67410. * @param name defines the name of the new line system
  67411. * @param options defines the options used to create the line system
  67412. * @param scene defines the hosting scene
  67413. * @returns a new line system mesh
  67414. */
  67415. static CreateLineSystem(name: string, options: {
  67416. lines: Vector3[][];
  67417. updatable?: boolean;
  67418. instance?: Nullable<LinesMesh>;
  67419. colors?: Nullable<Color4[][]>;
  67420. useVertexAlpha?: boolean;
  67421. }, scene: Nullable<Scene>): LinesMesh;
  67422. /**
  67423. * Creates a line mesh
  67424. * 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
  67425. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67426. * * The parameter `points` is an array successive Vector3
  67427. * * 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
  67428. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67429. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67430. * * When updating an instance, remember that only point positions can change, not the number of points
  67431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67433. * @param name defines the name of the new line system
  67434. * @param options defines the options used to create the line system
  67435. * @param scene defines the hosting scene
  67436. * @returns a new line mesh
  67437. */
  67438. static CreateLines(name: string, options: {
  67439. points: Vector3[];
  67440. updatable?: boolean;
  67441. instance?: Nullable<LinesMesh>;
  67442. colors?: Color4[];
  67443. useVertexAlpha?: boolean;
  67444. }, scene?: Nullable<Scene>): LinesMesh;
  67445. /**
  67446. * Creates a dashed line mesh
  67447. * * 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
  67448. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67449. * * The parameter `points` is an array successive Vector3
  67450. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67451. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67452. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67453. * * 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
  67454. * * When updating an instance, remember that only point positions can change, not the number of points
  67455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67456. * @param name defines the name of the mesh
  67457. * @param options defines the options used to create the mesh
  67458. * @param scene defines the hosting scene
  67459. * @returns the dashed line mesh
  67460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67461. */
  67462. static CreateDashedLines(name: string, options: {
  67463. points: Vector3[];
  67464. dashSize?: number;
  67465. gapSize?: number;
  67466. dashNb?: number;
  67467. updatable?: boolean;
  67468. instance?: LinesMesh;
  67469. }, scene?: Nullable<Scene>): LinesMesh;
  67470. /**
  67471. * 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.
  67472. * * 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.
  67473. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67474. * * 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.
  67475. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67476. * * 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
  67477. * * 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
  67478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67480. * * 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
  67481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67483. * @param name defines the name of the mesh
  67484. * @param options defines the options used to create the mesh
  67485. * @param scene defines the hosting scene
  67486. * @returns the extruded shape mesh
  67487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67489. */
  67490. static ExtrudeShape(name: string, options: {
  67491. shape: Vector3[];
  67492. path: Vector3[];
  67493. scale?: number;
  67494. rotation?: number;
  67495. cap?: number;
  67496. updatable?: boolean;
  67497. sideOrientation?: number;
  67498. frontUVs?: Vector4;
  67499. backUVs?: Vector4;
  67500. instance?: Mesh;
  67501. invertUV?: boolean;
  67502. }, scene?: Nullable<Scene>): Mesh;
  67503. /**
  67504. * Creates an custom extruded shape mesh.
  67505. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67506. * * 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.
  67507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67508. * * 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
  67509. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67510. * * 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
  67511. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67512. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67513. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67514. * * 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
  67515. * * 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
  67516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67518. * * 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
  67519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67521. * @param name defines the name of the mesh
  67522. * @param options defines the options used to create the mesh
  67523. * @param scene defines the hosting scene
  67524. * @returns the custom extruded shape mesh
  67525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67526. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67528. */
  67529. static ExtrudeShapeCustom(name: string, options: {
  67530. shape: Vector3[];
  67531. path: Vector3[];
  67532. scaleFunction?: any;
  67533. rotationFunction?: any;
  67534. ribbonCloseArray?: boolean;
  67535. ribbonClosePath?: boolean;
  67536. cap?: number;
  67537. updatable?: boolean;
  67538. sideOrientation?: number;
  67539. frontUVs?: Vector4;
  67540. backUVs?: Vector4;
  67541. instance?: Mesh;
  67542. invertUV?: boolean;
  67543. }, scene?: Nullable<Scene>): Mesh;
  67544. /**
  67545. * Creates lathe mesh.
  67546. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67547. * * 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
  67548. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67549. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67550. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67551. * * 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
  67552. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67553. * * 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
  67554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67555. * * 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
  67556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67558. * @param name defines the name of the mesh
  67559. * @param options defines the options used to create the mesh
  67560. * @param scene defines the hosting scene
  67561. * @returns the lathe mesh
  67562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67563. */
  67564. static CreateLathe(name: string, options: {
  67565. shape: Vector3[];
  67566. radius?: number;
  67567. tessellation?: number;
  67568. clip?: number;
  67569. arc?: number;
  67570. closed?: boolean;
  67571. updatable?: boolean;
  67572. sideOrientation?: number;
  67573. frontUVs?: Vector4;
  67574. backUVs?: Vector4;
  67575. cap?: number;
  67576. invertUV?: boolean;
  67577. }, scene?: Nullable<Scene>): Mesh;
  67578. /**
  67579. * Creates a tiled plane mesh
  67580. * * You can set a limited pattern arrangement with the tiles
  67581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67582. * * 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
  67583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67584. * @param name defines the name of the mesh
  67585. * @param options defines the options used to create the mesh
  67586. * @param scene defines the hosting scene
  67587. * @returns the plane mesh
  67588. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67589. */
  67590. static CreateTiledPlane(name: string, options: {
  67591. pattern?: number;
  67592. tileSize?: number;
  67593. tileWidth?: number;
  67594. tileHeight?: number;
  67595. size?: number;
  67596. width?: number;
  67597. height?: number;
  67598. alignHorizontal?: number;
  67599. alignVertical?: number;
  67600. sideOrientation?: number;
  67601. frontUVs?: Vector4;
  67602. backUVs?: Vector4;
  67603. updatable?: boolean;
  67604. }, scene?: Nullable<Scene>): Mesh;
  67605. /**
  67606. * Creates a plane mesh
  67607. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67608. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67609. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67611. * * 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
  67612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67613. * @param name defines the name of the mesh
  67614. * @param options defines the options used to create the mesh
  67615. * @param scene defines the hosting scene
  67616. * @returns the plane mesh
  67617. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67618. */
  67619. static CreatePlane(name: string, options: {
  67620. size?: number;
  67621. width?: number;
  67622. height?: number;
  67623. sideOrientation?: number;
  67624. frontUVs?: Vector4;
  67625. backUVs?: Vector4;
  67626. updatable?: boolean;
  67627. sourcePlane?: Plane;
  67628. }, scene?: Nullable<Scene>): Mesh;
  67629. /**
  67630. * Creates a ground mesh
  67631. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67632. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67634. * @param name defines the name of the mesh
  67635. * @param options defines the options used to create the mesh
  67636. * @param scene defines the hosting scene
  67637. * @returns the ground mesh
  67638. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67639. */
  67640. static CreateGround(name: string, options: {
  67641. width?: number;
  67642. height?: number;
  67643. subdivisions?: number;
  67644. subdivisionsX?: number;
  67645. subdivisionsY?: number;
  67646. updatable?: boolean;
  67647. }, scene?: Nullable<Scene>): Mesh;
  67648. /**
  67649. * Creates a tiled ground mesh
  67650. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67651. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67652. * * 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
  67653. * * 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
  67654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67655. * @param name defines the name of the mesh
  67656. * @param options defines the options used to create the mesh
  67657. * @param scene defines the hosting scene
  67658. * @returns the tiled ground mesh
  67659. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67660. */
  67661. static CreateTiledGround(name: string, options: {
  67662. xmin: number;
  67663. zmin: number;
  67664. xmax: number;
  67665. zmax: number;
  67666. subdivisions?: {
  67667. w: number;
  67668. h: number;
  67669. };
  67670. precision?: {
  67671. w: number;
  67672. h: number;
  67673. };
  67674. updatable?: boolean;
  67675. }, scene?: Nullable<Scene>): Mesh;
  67676. /**
  67677. * Creates a ground mesh from a height map
  67678. * * The parameter `url` sets the URL of the height map image resource.
  67679. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67680. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67681. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67682. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67683. * * 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.
  67684. * * 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).
  67685. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67687. * @param name defines the name of the mesh
  67688. * @param url defines the url to the height map
  67689. * @param options defines the options used to create the mesh
  67690. * @param scene defines the hosting scene
  67691. * @returns the ground mesh
  67692. * @see https://doc.babylonjs.com/babylon101/height_map
  67693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67694. */
  67695. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67696. width?: number;
  67697. height?: number;
  67698. subdivisions?: number;
  67699. minHeight?: number;
  67700. maxHeight?: number;
  67701. colorFilter?: Color3;
  67702. alphaFilter?: number;
  67703. updatable?: boolean;
  67704. onReady?: (mesh: GroundMesh) => void;
  67705. }, scene?: Nullable<Scene>): GroundMesh;
  67706. /**
  67707. * Creates a polygon mesh
  67708. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67709. * * 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
  67710. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67712. * * 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)
  67713. * * Remember you can only change the shape positions, not their number when updating a polygon
  67714. * @param name defines the name of the mesh
  67715. * @param options defines the options used to create the mesh
  67716. * @param scene defines the hosting scene
  67717. * @param earcutInjection can be used to inject your own earcut reference
  67718. * @returns the polygon mesh
  67719. */
  67720. static CreatePolygon(name: string, options: {
  67721. shape: Vector3[];
  67722. holes?: Vector3[][];
  67723. depth?: number;
  67724. faceUV?: Vector4[];
  67725. faceColors?: Color4[];
  67726. updatable?: boolean;
  67727. sideOrientation?: number;
  67728. frontUVs?: Vector4;
  67729. backUVs?: Vector4;
  67730. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67731. /**
  67732. * Creates an extruded polygon mesh, with depth in the Y direction.
  67733. * * 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)
  67734. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67735. * @param name defines the name of the mesh
  67736. * @param options defines the options used to create the mesh
  67737. * @param scene defines the hosting scene
  67738. * @param earcutInjection can be used to inject your own earcut reference
  67739. * @returns the polygon mesh
  67740. */
  67741. static ExtrudePolygon(name: string, options: {
  67742. shape: Vector3[];
  67743. holes?: Vector3[][];
  67744. depth?: number;
  67745. faceUV?: Vector4[];
  67746. faceColors?: Color4[];
  67747. updatable?: boolean;
  67748. sideOrientation?: number;
  67749. frontUVs?: Vector4;
  67750. backUVs?: Vector4;
  67751. wrap?: boolean;
  67752. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67753. /**
  67754. * Creates a tube mesh.
  67755. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67756. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67757. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67758. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67759. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67760. * * 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)
  67761. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67762. * * 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
  67763. * * 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
  67764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67765. * * 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
  67766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67768. * @param name defines the name of the mesh
  67769. * @param options defines the options used to create the mesh
  67770. * @param scene defines the hosting scene
  67771. * @returns the tube mesh
  67772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67773. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67774. */
  67775. static CreateTube(name: string, options: {
  67776. path: Vector3[];
  67777. radius?: number;
  67778. tessellation?: number;
  67779. radiusFunction?: {
  67780. (i: number, distance: number): number;
  67781. };
  67782. cap?: number;
  67783. arc?: number;
  67784. updatable?: boolean;
  67785. sideOrientation?: number;
  67786. frontUVs?: Vector4;
  67787. backUVs?: Vector4;
  67788. instance?: Mesh;
  67789. invertUV?: boolean;
  67790. }, scene?: Nullable<Scene>): Mesh;
  67791. /**
  67792. * Creates a polyhedron mesh
  67793. * * 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
  67794. * * The parameter `size` (positive float, default 1) sets the polygon size
  67795. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67796. * * 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`
  67797. * * 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
  67798. * * 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)`)
  67799. * * 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
  67800. * * 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
  67801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67802. * * 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
  67803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67804. * @param name defines the name of the mesh
  67805. * @param options defines the options used to create the mesh
  67806. * @param scene defines the hosting scene
  67807. * @returns the polyhedron mesh
  67808. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67809. */
  67810. static CreatePolyhedron(name: string, options: {
  67811. type?: number;
  67812. size?: number;
  67813. sizeX?: number;
  67814. sizeY?: number;
  67815. sizeZ?: number;
  67816. custom?: any;
  67817. faceUV?: Vector4[];
  67818. faceColors?: Color4[];
  67819. flat?: boolean;
  67820. updatable?: boolean;
  67821. sideOrientation?: number;
  67822. frontUVs?: Vector4;
  67823. backUVs?: Vector4;
  67824. }, scene?: Nullable<Scene>): Mesh;
  67825. /**
  67826. * Creates a decal mesh.
  67827. * 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
  67828. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67829. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67830. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67831. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67832. * @param name defines the name of the mesh
  67833. * @param sourceMesh defines the mesh where the decal must be applied
  67834. * @param options defines the options used to create the mesh
  67835. * @param scene defines the hosting scene
  67836. * @returns the decal mesh
  67837. * @see https://doc.babylonjs.com/how_to/decals
  67838. */
  67839. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67840. position?: Vector3;
  67841. normal?: Vector3;
  67842. size?: Vector3;
  67843. angle?: number;
  67844. }): Mesh;
  67845. /**
  67846. * Creates a Capsule Mesh
  67847. * @param name defines the name of the mesh.
  67848. * @param options the constructors options used to shape the mesh.
  67849. * @param scene defines the scene the mesh is scoped to.
  67850. * @returns the capsule mesh
  67851. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67852. */
  67853. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67854. }
  67855. }
  67856. declare module BABYLON {
  67857. /**
  67858. * A simplifier interface for future simplification implementations
  67859. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67860. */
  67861. export interface ISimplifier {
  67862. /**
  67863. * Simplification of a given mesh according to the given settings.
  67864. * Since this requires computation, it is assumed that the function runs async.
  67865. * @param settings The settings of the simplification, including quality and distance
  67866. * @param successCallback A callback that will be called after the mesh was simplified.
  67867. * @param errorCallback in case of an error, this callback will be called. optional.
  67868. */
  67869. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67870. }
  67871. /**
  67872. * Expected simplification settings.
  67873. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67874. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67875. */
  67876. export interface ISimplificationSettings {
  67877. /**
  67878. * Gets or sets the expected quality
  67879. */
  67880. quality: number;
  67881. /**
  67882. * Gets or sets the distance when this optimized version should be used
  67883. */
  67884. distance: number;
  67885. /**
  67886. * Gets an already optimized mesh
  67887. */
  67888. optimizeMesh?: boolean;
  67889. }
  67890. /**
  67891. * Class used to specify simplification options
  67892. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67893. */
  67894. export class SimplificationSettings implements ISimplificationSettings {
  67895. /** expected quality */
  67896. quality: number;
  67897. /** distance when this optimized version should be used */
  67898. distance: number;
  67899. /** already optimized mesh */
  67900. optimizeMesh?: boolean | undefined;
  67901. /**
  67902. * Creates a SimplificationSettings
  67903. * @param quality expected quality
  67904. * @param distance distance when this optimized version should be used
  67905. * @param optimizeMesh already optimized mesh
  67906. */
  67907. constructor(
  67908. /** expected quality */
  67909. quality: number,
  67910. /** distance when this optimized version should be used */
  67911. distance: number,
  67912. /** already optimized mesh */
  67913. optimizeMesh?: boolean | undefined);
  67914. }
  67915. /**
  67916. * Interface used to define a simplification task
  67917. */
  67918. export interface ISimplificationTask {
  67919. /**
  67920. * Array of settings
  67921. */
  67922. settings: Array<ISimplificationSettings>;
  67923. /**
  67924. * Simplification type
  67925. */
  67926. simplificationType: SimplificationType;
  67927. /**
  67928. * Mesh to simplify
  67929. */
  67930. mesh: Mesh;
  67931. /**
  67932. * Callback called on success
  67933. */
  67934. successCallback?: () => void;
  67935. /**
  67936. * Defines if parallel processing can be used
  67937. */
  67938. parallelProcessing: boolean;
  67939. }
  67940. /**
  67941. * Queue used to order the simplification tasks
  67942. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67943. */
  67944. export class SimplificationQueue {
  67945. private _simplificationArray;
  67946. /**
  67947. * Gets a boolean indicating that the process is still running
  67948. */
  67949. running: boolean;
  67950. /**
  67951. * Creates a new queue
  67952. */
  67953. constructor();
  67954. /**
  67955. * Adds a new simplification task
  67956. * @param task defines a task to add
  67957. */
  67958. addTask(task: ISimplificationTask): void;
  67959. /**
  67960. * Execute next task
  67961. */
  67962. executeNext(): void;
  67963. /**
  67964. * Execute a simplification task
  67965. * @param task defines the task to run
  67966. */
  67967. runSimplification(task: ISimplificationTask): void;
  67968. private getSimplifier;
  67969. }
  67970. /**
  67971. * The implemented types of simplification
  67972. * At the moment only Quadratic Error Decimation is implemented
  67973. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67974. */
  67975. export enum SimplificationType {
  67976. /** Quadratic error decimation */
  67977. QUADRATIC = 0
  67978. }
  67979. /**
  67980. * An implementation of the Quadratic Error simplification algorithm.
  67981. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67982. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67983. * @author RaananW
  67984. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67985. */
  67986. export class QuadraticErrorSimplification implements ISimplifier {
  67987. private _mesh;
  67988. private triangles;
  67989. private vertices;
  67990. private references;
  67991. private _reconstructedMesh;
  67992. /** Gets or sets the number pf sync interations */
  67993. syncIterations: number;
  67994. /** Gets or sets the aggressiveness of the simplifier */
  67995. aggressiveness: number;
  67996. /** Gets or sets the number of allowed iterations for decimation */
  67997. decimationIterations: number;
  67998. /** Gets or sets the espilon to use for bounding box computation */
  67999. boundingBoxEpsilon: number;
  68000. /**
  68001. * Creates a new QuadraticErrorSimplification
  68002. * @param _mesh defines the target mesh
  68003. */
  68004. constructor(_mesh: Mesh);
  68005. /**
  68006. * Simplification of a given mesh according to the given settings.
  68007. * Since this requires computation, it is assumed that the function runs async.
  68008. * @param settings The settings of the simplification, including quality and distance
  68009. * @param successCallback A callback that will be called after the mesh was simplified.
  68010. */
  68011. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68012. private runDecimation;
  68013. private initWithMesh;
  68014. private init;
  68015. private reconstructMesh;
  68016. private initDecimatedMesh;
  68017. private isFlipped;
  68018. private updateTriangles;
  68019. private identifyBorder;
  68020. private updateMesh;
  68021. private vertexError;
  68022. private calculateError;
  68023. }
  68024. }
  68025. declare module BABYLON {
  68026. interface Scene {
  68027. /** @hidden (Backing field) */
  68028. _simplificationQueue: SimplificationQueue;
  68029. /**
  68030. * Gets or sets the simplification queue attached to the scene
  68031. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68032. */
  68033. simplificationQueue: SimplificationQueue;
  68034. }
  68035. interface Mesh {
  68036. /**
  68037. * Simplify the mesh according to the given array of settings.
  68038. * Function will return immediately and will simplify async
  68039. * @param settings a collection of simplification settings
  68040. * @param parallelProcessing should all levels calculate parallel or one after the other
  68041. * @param simplificationType the type of simplification to run
  68042. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68043. * @returns the current mesh
  68044. */
  68045. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68046. }
  68047. /**
  68048. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68049. * created in a scene
  68050. */
  68051. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68052. /**
  68053. * The component name helpfull to identify the component in the list of scene components.
  68054. */
  68055. readonly name: string;
  68056. /**
  68057. * The scene the component belongs to.
  68058. */
  68059. scene: Scene;
  68060. /**
  68061. * Creates a new instance of the component for the given scene
  68062. * @param scene Defines the scene to register the component in
  68063. */
  68064. constructor(scene: Scene);
  68065. /**
  68066. * Registers the component in a given scene
  68067. */
  68068. register(): void;
  68069. /**
  68070. * Rebuilds the elements related to this component in case of
  68071. * context lost for instance.
  68072. */
  68073. rebuild(): void;
  68074. /**
  68075. * Disposes the component and the associated ressources
  68076. */
  68077. dispose(): void;
  68078. private _beforeCameraUpdate;
  68079. }
  68080. }
  68081. declare module BABYLON {
  68082. interface Mesh {
  68083. /**
  68084. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68085. */
  68086. thinInstanceEnablePicking: boolean;
  68087. /**
  68088. * Creates a new thin instance
  68089. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68090. * @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
  68091. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68092. */
  68093. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68094. /**
  68095. * Adds the transformation (matrix) of the current mesh as a thin instance
  68096. * @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
  68097. * @returns the thin instance index number
  68098. */
  68099. thinInstanceAddSelf(refresh: boolean): number;
  68100. /**
  68101. * Registers a custom attribute to be used with thin instances
  68102. * @param kind name of the attribute
  68103. * @param stride size in floats of the attribute
  68104. */
  68105. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68106. /**
  68107. * Sets the matrix of a thin instance
  68108. * @param index index of the thin instance
  68109. * @param matrix matrix to set
  68110. * @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
  68111. */
  68112. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68113. /**
  68114. * Sets the value of a custom attribute for a thin instance
  68115. * @param kind name of the attribute
  68116. * @param index index of the thin instance
  68117. * @param value value to set
  68118. * @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
  68119. */
  68120. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68121. /**
  68122. * 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.
  68123. */
  68124. thinInstanceCount: number;
  68125. /**
  68126. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68127. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68128. * @param buffer buffer to set
  68129. * @param stride size in floats of each value of the buffer
  68130. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68131. */
  68132. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68133. /**
  68134. * Gets the list of world matrices
  68135. * @return an array containing all the world matrices from the thin instances
  68136. */
  68137. thinInstanceGetWorldMatrices(): Matrix[];
  68138. /**
  68139. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68140. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68141. */
  68142. thinInstanceBufferUpdated(kind: string): void;
  68143. /**
  68144. * Applies a partial update to a buffer directly on the GPU
  68145. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  68146. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68147. * @param data the data to set in the GPU buffer
  68148. * @param offset the offset in the GPU buffer where to update the data
  68149. */
  68150. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68151. /**
  68152. * Refreshes the bounding info, taking into account all the thin instances defined
  68153. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68154. */
  68155. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68156. /** @hidden */
  68157. _thinInstanceInitializeUserStorage(): void;
  68158. /** @hidden */
  68159. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68160. /** @hidden */
  68161. _userThinInstanceBuffersStorage: {
  68162. data: {
  68163. [key: string]: Float32Array;
  68164. };
  68165. sizes: {
  68166. [key: string]: number;
  68167. };
  68168. vertexBuffers: {
  68169. [key: string]: Nullable<VertexBuffer>;
  68170. };
  68171. strides: {
  68172. [key: string]: number;
  68173. };
  68174. };
  68175. }
  68176. }
  68177. declare module BABYLON {
  68178. /**
  68179. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68180. */
  68181. export interface INavigationEnginePlugin {
  68182. /**
  68183. * plugin name
  68184. */
  68185. name: string;
  68186. /**
  68187. * Creates a navigation mesh
  68188. * @param meshes array of all the geometry used to compute the navigatio mesh
  68189. * @param parameters bunch of parameters used to filter geometry
  68190. */
  68191. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68192. /**
  68193. * Create a navigation mesh debug mesh
  68194. * @param scene is where the mesh will be added
  68195. * @returns debug display mesh
  68196. */
  68197. createDebugNavMesh(scene: Scene): Mesh;
  68198. /**
  68199. * Get a navigation mesh constrained position, closest to the parameter position
  68200. * @param position world position
  68201. * @returns the closest point to position constrained by the navigation mesh
  68202. */
  68203. getClosestPoint(position: Vector3): Vector3;
  68204. /**
  68205. * Get a navigation mesh constrained position, closest to the parameter position
  68206. * @param position world position
  68207. * @param result output the closest point to position constrained by the navigation mesh
  68208. */
  68209. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68210. /**
  68211. * Get a navigation mesh constrained position, within a particular radius
  68212. * @param position world position
  68213. * @param maxRadius the maximum distance to the constrained world position
  68214. * @returns the closest point to position constrained by the navigation mesh
  68215. */
  68216. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68217. /**
  68218. * Get a navigation mesh constrained position, within a particular radius
  68219. * @param position world position
  68220. * @param maxRadius the maximum distance to the constrained world position
  68221. * @param result output the closest point to position constrained by the navigation mesh
  68222. */
  68223. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68224. /**
  68225. * Compute the final position from a segment made of destination-position
  68226. * @param position world position
  68227. * @param destination world position
  68228. * @returns the resulting point along the navmesh
  68229. */
  68230. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68231. /**
  68232. * Compute the final position from a segment made of destination-position
  68233. * @param position world position
  68234. * @param destination world position
  68235. * @param result output the resulting point along the navmesh
  68236. */
  68237. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68238. /**
  68239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68240. * @param start world position
  68241. * @param end world position
  68242. * @returns array containing world position composing the path
  68243. */
  68244. computePath(start: Vector3, end: Vector3): Vector3[];
  68245. /**
  68246. * If this plugin is supported
  68247. * @returns true if plugin is supported
  68248. */
  68249. isSupported(): boolean;
  68250. /**
  68251. * Create a new Crowd so you can add agents
  68252. * @param maxAgents the maximum agent count in the crowd
  68253. * @param maxAgentRadius the maximum radius an agent can have
  68254. * @param scene to attach the crowd to
  68255. * @returns the crowd you can add agents to
  68256. */
  68257. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68258. /**
  68259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68260. * The queries will try to find a solution within those bounds
  68261. * default is (1,1,1)
  68262. * @param extent x,y,z value that define the extent around the queries point of reference
  68263. */
  68264. setDefaultQueryExtent(extent: Vector3): void;
  68265. /**
  68266. * Get the Bounding box extent specified by setDefaultQueryExtent
  68267. * @returns the box extent values
  68268. */
  68269. getDefaultQueryExtent(): Vector3;
  68270. /**
  68271. * build the navmesh from a previously saved state using getNavmeshData
  68272. * @param data the Uint8Array returned by getNavmeshData
  68273. */
  68274. buildFromNavmeshData(data: Uint8Array): void;
  68275. /**
  68276. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68277. * @returns data the Uint8Array that can be saved and reused
  68278. */
  68279. getNavmeshData(): Uint8Array;
  68280. /**
  68281. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68282. * @param result output the box extent values
  68283. */
  68284. getDefaultQueryExtentToRef(result: Vector3): void;
  68285. /**
  68286. * Set the time step of the navigation tick update.
  68287. * Default is 1/60.
  68288. * A value of 0 will disable fixed time update
  68289. * @param newTimeStep the new timestep to apply to this world.
  68290. */
  68291. setTimeStep(newTimeStep: number): void;
  68292. /**
  68293. * Get the time step of the navigation tick update.
  68294. * @returns the current time step
  68295. */
  68296. getTimeStep(): number;
  68297. /**
  68298. * If delta time in navigation tick update is greater than the time step
  68299. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68300. * they will be discarded.
  68301. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68302. * @param newStepCount the maximum number of iterations
  68303. */
  68304. setMaximumSubStepCount(newStepCount: number): void;
  68305. /**
  68306. * Get the maximum number of iterations per navigation tick update
  68307. * @returns the maximum number of iterations
  68308. */
  68309. getMaximumSubStepCount(): number;
  68310. /**
  68311. * Release all resources
  68312. */
  68313. dispose(): void;
  68314. }
  68315. /**
  68316. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68317. */
  68318. export interface ICrowd {
  68319. /**
  68320. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68321. * You can attach anything to that node. The node position is updated in the scene update tick.
  68322. * @param pos world position that will be constrained by the navigation mesh
  68323. * @param parameters agent parameters
  68324. * @param transform hooked to the agent that will be update by the scene
  68325. * @returns agent index
  68326. */
  68327. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68328. /**
  68329. * Returns the agent position in world space
  68330. * @param index agent index returned by addAgent
  68331. * @returns world space position
  68332. */
  68333. getAgentPosition(index: number): Vector3;
  68334. /**
  68335. * Gets the agent position result in world space
  68336. * @param index agent index returned by addAgent
  68337. * @param result output world space position
  68338. */
  68339. getAgentPositionToRef(index: number, result: Vector3): void;
  68340. /**
  68341. * Gets the agent velocity in world space
  68342. * @param index agent index returned by addAgent
  68343. * @returns world space velocity
  68344. */
  68345. getAgentVelocity(index: number): Vector3;
  68346. /**
  68347. * Gets the agent velocity result in world space
  68348. * @param index agent index returned by addAgent
  68349. * @param result output world space velocity
  68350. */
  68351. getAgentVelocityToRef(index: number, result: Vector3): void;
  68352. /**
  68353. * Gets the agent next target point on the path
  68354. * @param index agent index returned by addAgent
  68355. * @returns world space position
  68356. */
  68357. getAgentNextTargetPath(index: number): Vector3;
  68358. /**
  68359. * Gets the agent state
  68360. * @param index agent index returned by addAgent
  68361. * @returns agent state
  68362. */
  68363. getAgentState(index: number): number;
  68364. /**
  68365. * returns true if the agent in over an off mesh link connection
  68366. * @param index agent index returned by addAgent
  68367. * @returns true if over an off mesh link connection
  68368. */
  68369. overOffmeshConnection(index: number): boolean;
  68370. /**
  68371. * Gets the agent next target point on the path
  68372. * @param index agent index returned by addAgent
  68373. * @param result output world space position
  68374. */
  68375. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68376. /**
  68377. * remove a particular agent previously created
  68378. * @param index agent index returned by addAgent
  68379. */
  68380. removeAgent(index: number): void;
  68381. /**
  68382. * get the list of all agents attached to this crowd
  68383. * @returns list of agent indices
  68384. */
  68385. getAgents(): number[];
  68386. /**
  68387. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68388. * @param deltaTime in seconds
  68389. */
  68390. update(deltaTime: number): void;
  68391. /**
  68392. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68393. * @param index agent index returned by addAgent
  68394. * @param destination targeted world position
  68395. */
  68396. agentGoto(index: number, destination: Vector3): void;
  68397. /**
  68398. * Teleport the agent to a new position
  68399. * @param index agent index returned by addAgent
  68400. * @param destination targeted world position
  68401. */
  68402. agentTeleport(index: number, destination: Vector3): void;
  68403. /**
  68404. * Update agent parameters
  68405. * @param index agent index returned by addAgent
  68406. * @param parameters agent parameters
  68407. */
  68408. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68409. /**
  68410. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68411. * The queries will try to find a solution within those bounds
  68412. * default is (1,1,1)
  68413. * @param extent x,y,z value that define the extent around the queries point of reference
  68414. */
  68415. setDefaultQueryExtent(extent: Vector3): void;
  68416. /**
  68417. * Get the Bounding box extent specified by setDefaultQueryExtent
  68418. * @returns the box extent values
  68419. */
  68420. getDefaultQueryExtent(): Vector3;
  68421. /**
  68422. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68423. * @param result output the box extent values
  68424. */
  68425. getDefaultQueryExtentToRef(result: Vector3): void;
  68426. /**
  68427. * Release all resources
  68428. */
  68429. dispose(): void;
  68430. }
  68431. /**
  68432. * Configures an agent
  68433. */
  68434. export interface IAgentParameters {
  68435. /**
  68436. * Agent radius. [Limit: >= 0]
  68437. */
  68438. radius: number;
  68439. /**
  68440. * Agent height. [Limit: > 0]
  68441. */
  68442. height: number;
  68443. /**
  68444. * Maximum allowed acceleration. [Limit: >= 0]
  68445. */
  68446. maxAcceleration: number;
  68447. /**
  68448. * Maximum allowed speed. [Limit: >= 0]
  68449. */
  68450. maxSpeed: number;
  68451. /**
  68452. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68453. */
  68454. collisionQueryRange: number;
  68455. /**
  68456. * The path visibility optimization range. [Limit: > 0]
  68457. */
  68458. pathOptimizationRange: number;
  68459. /**
  68460. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68461. */
  68462. separationWeight: number;
  68463. }
  68464. /**
  68465. * Configures the navigation mesh creation
  68466. */
  68467. export interface INavMeshParameters {
  68468. /**
  68469. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68470. */
  68471. cs: number;
  68472. /**
  68473. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68474. */
  68475. ch: number;
  68476. /**
  68477. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68478. */
  68479. walkableSlopeAngle: number;
  68480. /**
  68481. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68482. * be considered walkable. [Limit: >= 3] [Units: vx]
  68483. */
  68484. walkableHeight: number;
  68485. /**
  68486. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68487. */
  68488. walkableClimb: number;
  68489. /**
  68490. * The distance to erode/shrink the walkable area of the heightfield away from
  68491. * obstructions. [Limit: >=0] [Units: vx]
  68492. */
  68493. walkableRadius: number;
  68494. /**
  68495. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68496. */
  68497. maxEdgeLen: number;
  68498. /**
  68499. * The maximum distance a simplfied contour's border edges should deviate
  68500. * the original raw contour. [Limit: >=0] [Units: vx]
  68501. */
  68502. maxSimplificationError: number;
  68503. /**
  68504. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68505. */
  68506. minRegionArea: number;
  68507. /**
  68508. * Any regions with a span count smaller than this value will, if possible,
  68509. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68510. */
  68511. mergeRegionArea: number;
  68512. /**
  68513. * The maximum number of vertices allowed for polygons generated during the
  68514. * contour to polygon conversion process. [Limit: >= 3]
  68515. */
  68516. maxVertsPerPoly: number;
  68517. /**
  68518. * Sets the sampling distance to use when generating the detail mesh.
  68519. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68520. */
  68521. detailSampleDist: number;
  68522. /**
  68523. * The maximum distance the detail mesh surface should deviate from heightfield
  68524. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68525. */
  68526. detailSampleMaxError: number;
  68527. }
  68528. }
  68529. declare module BABYLON {
  68530. /**
  68531. * RecastJS navigation plugin
  68532. */
  68533. export class RecastJSPlugin implements INavigationEnginePlugin {
  68534. /**
  68535. * Reference to the Recast library
  68536. */
  68537. bjsRECAST: any;
  68538. /**
  68539. * plugin name
  68540. */
  68541. name: string;
  68542. /**
  68543. * the first navmesh created. We might extend this to support multiple navmeshes
  68544. */
  68545. navMesh: any;
  68546. private _maximumSubStepCount;
  68547. private _timeStep;
  68548. /**
  68549. * Initializes the recastJS plugin
  68550. * @param recastInjection can be used to inject your own recast reference
  68551. */
  68552. constructor(recastInjection?: any);
  68553. /**
  68554. * Set the time step of the navigation tick update.
  68555. * Default is 1/60.
  68556. * A value of 0 will disable fixed time update
  68557. * @param newTimeStep the new timestep to apply to this world.
  68558. */
  68559. setTimeStep(newTimeStep?: number): void;
  68560. /**
  68561. * Get the time step of the navigation tick update.
  68562. * @returns the current time step
  68563. */
  68564. getTimeStep(): number;
  68565. /**
  68566. * If delta time in navigation tick update is greater than the time step
  68567. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68568. * they will be discarded.
  68569. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68570. * @param newStepCount the maximum number of iterations
  68571. */
  68572. setMaximumSubStepCount(newStepCount?: number): void;
  68573. /**
  68574. * Get the maximum number of iterations per navigation tick update
  68575. * @returns the maximum number of iterations
  68576. */
  68577. getMaximumSubStepCount(): number;
  68578. /**
  68579. * Creates a navigation mesh
  68580. * @param meshes array of all the geometry used to compute the navigatio mesh
  68581. * @param parameters bunch of parameters used to filter geometry
  68582. */
  68583. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68584. /**
  68585. * Create a navigation mesh debug mesh
  68586. * @param scene is where the mesh will be added
  68587. * @returns debug display mesh
  68588. */
  68589. createDebugNavMesh(scene: Scene): Mesh;
  68590. /**
  68591. * Get a navigation mesh constrained position, closest to the parameter position
  68592. * @param position world position
  68593. * @returns the closest point to position constrained by the navigation mesh
  68594. */
  68595. getClosestPoint(position: Vector3): Vector3;
  68596. /**
  68597. * Get a navigation mesh constrained position, closest to the parameter position
  68598. * @param position world position
  68599. * @param result output the closest point to position constrained by the navigation mesh
  68600. */
  68601. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68602. /**
  68603. * Get a navigation mesh constrained position, within a particular radius
  68604. * @param position world position
  68605. * @param maxRadius the maximum distance to the constrained world position
  68606. * @returns the closest point to position constrained by the navigation mesh
  68607. */
  68608. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68609. /**
  68610. * Get a navigation mesh constrained position, within a particular radius
  68611. * @param position world position
  68612. * @param maxRadius the maximum distance to the constrained world position
  68613. * @param result output the closest point to position constrained by the navigation mesh
  68614. */
  68615. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68616. /**
  68617. * Compute the final position from a segment made of destination-position
  68618. * @param position world position
  68619. * @param destination world position
  68620. * @returns the resulting point along the navmesh
  68621. */
  68622. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68623. /**
  68624. * Compute the final position from a segment made of destination-position
  68625. * @param position world position
  68626. * @param destination world position
  68627. * @param result output the resulting point along the navmesh
  68628. */
  68629. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68630. /**
  68631. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68632. * @param start world position
  68633. * @param end world position
  68634. * @returns array containing world position composing the path
  68635. */
  68636. computePath(start: Vector3, end: Vector3): Vector3[];
  68637. /**
  68638. * Create a new Crowd so you can add agents
  68639. * @param maxAgents the maximum agent count in the crowd
  68640. * @param maxAgentRadius the maximum radius an agent can have
  68641. * @param scene to attach the crowd to
  68642. * @returns the crowd you can add agents to
  68643. */
  68644. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68645. /**
  68646. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68647. * The queries will try to find a solution within those bounds
  68648. * default is (1,1,1)
  68649. * @param extent x,y,z value that define the extent around the queries point of reference
  68650. */
  68651. setDefaultQueryExtent(extent: Vector3): void;
  68652. /**
  68653. * Get the Bounding box extent specified by setDefaultQueryExtent
  68654. * @returns the box extent values
  68655. */
  68656. getDefaultQueryExtent(): Vector3;
  68657. /**
  68658. * build the navmesh from a previously saved state using getNavmeshData
  68659. * @param data the Uint8Array returned by getNavmeshData
  68660. */
  68661. buildFromNavmeshData(data: Uint8Array): void;
  68662. /**
  68663. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68664. * @returns data the Uint8Array that can be saved and reused
  68665. */
  68666. getNavmeshData(): Uint8Array;
  68667. /**
  68668. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68669. * @param result output the box extent values
  68670. */
  68671. getDefaultQueryExtentToRef(result: Vector3): void;
  68672. /**
  68673. * Disposes
  68674. */
  68675. dispose(): void;
  68676. /**
  68677. * If this plugin is supported
  68678. * @returns true if plugin is supported
  68679. */
  68680. isSupported(): boolean;
  68681. }
  68682. /**
  68683. * Recast detour crowd implementation
  68684. */
  68685. export class RecastJSCrowd implements ICrowd {
  68686. /**
  68687. * Recast/detour plugin
  68688. */
  68689. bjsRECASTPlugin: RecastJSPlugin;
  68690. /**
  68691. * Link to the detour crowd
  68692. */
  68693. recastCrowd: any;
  68694. /**
  68695. * One transform per agent
  68696. */
  68697. transforms: TransformNode[];
  68698. /**
  68699. * All agents created
  68700. */
  68701. agents: number[];
  68702. /**
  68703. * Link to the scene is kept to unregister the crowd from the scene
  68704. */
  68705. private _scene;
  68706. /**
  68707. * Observer for crowd updates
  68708. */
  68709. private _onBeforeAnimationsObserver;
  68710. /**
  68711. * Constructor
  68712. * @param plugin recastJS plugin
  68713. * @param maxAgents the maximum agent count in the crowd
  68714. * @param maxAgentRadius the maximum radius an agent can have
  68715. * @param scene to attach the crowd to
  68716. * @returns the crowd you can add agents to
  68717. */
  68718. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68719. /**
  68720. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68721. * You can attach anything to that node. The node position is updated in the scene update tick.
  68722. * @param pos world position that will be constrained by the navigation mesh
  68723. * @param parameters agent parameters
  68724. * @param transform hooked to the agent that will be update by the scene
  68725. * @returns agent index
  68726. */
  68727. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68728. /**
  68729. * Returns the agent position in world space
  68730. * @param index agent index returned by addAgent
  68731. * @returns world space position
  68732. */
  68733. getAgentPosition(index: number): Vector3;
  68734. /**
  68735. * Returns the agent position result in world space
  68736. * @param index agent index returned by addAgent
  68737. * @param result output world space position
  68738. */
  68739. getAgentPositionToRef(index: number, result: Vector3): void;
  68740. /**
  68741. * Returns the agent velocity in world space
  68742. * @param index agent index returned by addAgent
  68743. * @returns world space velocity
  68744. */
  68745. getAgentVelocity(index: number): Vector3;
  68746. /**
  68747. * Returns the agent velocity result in world space
  68748. * @param index agent index returned by addAgent
  68749. * @param result output world space velocity
  68750. */
  68751. getAgentVelocityToRef(index: number, result: Vector3): void;
  68752. /**
  68753. * Returns the agent next target point on the path
  68754. * @param index agent index returned by addAgent
  68755. * @returns world space position
  68756. */
  68757. getAgentNextTargetPath(index: number): Vector3;
  68758. /**
  68759. * Returns the agent next target point on the path
  68760. * @param index agent index returned by addAgent
  68761. * @param result output world space position
  68762. */
  68763. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68764. /**
  68765. * Gets the agent state
  68766. * @param index agent index returned by addAgent
  68767. * @returns agent state
  68768. */
  68769. getAgentState(index: number): number;
  68770. /**
  68771. * returns true if the agent in over an off mesh link connection
  68772. * @param index agent index returned by addAgent
  68773. * @returns true if over an off mesh link connection
  68774. */
  68775. overOffmeshConnection(index: number): boolean;
  68776. /**
  68777. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68778. * @param index agent index returned by addAgent
  68779. * @param destination targeted world position
  68780. */
  68781. agentGoto(index: number, destination: Vector3): void;
  68782. /**
  68783. * Teleport the agent to a new position
  68784. * @param index agent index returned by addAgent
  68785. * @param destination targeted world position
  68786. */
  68787. agentTeleport(index: number, destination: Vector3): void;
  68788. /**
  68789. * Update agent parameters
  68790. * @param index agent index returned by addAgent
  68791. * @param parameters agent parameters
  68792. */
  68793. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68794. /**
  68795. * remove a particular agent previously created
  68796. * @param index agent index returned by addAgent
  68797. */
  68798. removeAgent(index: number): void;
  68799. /**
  68800. * get the list of all agents attached to this crowd
  68801. * @returns list of agent indices
  68802. */
  68803. getAgents(): number[];
  68804. /**
  68805. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68806. * @param deltaTime in seconds
  68807. */
  68808. update(deltaTime: number): void;
  68809. /**
  68810. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68811. * The queries will try to find a solution within those bounds
  68812. * default is (1,1,1)
  68813. * @param extent x,y,z value that define the extent around the queries point of reference
  68814. */
  68815. setDefaultQueryExtent(extent: Vector3): void;
  68816. /**
  68817. * Get the Bounding box extent specified by setDefaultQueryExtent
  68818. * @returns the box extent values
  68819. */
  68820. getDefaultQueryExtent(): Vector3;
  68821. /**
  68822. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68823. * @param result output the box extent values
  68824. */
  68825. getDefaultQueryExtentToRef(result: Vector3): void;
  68826. /**
  68827. * Release all resources
  68828. */
  68829. dispose(): void;
  68830. }
  68831. }
  68832. declare module BABYLON {
  68833. /**
  68834. * Class used to enable access to IndexedDB
  68835. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68836. */
  68837. export class Database implements IOfflineProvider {
  68838. private _callbackManifestChecked;
  68839. private _currentSceneUrl;
  68840. private _db;
  68841. private _enableSceneOffline;
  68842. private _enableTexturesOffline;
  68843. private _manifestVersionFound;
  68844. private _mustUpdateRessources;
  68845. private _hasReachedQuota;
  68846. private _isSupported;
  68847. private _idbFactory;
  68848. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68849. private static IsUASupportingBlobStorage;
  68850. /**
  68851. * Gets a boolean indicating if Database storate is enabled (off by default)
  68852. */
  68853. static IDBStorageEnabled: boolean;
  68854. /**
  68855. * Gets a boolean indicating if scene must be saved in the database
  68856. */
  68857. get enableSceneOffline(): boolean;
  68858. /**
  68859. * Gets a boolean indicating if textures must be saved in the database
  68860. */
  68861. get enableTexturesOffline(): boolean;
  68862. /**
  68863. * Creates a new Database
  68864. * @param urlToScene defines the url to load the scene
  68865. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68866. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68867. */
  68868. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68869. private static _ParseURL;
  68870. private static _ReturnFullUrlLocation;
  68871. private _checkManifestFile;
  68872. /**
  68873. * Open the database and make it available
  68874. * @param successCallback defines the callback to call on success
  68875. * @param errorCallback defines the callback to call on error
  68876. */
  68877. open(successCallback: () => void, errorCallback: () => void): void;
  68878. /**
  68879. * Loads an image from the database
  68880. * @param url defines the url to load from
  68881. * @param image defines the target DOM image
  68882. */
  68883. loadImage(url: string, image: HTMLImageElement): void;
  68884. private _loadImageFromDBAsync;
  68885. private _saveImageIntoDBAsync;
  68886. private _checkVersionFromDB;
  68887. private _loadVersionFromDBAsync;
  68888. private _saveVersionIntoDBAsync;
  68889. /**
  68890. * Loads a file from database
  68891. * @param url defines the URL to load from
  68892. * @param sceneLoaded defines a callback to call on success
  68893. * @param progressCallBack defines a callback to call when progress changed
  68894. * @param errorCallback defines a callback to call on error
  68895. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68896. */
  68897. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68898. private _loadFileAsync;
  68899. private _saveFileAsync;
  68900. /**
  68901. * Validates if xhr data is correct
  68902. * @param xhr defines the request to validate
  68903. * @param dataType defines the expected data type
  68904. * @returns true if data is correct
  68905. */
  68906. private static _ValidateXHRData;
  68907. }
  68908. }
  68909. declare module BABYLON {
  68910. /** @hidden */
  68911. export var gpuUpdateParticlesPixelShader: {
  68912. name: string;
  68913. shader: string;
  68914. };
  68915. }
  68916. declare module BABYLON {
  68917. /** @hidden */
  68918. export var gpuUpdateParticlesVertexShader: {
  68919. name: string;
  68920. shader: string;
  68921. };
  68922. }
  68923. declare module BABYLON {
  68924. /** @hidden */
  68925. export var clipPlaneFragmentDeclaration2: {
  68926. name: string;
  68927. shader: string;
  68928. };
  68929. }
  68930. declare module BABYLON {
  68931. /** @hidden */
  68932. export var gpuRenderParticlesPixelShader: {
  68933. name: string;
  68934. shader: string;
  68935. };
  68936. }
  68937. declare module BABYLON {
  68938. /** @hidden */
  68939. export var clipPlaneVertexDeclaration2: {
  68940. name: string;
  68941. shader: string;
  68942. };
  68943. }
  68944. declare module BABYLON {
  68945. /** @hidden */
  68946. export var gpuRenderParticlesVertexShader: {
  68947. name: string;
  68948. shader: string;
  68949. };
  68950. }
  68951. declare module BABYLON {
  68952. /**
  68953. * This represents a GPU particle system in Babylon
  68954. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68955. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68956. */
  68957. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68958. /**
  68959. * The layer mask we are rendering the particles through.
  68960. */
  68961. layerMask: number;
  68962. private _capacity;
  68963. private _activeCount;
  68964. private _currentActiveCount;
  68965. private _accumulatedCount;
  68966. private _renderEffect;
  68967. private _updateEffect;
  68968. private _buffer0;
  68969. private _buffer1;
  68970. private _spriteBuffer;
  68971. private _updateVAO;
  68972. private _renderVAO;
  68973. private _targetIndex;
  68974. private _sourceBuffer;
  68975. private _targetBuffer;
  68976. private _currentRenderId;
  68977. private _started;
  68978. private _stopped;
  68979. private _timeDelta;
  68980. private _randomTexture;
  68981. private _randomTexture2;
  68982. private _attributesStrideSize;
  68983. private _updateEffectOptions;
  68984. private _randomTextureSize;
  68985. private _actualFrame;
  68986. private _customEffect;
  68987. private readonly _rawTextureWidth;
  68988. /**
  68989. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68990. */
  68991. static get IsSupported(): boolean;
  68992. /**
  68993. * An event triggered when the system is disposed.
  68994. */
  68995. onDisposeObservable: Observable<IParticleSystem>;
  68996. /**
  68997. * An event triggered when the system is stopped
  68998. */
  68999. onStoppedObservable: Observable<IParticleSystem>;
  69000. /**
  69001. * Gets the maximum number of particles active at the same time.
  69002. * @returns The max number of active particles.
  69003. */
  69004. getCapacity(): number;
  69005. /**
  69006. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69007. * to override the particles.
  69008. */
  69009. forceDepthWrite: boolean;
  69010. /**
  69011. * Gets or set the number of active particles
  69012. */
  69013. get activeParticleCount(): number;
  69014. set activeParticleCount(value: number);
  69015. private _preWarmDone;
  69016. /**
  69017. * Specifies if the particles are updated in emitter local space or world space.
  69018. */
  69019. isLocal: boolean;
  69020. /** Gets or sets a matrix to use to compute projection */
  69021. defaultProjectionMatrix: Matrix;
  69022. /**
  69023. * Is this system ready to be used/rendered
  69024. * @return true if the system is ready
  69025. */
  69026. isReady(): boolean;
  69027. /**
  69028. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69029. * @returns True if it has been started, otherwise false.
  69030. */
  69031. isStarted(): boolean;
  69032. /**
  69033. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69034. * @returns True if it has been stopped, otherwise false.
  69035. */
  69036. isStopped(): boolean;
  69037. /**
  69038. * Gets a boolean indicating that the system is stopping
  69039. * @returns true if the system is currently stopping
  69040. */
  69041. isStopping(): boolean;
  69042. /**
  69043. * Gets the number of particles active at the same time.
  69044. * @returns The number of active particles.
  69045. */
  69046. getActiveCount(): number;
  69047. /**
  69048. * Starts the particle system and begins to emit
  69049. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69050. */
  69051. start(delay?: number): void;
  69052. /**
  69053. * Stops the particle system.
  69054. */
  69055. stop(): void;
  69056. /**
  69057. * Remove all active particles
  69058. */
  69059. reset(): void;
  69060. /**
  69061. * Returns the string "GPUParticleSystem"
  69062. * @returns a string containing the class name
  69063. */
  69064. getClassName(): string;
  69065. /**
  69066. * Gets the custom effect used to render the particles
  69067. * @param blendMode Blend mode for which the effect should be retrieved
  69068. * @returns The effect
  69069. */
  69070. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69071. /**
  69072. * Sets the custom effect used to render the particles
  69073. * @param effect The effect to set
  69074. * @param blendMode Blend mode for which the effect should be set
  69075. */
  69076. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69077. /** @hidden */
  69078. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69079. /**
  69080. * Observable that will be called just before the particles are drawn
  69081. */
  69082. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69083. /**
  69084. * Gets the name of the particle vertex shader
  69085. */
  69086. get vertexShaderName(): string;
  69087. private _colorGradientsTexture;
  69088. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69089. /**
  69090. * Adds a new color gradient
  69091. * @param gradient defines the gradient to use (between 0 and 1)
  69092. * @param color1 defines the color to affect to the specified gradient
  69093. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69094. * @returns the current particle system
  69095. */
  69096. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69097. private _refreshColorGradient;
  69098. /** Force the system to rebuild all gradients that need to be resync */
  69099. forceRefreshGradients(): void;
  69100. /**
  69101. * Remove a specific color gradient
  69102. * @param gradient defines the gradient to remove
  69103. * @returns the current particle system
  69104. */
  69105. removeColorGradient(gradient: number): GPUParticleSystem;
  69106. private _angularSpeedGradientsTexture;
  69107. private _sizeGradientsTexture;
  69108. private _velocityGradientsTexture;
  69109. private _limitVelocityGradientsTexture;
  69110. private _dragGradientsTexture;
  69111. private _addFactorGradient;
  69112. /**
  69113. * Adds a new size gradient
  69114. * @param gradient defines the gradient to use (between 0 and 1)
  69115. * @param factor defines the size factor to affect to the specified gradient
  69116. * @returns the current particle system
  69117. */
  69118. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69119. /**
  69120. * Remove a specific size gradient
  69121. * @param gradient defines the gradient to remove
  69122. * @returns the current particle system
  69123. */
  69124. removeSizeGradient(gradient: number): GPUParticleSystem;
  69125. private _refreshFactorGradient;
  69126. /**
  69127. * Adds a new angular speed gradient
  69128. * @param gradient defines the gradient to use (between 0 and 1)
  69129. * @param factor defines the angular speed to affect to the specified gradient
  69130. * @returns the current particle system
  69131. */
  69132. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69133. /**
  69134. * Remove a specific angular speed gradient
  69135. * @param gradient defines the gradient to remove
  69136. * @returns the current particle system
  69137. */
  69138. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69139. /**
  69140. * Adds a new velocity gradient
  69141. * @param gradient defines the gradient to use (between 0 and 1)
  69142. * @param factor defines the velocity to affect to the specified gradient
  69143. * @returns the current particle system
  69144. */
  69145. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69146. /**
  69147. * Remove a specific velocity gradient
  69148. * @param gradient defines the gradient to remove
  69149. * @returns the current particle system
  69150. */
  69151. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69152. /**
  69153. * Adds a new limit velocity gradient
  69154. * @param gradient defines the gradient to use (between 0 and 1)
  69155. * @param factor defines the limit velocity value to affect to the specified gradient
  69156. * @returns the current particle system
  69157. */
  69158. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69159. /**
  69160. * Remove a specific limit velocity gradient
  69161. * @param gradient defines the gradient to remove
  69162. * @returns the current particle system
  69163. */
  69164. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69165. /**
  69166. * Adds a new drag gradient
  69167. * @param gradient defines the gradient to use (between 0 and 1)
  69168. * @param factor defines the drag value to affect to the specified gradient
  69169. * @returns the current particle system
  69170. */
  69171. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69172. /**
  69173. * Remove a specific drag gradient
  69174. * @param gradient defines the gradient to remove
  69175. * @returns the current particle system
  69176. */
  69177. removeDragGradient(gradient: number): GPUParticleSystem;
  69178. /**
  69179. * Not supported by GPUParticleSystem
  69180. * @param gradient defines the gradient to use (between 0 and 1)
  69181. * @param factor defines the emit rate value to affect to the specified gradient
  69182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69183. * @returns the current particle system
  69184. */
  69185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69186. /**
  69187. * Not supported by GPUParticleSystem
  69188. * @param gradient defines the gradient to remove
  69189. * @returns the current particle system
  69190. */
  69191. removeEmitRateGradient(gradient: number): IParticleSystem;
  69192. /**
  69193. * Not supported by GPUParticleSystem
  69194. * @param gradient defines the gradient to use (between 0 and 1)
  69195. * @param factor defines the start size value to affect to the specified gradient
  69196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69197. * @returns the current particle system
  69198. */
  69199. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69200. /**
  69201. * Not supported by GPUParticleSystem
  69202. * @param gradient defines the gradient to remove
  69203. * @returns the current particle system
  69204. */
  69205. removeStartSizeGradient(gradient: number): IParticleSystem;
  69206. /**
  69207. * Not supported by GPUParticleSystem
  69208. * @param gradient defines the gradient to use (between 0 and 1)
  69209. * @param min defines the color remap minimal range
  69210. * @param max defines the color remap maximal range
  69211. * @returns the current particle system
  69212. */
  69213. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69214. /**
  69215. * Not supported by GPUParticleSystem
  69216. * @param gradient defines the gradient to remove
  69217. * @returns the current particle system
  69218. */
  69219. removeColorRemapGradient(): IParticleSystem;
  69220. /**
  69221. * Not supported by GPUParticleSystem
  69222. * @param gradient defines the gradient to use (between 0 and 1)
  69223. * @param min defines the alpha remap minimal range
  69224. * @param max defines the alpha remap maximal range
  69225. * @returns the current particle system
  69226. */
  69227. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69228. /**
  69229. * Not supported by GPUParticleSystem
  69230. * @param gradient defines the gradient to remove
  69231. * @returns the current particle system
  69232. */
  69233. removeAlphaRemapGradient(): IParticleSystem;
  69234. /**
  69235. * Not supported by GPUParticleSystem
  69236. * @param gradient defines the gradient to use (between 0 and 1)
  69237. * @param color defines the color to affect to the specified gradient
  69238. * @returns the current particle system
  69239. */
  69240. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69241. /**
  69242. * Not supported by GPUParticleSystem
  69243. * @param gradient defines the gradient to remove
  69244. * @returns the current particle system
  69245. */
  69246. removeRampGradient(): IParticleSystem;
  69247. /**
  69248. * Not supported by GPUParticleSystem
  69249. * @returns the list of ramp gradients
  69250. */
  69251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69252. /**
  69253. * Not supported by GPUParticleSystem
  69254. * Gets or sets a boolean indicating that ramp gradients must be used
  69255. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69256. */
  69257. get useRampGradients(): boolean;
  69258. set useRampGradients(value: boolean);
  69259. /**
  69260. * Not supported by GPUParticleSystem
  69261. * @param gradient defines the gradient to use (between 0 and 1)
  69262. * @param factor defines the life time factor to affect to the specified gradient
  69263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69264. * @returns the current particle system
  69265. */
  69266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69267. /**
  69268. * Not supported by GPUParticleSystem
  69269. * @param gradient defines the gradient to remove
  69270. * @returns the current particle system
  69271. */
  69272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69273. /**
  69274. * Instantiates a GPU particle system.
  69275. * 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.
  69276. * @param name The name of the particle system
  69277. * @param options The options used to create the system
  69278. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69279. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69280. * @param customEffect a custom effect used to change the way particles are rendered by default
  69281. */
  69282. constructor(name: string, options: Partial<{
  69283. capacity: number;
  69284. randomTextureSize: number;
  69285. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69286. protected _reset(): void;
  69287. private _createUpdateVAO;
  69288. private _createRenderVAO;
  69289. private _initialize;
  69290. /** @hidden */
  69291. _recreateUpdateEffect(): void;
  69292. private _getEffect;
  69293. /**
  69294. * Fill the defines array according to the current settings of the particle system
  69295. * @param defines Array to be updated
  69296. * @param blendMode blend mode to take into account when updating the array
  69297. */
  69298. fillDefines(defines: Array<string>, blendMode?: number): void;
  69299. /**
  69300. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69301. * @param uniforms Uniforms array to fill
  69302. * @param attributes Attributes array to fill
  69303. * @param samplers Samplers array to fill
  69304. */
  69305. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69306. /** @hidden */
  69307. _recreateRenderEffect(): Effect;
  69308. /**
  69309. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69310. * @param preWarm defines if we are in the pre-warmimg phase
  69311. */
  69312. animate(preWarm?: boolean): void;
  69313. private _createFactorGradientTexture;
  69314. private _createSizeGradientTexture;
  69315. private _createAngularSpeedGradientTexture;
  69316. private _createVelocityGradientTexture;
  69317. private _createLimitVelocityGradientTexture;
  69318. private _createDragGradientTexture;
  69319. private _createColorGradientTexture;
  69320. /**
  69321. * Renders the particle system in its current state
  69322. * @param preWarm defines if the system should only update the particles but not render them
  69323. * @returns the current number of particles
  69324. */
  69325. render(preWarm?: boolean): number;
  69326. /**
  69327. * Rebuilds the particle system
  69328. */
  69329. rebuild(): void;
  69330. private _releaseBuffers;
  69331. private _releaseVAOs;
  69332. /**
  69333. * Disposes the particle system and free the associated resources
  69334. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69335. */
  69336. dispose(disposeTexture?: boolean): void;
  69337. /**
  69338. * Clones the particle system.
  69339. * @param name The name of the cloned object
  69340. * @param newEmitter The new emitter to use
  69341. * @returns the cloned particle system
  69342. */
  69343. clone(name: string, newEmitter: any): GPUParticleSystem;
  69344. /**
  69345. * Serializes the particle system to a JSON object
  69346. * @param serializeTexture defines if the texture must be serialized as well
  69347. * @returns the JSON object
  69348. */
  69349. serialize(serializeTexture?: boolean): any;
  69350. /**
  69351. * Parses a JSON object to create a GPU particle system.
  69352. * @param parsedParticleSystem The JSON object to parse
  69353. * @param sceneOrEngine The scene or the engine to create the particle system in
  69354. * @param rootUrl The root url to use to load external dependencies like texture
  69355. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69356. * @returns the parsed GPU particle system
  69357. */
  69358. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69359. }
  69360. }
  69361. declare module BABYLON {
  69362. /**
  69363. * Represents a set of particle systems working together to create a specific effect
  69364. */
  69365. export class ParticleSystemSet implements IDisposable {
  69366. /**
  69367. * Gets or sets base Assets URL
  69368. */
  69369. static BaseAssetsUrl: string;
  69370. private _emitterCreationOptions;
  69371. private _emitterNode;
  69372. /**
  69373. * Gets the particle system list
  69374. */
  69375. systems: IParticleSystem[];
  69376. /**
  69377. * Gets the emitter node used with this set
  69378. */
  69379. get emitterNode(): Nullable<TransformNode>;
  69380. /**
  69381. * Creates a new emitter mesh as a sphere
  69382. * @param options defines the options used to create the sphere
  69383. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69384. * @param scene defines the hosting scene
  69385. */
  69386. setEmitterAsSphere(options: {
  69387. diameter: number;
  69388. segments: number;
  69389. color: Color3;
  69390. }, renderingGroupId: number, scene: Scene): void;
  69391. /**
  69392. * Starts all particle systems of the set
  69393. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69394. */
  69395. start(emitter?: AbstractMesh): void;
  69396. /**
  69397. * Release all associated resources
  69398. */
  69399. dispose(): void;
  69400. /**
  69401. * Serialize the set into a JSON compatible object
  69402. * @param serializeTexture defines if the texture must be serialized as well
  69403. * @returns a JSON compatible representation of the set
  69404. */
  69405. serialize(serializeTexture?: boolean): any;
  69406. /**
  69407. * Parse a new ParticleSystemSet from a serialized source
  69408. * @param data defines a JSON compatible representation of the set
  69409. * @param scene defines the hosting scene
  69410. * @param gpu defines if we want GPU particles or CPU particles
  69411. * @returns a new ParticleSystemSet
  69412. */
  69413. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69414. }
  69415. }
  69416. declare module BABYLON {
  69417. /**
  69418. * This class is made for on one-liner static method to help creating particle system set.
  69419. */
  69420. export class ParticleHelper {
  69421. /**
  69422. * Gets or sets base Assets URL
  69423. */
  69424. static BaseAssetsUrl: string;
  69425. /** Define the Url to load snippets */
  69426. static SnippetUrl: string;
  69427. /**
  69428. * Create a default particle system that you can tweak
  69429. * @param emitter defines the emitter to use
  69430. * @param capacity defines the system capacity (default is 500 particles)
  69431. * @param scene defines the hosting scene
  69432. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69433. * @returns the new Particle system
  69434. */
  69435. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69436. /**
  69437. * This is the main static method (one-liner) of this helper to create different particle systems
  69438. * @param type This string represents the type to the particle system to create
  69439. * @param scene The scene where the particle system should live
  69440. * @param gpu If the system will use gpu
  69441. * @returns the ParticleSystemSet created
  69442. */
  69443. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69444. /**
  69445. * Static function used to export a particle system to a ParticleSystemSet variable.
  69446. * Please note that the emitter shape is not exported
  69447. * @param systems defines the particle systems to export
  69448. * @returns the created particle system set
  69449. */
  69450. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69451. /**
  69452. * Creates a particle system from a snippet saved in a remote file
  69453. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69454. * @param url defines the url to load from
  69455. * @param scene defines the hosting scene
  69456. * @param gpu If the system will use gpu
  69457. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69458. * @returns a promise that will resolve to the new particle system
  69459. */
  69460. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69461. /**
  69462. * Creates a particle system from a snippet saved by the particle system editor
  69463. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69464. * @param scene defines the hosting scene
  69465. * @param gpu If the system will use gpu
  69466. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69467. * @returns a promise that will resolve to the new particle system
  69468. */
  69469. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69470. }
  69471. }
  69472. declare module BABYLON {
  69473. interface Engine {
  69474. /**
  69475. * Create an effect to use with particle systems.
  69476. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69477. * the particle system for which you want to create a custom effect in the last parameter
  69478. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69479. * @param uniformsNames defines a list of attribute names
  69480. * @param samplers defines an array of string used to represent textures
  69481. * @param defines defines the string containing the defines to use to compile the shaders
  69482. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69483. * @param onCompiled defines a function to call when the effect creation is successful
  69484. * @param onError defines a function to call when the effect creation has failed
  69485. * @param particleSystem the particle system you want to create the effect for
  69486. * @returns the new Effect
  69487. */
  69488. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69489. }
  69490. interface Mesh {
  69491. /**
  69492. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69493. * @returns an array of IParticleSystem
  69494. */
  69495. getEmittedParticleSystems(): IParticleSystem[];
  69496. /**
  69497. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69498. * @returns an array of IParticleSystem
  69499. */
  69500. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69501. }
  69502. }
  69503. declare module BABYLON {
  69504. /** Defines the 4 color options */
  69505. export enum PointColor {
  69506. /** color value */
  69507. Color = 2,
  69508. /** uv value */
  69509. UV = 1,
  69510. /** random value */
  69511. Random = 0,
  69512. /** stated value */
  69513. Stated = 3
  69514. }
  69515. /**
  69516. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69517. * 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.
  69518. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69519. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69520. *
  69521. * Full documentation here : TO BE ENTERED
  69522. */
  69523. export class PointsCloudSystem implements IDisposable {
  69524. /**
  69525. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69526. * Example : var p = SPS.particles[i];
  69527. */
  69528. particles: CloudPoint[];
  69529. /**
  69530. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69531. */
  69532. nbParticles: number;
  69533. /**
  69534. * This a counter for your own usage. It's not set by any SPS functions.
  69535. */
  69536. counter: number;
  69537. /**
  69538. * The PCS name. This name is also given to the underlying mesh.
  69539. */
  69540. name: string;
  69541. /**
  69542. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69543. */
  69544. mesh: Mesh;
  69545. /**
  69546. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69547. * Please read :
  69548. */
  69549. vars: any;
  69550. /**
  69551. * @hidden
  69552. */
  69553. _size: number;
  69554. private _scene;
  69555. private _promises;
  69556. private _positions;
  69557. private _indices;
  69558. private _normals;
  69559. private _colors;
  69560. private _uvs;
  69561. private _indices32;
  69562. private _positions32;
  69563. private _colors32;
  69564. private _uvs32;
  69565. private _updatable;
  69566. private _isVisibilityBoxLocked;
  69567. private _alwaysVisible;
  69568. private _groups;
  69569. private _groupCounter;
  69570. private _computeParticleColor;
  69571. private _computeParticleTexture;
  69572. private _computeParticleRotation;
  69573. private _computeBoundingBox;
  69574. private _isReady;
  69575. /**
  69576. * Creates a PCS (Points Cloud System) object
  69577. * @param name (String) is the PCS name, this will be the underlying mesh name
  69578. * @param pointSize (number) is the size for each point
  69579. * @param scene (Scene) is the scene in which the PCS is added
  69580. * @param options defines the options of the PCS e.g.
  69581. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69582. */
  69583. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69584. updatable?: boolean;
  69585. });
  69586. /**
  69587. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69588. * If no points were added to the PCS, the returned mesh is just a single point.
  69589. * @returns a promise for the created mesh
  69590. */
  69591. buildMeshAsync(): Promise<Mesh>;
  69592. /**
  69593. * @hidden
  69594. */
  69595. private _buildMesh;
  69596. private _addParticle;
  69597. private _randomUnitVector;
  69598. private _getColorIndicesForCoord;
  69599. private _setPointsColorOrUV;
  69600. private _colorFromTexture;
  69601. private _calculateDensity;
  69602. /**
  69603. * Adds points to the PCS in random positions within a unit sphere
  69604. * @param nb (positive integer) the number of particles to be created from this model
  69605. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69606. * @returns the number of groups in the system
  69607. */
  69608. addPoints(nb: number, pointFunction?: any): number;
  69609. /**
  69610. * Adds points to the PCS from the surface of the model shape
  69611. * @param mesh is any Mesh object that will be used as a surface model for the points
  69612. * @param nb (positive integer) the number of particles to be created from this model
  69613. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69614. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69615. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69616. * @returns the number of groups in the system
  69617. */
  69618. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69619. /**
  69620. * Adds points to the PCS inside the model shape
  69621. * @param mesh is any Mesh object that will be used as a surface model for the points
  69622. * @param nb (positive integer) the number of particles to be created from this model
  69623. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69624. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69625. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69626. * @returns the number of groups in the system
  69627. */
  69628. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69629. /**
  69630. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69631. * This method calls `updateParticle()` for each particle of the SPS.
  69632. * For an animated SPS, it is usually called within the render loop.
  69633. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69634. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69635. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69636. * @returns the PCS.
  69637. */
  69638. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69639. /**
  69640. * Disposes the PCS.
  69641. */
  69642. dispose(): void;
  69643. /**
  69644. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69645. * doc :
  69646. * @returns the PCS.
  69647. */
  69648. refreshVisibleSize(): PointsCloudSystem;
  69649. /**
  69650. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69651. * @param size the size (float) of the visibility box
  69652. * note : this doesn't lock the PCS mesh bounding box.
  69653. * doc :
  69654. */
  69655. setVisibilityBox(size: number): void;
  69656. /**
  69657. * Gets whether the PCS is always visible or not
  69658. * doc :
  69659. */
  69660. get isAlwaysVisible(): boolean;
  69661. /**
  69662. * Sets the PCS as always visible or not
  69663. * doc :
  69664. */
  69665. set isAlwaysVisible(val: boolean);
  69666. /**
  69667. * Tells to `setParticles()` to compute the particle rotations or not
  69668. * Default value : false. The PCS is faster when it's set to false
  69669. * Note : particle rotations are only applied to parent particles
  69670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69671. */
  69672. set computeParticleRotation(val: boolean);
  69673. /**
  69674. * Tells to `setParticles()` to compute the particle colors or not.
  69675. * Default value : true. The PCS is faster when it's set to false.
  69676. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69677. */
  69678. set computeParticleColor(val: boolean);
  69679. set computeParticleTexture(val: boolean);
  69680. /**
  69681. * Gets if `setParticles()` computes the particle colors or not.
  69682. * Default value : false. The PCS is faster when it's set to false.
  69683. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69684. */
  69685. get computeParticleColor(): boolean;
  69686. /**
  69687. * Gets if `setParticles()` computes the particle textures or not.
  69688. * Default value : false. The PCS is faster when it's set to false.
  69689. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69690. */
  69691. get computeParticleTexture(): boolean;
  69692. /**
  69693. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69694. */
  69695. set computeBoundingBox(val: boolean);
  69696. /**
  69697. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69698. */
  69699. get computeBoundingBox(): boolean;
  69700. /**
  69701. * This function does nothing. It may be overwritten to set all the particle first values.
  69702. * The PCS doesn't call this function, you may have to call it by your own.
  69703. * doc :
  69704. */
  69705. initParticles(): void;
  69706. /**
  69707. * This function does nothing. It may be overwritten to recycle a particle
  69708. * The PCS doesn't call this function, you can to call it
  69709. * doc :
  69710. * @param particle The particle to recycle
  69711. * @returns the recycled particle
  69712. */
  69713. recycleParticle(particle: CloudPoint): CloudPoint;
  69714. /**
  69715. * Updates a particle : this function should be overwritten by the user.
  69716. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69717. * doc :
  69718. * @example : just set a particle position or velocity and recycle conditions
  69719. * @param particle The particle to update
  69720. * @returns the updated particle
  69721. */
  69722. updateParticle(particle: CloudPoint): CloudPoint;
  69723. /**
  69724. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69725. * This does nothing and may be overwritten by the user.
  69726. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69727. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69728. * @param update the boolean update value actually passed to setParticles()
  69729. */
  69730. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69731. /**
  69732. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69733. * This will be passed three parameters.
  69734. * This does nothing and may be overwritten by the user.
  69735. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69736. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69737. * @param update the boolean update value actually passed to setParticles()
  69738. */
  69739. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69740. }
  69741. }
  69742. declare module BABYLON {
  69743. /**
  69744. * Represents one particle of a points cloud system.
  69745. */
  69746. export class CloudPoint {
  69747. /**
  69748. * particle global index
  69749. */
  69750. idx: number;
  69751. /**
  69752. * The color of the particle
  69753. */
  69754. color: Nullable<Color4>;
  69755. /**
  69756. * The world space position of the particle.
  69757. */
  69758. position: Vector3;
  69759. /**
  69760. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69761. */
  69762. rotation: Vector3;
  69763. /**
  69764. * The world space rotation quaternion of the particle.
  69765. */
  69766. rotationQuaternion: Nullable<Quaternion>;
  69767. /**
  69768. * The uv of the particle.
  69769. */
  69770. uv: Nullable<Vector2>;
  69771. /**
  69772. * The current speed of the particle.
  69773. */
  69774. velocity: Vector3;
  69775. /**
  69776. * The pivot point in the particle local space.
  69777. */
  69778. pivot: Vector3;
  69779. /**
  69780. * Must the particle be translated from its pivot point in its local space ?
  69781. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69782. * Default : false
  69783. */
  69784. translateFromPivot: boolean;
  69785. /**
  69786. * Index of this particle in the global "positions" array (Internal use)
  69787. * @hidden
  69788. */
  69789. _pos: number;
  69790. /**
  69791. * @hidden Index of this particle in the global "indices" array (Internal use)
  69792. */
  69793. _ind: number;
  69794. /**
  69795. * Group this particle belongs to
  69796. */
  69797. _group: PointsGroup;
  69798. /**
  69799. * Group id of this particle
  69800. */
  69801. groupId: number;
  69802. /**
  69803. * Index of the particle in its group id (Internal use)
  69804. */
  69805. idxInGroup: number;
  69806. /**
  69807. * @hidden Particle BoundingInfo object (Internal use)
  69808. */
  69809. _boundingInfo: BoundingInfo;
  69810. /**
  69811. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69812. */
  69813. _pcs: PointsCloudSystem;
  69814. /**
  69815. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69816. */
  69817. _stillInvisible: boolean;
  69818. /**
  69819. * @hidden Last computed particle rotation matrix
  69820. */
  69821. _rotationMatrix: number[];
  69822. /**
  69823. * Parent particle Id, if any.
  69824. * Default null.
  69825. */
  69826. parentId: Nullable<number>;
  69827. /**
  69828. * @hidden Internal global position in the PCS.
  69829. */
  69830. _globalPosition: Vector3;
  69831. /**
  69832. * Creates a Point Cloud object.
  69833. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69834. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69835. * @param group (PointsGroup) is the group the particle belongs to
  69836. * @param groupId (integer) is the group identifier in the PCS.
  69837. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69838. * @param pcs defines the PCS it is associated to
  69839. */
  69840. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69841. /**
  69842. * get point size
  69843. */
  69844. get size(): Vector3;
  69845. /**
  69846. * Set point size
  69847. */
  69848. set size(scale: Vector3);
  69849. /**
  69850. * Legacy support, changed quaternion to rotationQuaternion
  69851. */
  69852. get quaternion(): Nullable<Quaternion>;
  69853. /**
  69854. * Legacy support, changed quaternion to rotationQuaternion
  69855. */
  69856. set quaternion(q: Nullable<Quaternion>);
  69857. /**
  69858. * Returns a boolean. True if the particle intersects a mesh, else false
  69859. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69860. * @param target is the object (point or mesh) what the intersection is computed against
  69861. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69862. * @returns true if it intersects
  69863. */
  69864. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69865. /**
  69866. * get the rotation matrix of the particle
  69867. * @hidden
  69868. */
  69869. getRotationMatrix(m: Matrix): void;
  69870. }
  69871. /**
  69872. * Represents a group of points in a points cloud system
  69873. * * PCS internal tool, don't use it manually.
  69874. */
  69875. export class PointsGroup {
  69876. /**
  69877. * The group id
  69878. * @hidden
  69879. */
  69880. groupID: number;
  69881. /**
  69882. * image data for group (internal use)
  69883. * @hidden
  69884. */
  69885. _groupImageData: Nullable<ArrayBufferView>;
  69886. /**
  69887. * Image Width (internal use)
  69888. * @hidden
  69889. */
  69890. _groupImgWidth: number;
  69891. /**
  69892. * Image Height (internal use)
  69893. * @hidden
  69894. */
  69895. _groupImgHeight: number;
  69896. /**
  69897. * Custom position function (internal use)
  69898. * @hidden
  69899. */
  69900. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69901. /**
  69902. * density per facet for surface points
  69903. * @hidden
  69904. */
  69905. _groupDensity: number[];
  69906. /**
  69907. * Only when points are colored by texture carries pointer to texture list array
  69908. * @hidden
  69909. */
  69910. _textureNb: number;
  69911. /**
  69912. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69913. * PCS internal tool, don't use it manually.
  69914. * @hidden
  69915. */
  69916. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69917. }
  69918. }
  69919. declare module BABYLON {
  69920. interface Scene {
  69921. /** @hidden (Backing field) */
  69922. _physicsEngine: Nullable<IPhysicsEngine>;
  69923. /** @hidden */
  69924. _physicsTimeAccumulator: number;
  69925. /**
  69926. * Gets the current physics engine
  69927. * @returns a IPhysicsEngine or null if none attached
  69928. */
  69929. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69930. /**
  69931. * Enables physics to the current scene
  69932. * @param gravity defines the scene's gravity for the physics engine
  69933. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69934. * @return a boolean indicating if the physics engine was initialized
  69935. */
  69936. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69937. /**
  69938. * Disables and disposes the physics engine associated with the scene
  69939. */
  69940. disablePhysicsEngine(): void;
  69941. /**
  69942. * Gets a boolean indicating if there is an active physics engine
  69943. * @returns a boolean indicating if there is an active physics engine
  69944. */
  69945. isPhysicsEnabled(): boolean;
  69946. /**
  69947. * Deletes a physics compound impostor
  69948. * @param compound defines the compound to delete
  69949. */
  69950. deleteCompoundImpostor(compound: any): void;
  69951. /**
  69952. * An event triggered when physic simulation is about to be run
  69953. */
  69954. onBeforePhysicsObservable: Observable<Scene>;
  69955. /**
  69956. * An event triggered when physic simulation has been done
  69957. */
  69958. onAfterPhysicsObservable: Observable<Scene>;
  69959. }
  69960. interface AbstractMesh {
  69961. /** @hidden */
  69962. _physicsImpostor: Nullable<PhysicsImpostor>;
  69963. /**
  69964. * Gets or sets impostor used for physic simulation
  69965. * @see https://doc.babylonjs.com/features/physics_engine
  69966. */
  69967. physicsImpostor: Nullable<PhysicsImpostor>;
  69968. /**
  69969. * Gets the current physics impostor
  69970. * @see https://doc.babylonjs.com/features/physics_engine
  69971. * @returns a physics impostor or null
  69972. */
  69973. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69974. /** Apply a physic impulse to the mesh
  69975. * @param force defines the force to apply
  69976. * @param contactPoint defines where to apply the force
  69977. * @returns the current mesh
  69978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69979. */
  69980. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69981. /**
  69982. * Creates a physic joint between two meshes
  69983. * @param otherMesh defines the other mesh to use
  69984. * @param pivot1 defines the pivot to use on this mesh
  69985. * @param pivot2 defines the pivot to use on the other mesh
  69986. * @param options defines additional options (can be plugin dependent)
  69987. * @returns the current mesh
  69988. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69989. */
  69990. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69991. /** @hidden */
  69992. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69993. }
  69994. /**
  69995. * Defines the physics engine scene component responsible to manage a physics engine
  69996. */
  69997. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69998. /**
  69999. * The component name helpful to identify the component in the list of scene components.
  70000. */
  70001. readonly name: string;
  70002. /**
  70003. * The scene the component belongs to.
  70004. */
  70005. scene: Scene;
  70006. /**
  70007. * Creates a new instance of the component for the given scene
  70008. * @param scene Defines the scene to register the component in
  70009. */
  70010. constructor(scene: Scene);
  70011. /**
  70012. * Registers the component in a given scene
  70013. */
  70014. register(): void;
  70015. /**
  70016. * Rebuilds the elements related to this component in case of
  70017. * context lost for instance.
  70018. */
  70019. rebuild(): void;
  70020. /**
  70021. * Disposes the component and the associated ressources
  70022. */
  70023. dispose(): void;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /**
  70028. * A helper for physics simulations
  70029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70030. */
  70031. export class PhysicsHelper {
  70032. private _scene;
  70033. private _physicsEngine;
  70034. /**
  70035. * Initializes the Physics helper
  70036. * @param scene Babylon.js scene
  70037. */
  70038. constructor(scene: Scene);
  70039. /**
  70040. * Applies a radial explosion impulse
  70041. * @param origin the origin of the explosion
  70042. * @param radiusOrEventOptions the radius or the options of radial explosion
  70043. * @param strength the explosion strength
  70044. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70045. * @returns A physics radial explosion event, or null
  70046. */
  70047. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70048. /**
  70049. * Applies a radial explosion force
  70050. * @param origin the origin of the explosion
  70051. * @param radiusOrEventOptions the radius or the options of radial explosion
  70052. * @param strength the explosion strength
  70053. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70054. * @returns A physics radial explosion event, or null
  70055. */
  70056. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70057. /**
  70058. * Creates a gravitational field
  70059. * @param origin the origin of the explosion
  70060. * @param radiusOrEventOptions the radius or the options of radial explosion
  70061. * @param strength the explosion strength
  70062. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70063. * @returns A physics gravitational field event, or null
  70064. */
  70065. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70066. /**
  70067. * Creates a physics updraft event
  70068. * @param origin the origin of the updraft
  70069. * @param radiusOrEventOptions the radius or the options of the updraft
  70070. * @param strength the strength of the updraft
  70071. * @param height the height of the updraft
  70072. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70073. * @returns A physics updraft event, or null
  70074. */
  70075. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70076. /**
  70077. * Creates a physics vortex event
  70078. * @param origin the of the vortex
  70079. * @param radiusOrEventOptions the radius or the options of the vortex
  70080. * @param strength the strength of the vortex
  70081. * @param height the height of the vortex
  70082. * @returns a Physics vortex event, or null
  70083. * A physics vortex event or null
  70084. */
  70085. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70086. }
  70087. /**
  70088. * Represents a physics radial explosion event
  70089. */
  70090. class PhysicsRadialExplosionEvent {
  70091. private _scene;
  70092. private _options;
  70093. private _sphere;
  70094. private _dataFetched;
  70095. /**
  70096. * Initializes a radial explosioin event
  70097. * @param _scene BabylonJS scene
  70098. * @param _options The options for the vortex event
  70099. */
  70100. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70101. /**
  70102. * Returns the data related to the radial explosion event (sphere).
  70103. * @returns The radial explosion event data
  70104. */
  70105. getData(): PhysicsRadialExplosionEventData;
  70106. /**
  70107. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70108. * @param impostor A physics imposter
  70109. * @param origin the origin of the explosion
  70110. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70111. */
  70112. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70113. /**
  70114. * Triggers affecterd impostors callbacks
  70115. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70116. */
  70117. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70118. /**
  70119. * Disposes the sphere.
  70120. * @param force Specifies if the sphere should be disposed by force
  70121. */
  70122. dispose(force?: boolean): void;
  70123. /*** Helpers ***/
  70124. private _prepareSphere;
  70125. private _intersectsWithSphere;
  70126. }
  70127. /**
  70128. * Represents a gravitational field event
  70129. */
  70130. class PhysicsGravitationalFieldEvent {
  70131. private _physicsHelper;
  70132. private _scene;
  70133. private _origin;
  70134. private _options;
  70135. private _tickCallback;
  70136. private _sphere;
  70137. private _dataFetched;
  70138. /**
  70139. * Initializes the physics gravitational field event
  70140. * @param _physicsHelper A physics helper
  70141. * @param _scene BabylonJS scene
  70142. * @param _origin The origin position of the gravitational field event
  70143. * @param _options The options for the vortex event
  70144. */
  70145. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70146. /**
  70147. * Returns the data related to the gravitational field event (sphere).
  70148. * @returns A gravitational field event
  70149. */
  70150. getData(): PhysicsGravitationalFieldEventData;
  70151. /**
  70152. * Enables the gravitational field.
  70153. */
  70154. enable(): void;
  70155. /**
  70156. * Disables the gravitational field.
  70157. */
  70158. disable(): void;
  70159. /**
  70160. * Disposes the sphere.
  70161. * @param force The force to dispose from the gravitational field event
  70162. */
  70163. dispose(force?: boolean): void;
  70164. private _tick;
  70165. }
  70166. /**
  70167. * Represents a physics updraft event
  70168. */
  70169. class PhysicsUpdraftEvent {
  70170. private _scene;
  70171. private _origin;
  70172. private _options;
  70173. private _physicsEngine;
  70174. private _originTop;
  70175. private _originDirection;
  70176. private _tickCallback;
  70177. private _cylinder;
  70178. private _cylinderPosition;
  70179. private _dataFetched;
  70180. /**
  70181. * Initializes the physics updraft event
  70182. * @param _scene BabylonJS scene
  70183. * @param _origin The origin position of the updraft
  70184. * @param _options The options for the updraft event
  70185. */
  70186. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70187. /**
  70188. * Returns the data related to the updraft event (cylinder).
  70189. * @returns A physics updraft event
  70190. */
  70191. getData(): PhysicsUpdraftEventData;
  70192. /**
  70193. * Enables the updraft.
  70194. */
  70195. enable(): void;
  70196. /**
  70197. * Disables the updraft.
  70198. */
  70199. disable(): void;
  70200. /**
  70201. * Disposes the cylinder.
  70202. * @param force Specifies if the updraft should be disposed by force
  70203. */
  70204. dispose(force?: boolean): void;
  70205. private getImpostorHitData;
  70206. private _tick;
  70207. /*** Helpers ***/
  70208. private _prepareCylinder;
  70209. private _intersectsWithCylinder;
  70210. }
  70211. /**
  70212. * Represents a physics vortex event
  70213. */
  70214. class PhysicsVortexEvent {
  70215. private _scene;
  70216. private _origin;
  70217. private _options;
  70218. private _physicsEngine;
  70219. private _originTop;
  70220. private _tickCallback;
  70221. private _cylinder;
  70222. private _cylinderPosition;
  70223. private _dataFetched;
  70224. /**
  70225. * Initializes the physics vortex event
  70226. * @param _scene The BabylonJS scene
  70227. * @param _origin The origin position of the vortex
  70228. * @param _options The options for the vortex event
  70229. */
  70230. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70231. /**
  70232. * Returns the data related to the vortex event (cylinder).
  70233. * @returns The physics vortex event data
  70234. */
  70235. getData(): PhysicsVortexEventData;
  70236. /**
  70237. * Enables the vortex.
  70238. */
  70239. enable(): void;
  70240. /**
  70241. * Disables the cortex.
  70242. */
  70243. disable(): void;
  70244. /**
  70245. * Disposes the sphere.
  70246. * @param force
  70247. */
  70248. dispose(force?: boolean): void;
  70249. private getImpostorHitData;
  70250. private _tick;
  70251. /*** Helpers ***/
  70252. private _prepareCylinder;
  70253. private _intersectsWithCylinder;
  70254. }
  70255. /**
  70256. * Options fot the radial explosion event
  70257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70258. */
  70259. export class PhysicsRadialExplosionEventOptions {
  70260. /**
  70261. * The radius of the sphere for the radial explosion.
  70262. */
  70263. radius: number;
  70264. /**
  70265. * The strenth of the explosion.
  70266. */
  70267. strength: number;
  70268. /**
  70269. * The strenght of the force in correspondence to the distance of the affected object
  70270. */
  70271. falloff: PhysicsRadialImpulseFalloff;
  70272. /**
  70273. * Sphere options for the radial explosion.
  70274. */
  70275. sphere: {
  70276. segments: number;
  70277. diameter: number;
  70278. };
  70279. /**
  70280. * Sphere options for the radial explosion.
  70281. */
  70282. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70283. }
  70284. /**
  70285. * Options fot the updraft event
  70286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70287. */
  70288. export class PhysicsUpdraftEventOptions {
  70289. /**
  70290. * The radius of the cylinder for the vortex
  70291. */
  70292. radius: number;
  70293. /**
  70294. * The strenth of the updraft.
  70295. */
  70296. strength: number;
  70297. /**
  70298. * The height of the cylinder for the updraft.
  70299. */
  70300. height: number;
  70301. /**
  70302. * The mode for the the updraft.
  70303. */
  70304. updraftMode: PhysicsUpdraftMode;
  70305. }
  70306. /**
  70307. * Options fot the vortex event
  70308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70309. */
  70310. export class PhysicsVortexEventOptions {
  70311. /**
  70312. * The radius of the cylinder for the vortex
  70313. */
  70314. radius: number;
  70315. /**
  70316. * The strenth of the vortex.
  70317. */
  70318. strength: number;
  70319. /**
  70320. * The height of the cylinder for the vortex.
  70321. */
  70322. height: number;
  70323. /**
  70324. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70325. */
  70326. centripetalForceThreshold: number;
  70327. /**
  70328. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70329. */
  70330. centripetalForceMultiplier: number;
  70331. /**
  70332. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70333. */
  70334. centrifugalForceMultiplier: number;
  70335. /**
  70336. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70337. */
  70338. updraftForceMultiplier: number;
  70339. }
  70340. /**
  70341. * The strenght of the force in correspondence to the distance of the affected object
  70342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70343. */
  70344. export enum PhysicsRadialImpulseFalloff {
  70345. /** Defines that impulse is constant in strength across it's whole radius */
  70346. Constant = 0,
  70347. /** Defines that impulse gets weaker if it's further from the origin */
  70348. Linear = 1
  70349. }
  70350. /**
  70351. * The strength of the force in correspondence to the distance of the affected object
  70352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70353. */
  70354. export enum PhysicsUpdraftMode {
  70355. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70356. Center = 0,
  70357. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70358. Perpendicular = 1
  70359. }
  70360. /**
  70361. * Interface for a physics hit data
  70362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70363. */
  70364. export interface PhysicsHitData {
  70365. /**
  70366. * The force applied at the contact point
  70367. */
  70368. force: Vector3;
  70369. /**
  70370. * The contact point
  70371. */
  70372. contactPoint: Vector3;
  70373. /**
  70374. * The distance from the origin to the contact point
  70375. */
  70376. distanceFromOrigin: number;
  70377. }
  70378. /**
  70379. * Interface for radial explosion event data
  70380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70381. */
  70382. export interface PhysicsRadialExplosionEventData {
  70383. /**
  70384. * A sphere used for the radial explosion event
  70385. */
  70386. sphere: Mesh;
  70387. }
  70388. /**
  70389. * Interface for gravitational field event data
  70390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70391. */
  70392. export interface PhysicsGravitationalFieldEventData {
  70393. /**
  70394. * A sphere mesh used for the gravitational field event
  70395. */
  70396. sphere: Mesh;
  70397. }
  70398. /**
  70399. * Interface for updraft event data
  70400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70401. */
  70402. export interface PhysicsUpdraftEventData {
  70403. /**
  70404. * A cylinder used for the updraft event
  70405. */
  70406. cylinder: Mesh;
  70407. }
  70408. /**
  70409. * Interface for vortex event data
  70410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70411. */
  70412. export interface PhysicsVortexEventData {
  70413. /**
  70414. * A cylinder used for the vortex event
  70415. */
  70416. cylinder: Mesh;
  70417. }
  70418. /**
  70419. * Interface for an affected physics impostor
  70420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70421. */
  70422. export interface PhysicsAffectedImpostorWithData {
  70423. /**
  70424. * The impostor affected by the effect
  70425. */
  70426. impostor: PhysicsImpostor;
  70427. /**
  70428. * The data about the hit/horce from the explosion
  70429. */
  70430. hitData: PhysicsHitData;
  70431. }
  70432. }
  70433. declare module BABYLON {
  70434. /** @hidden */
  70435. export var blackAndWhitePixelShader: {
  70436. name: string;
  70437. shader: string;
  70438. };
  70439. }
  70440. declare module BABYLON {
  70441. /**
  70442. * Post process used to render in black and white
  70443. */
  70444. export class BlackAndWhitePostProcess extends PostProcess {
  70445. /**
  70446. * Linear about to convert he result to black and white (default: 1)
  70447. */
  70448. degree: number;
  70449. /**
  70450. * Gets a string identifying the name of the class
  70451. * @returns "BlackAndWhitePostProcess" string
  70452. */
  70453. getClassName(): string;
  70454. /**
  70455. * Creates a black and white post process
  70456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70457. * @param name The name of the effect.
  70458. * @param options The required width/height ratio to downsize to before computing the render pass.
  70459. * @param camera The camera to apply the render pass to.
  70460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70461. * @param engine The engine which the post process will be applied. (default: current engine)
  70462. * @param reusable If the post process can be reused on the same frame. (default: false)
  70463. */
  70464. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70465. /** @hidden */
  70466. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * This represents a set of one or more post processes in Babylon.
  70472. * A post process can be used to apply a shader to a texture after it is rendered.
  70473. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70474. */
  70475. export class PostProcessRenderEffect {
  70476. private _postProcesses;
  70477. private _getPostProcesses;
  70478. private _singleInstance;
  70479. private _cameras;
  70480. private _indicesForCamera;
  70481. /**
  70482. * Name of the effect
  70483. * @hidden
  70484. */
  70485. _name: string;
  70486. /**
  70487. * Instantiates a post process render effect.
  70488. * A post process can be used to apply a shader to a texture after it is rendered.
  70489. * @param engine The engine the effect is tied to
  70490. * @param name The name of the effect
  70491. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70492. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70493. */
  70494. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70495. /**
  70496. * Checks if all the post processes in the effect are supported.
  70497. */
  70498. get isSupported(): boolean;
  70499. /**
  70500. * Updates the current state of the effect
  70501. * @hidden
  70502. */
  70503. _update(): void;
  70504. /**
  70505. * Attaches the effect on cameras
  70506. * @param cameras The camera to attach to.
  70507. * @hidden
  70508. */
  70509. _attachCameras(cameras: Camera): void;
  70510. /**
  70511. * Attaches the effect on cameras
  70512. * @param cameras The camera to attach to.
  70513. * @hidden
  70514. */
  70515. _attachCameras(cameras: Camera[]): void;
  70516. /**
  70517. * Detaches the effect on cameras
  70518. * @param cameras The camera to detatch from.
  70519. * @hidden
  70520. */
  70521. _detachCameras(cameras: Camera): void;
  70522. /**
  70523. * Detatches the effect on cameras
  70524. * @param cameras The camera to detatch from.
  70525. * @hidden
  70526. */
  70527. _detachCameras(cameras: Camera[]): void;
  70528. /**
  70529. * Enables the effect on given cameras
  70530. * @param cameras The camera to enable.
  70531. * @hidden
  70532. */
  70533. _enable(cameras: Camera): void;
  70534. /**
  70535. * Enables the effect on given cameras
  70536. * @param cameras The camera to enable.
  70537. * @hidden
  70538. */
  70539. _enable(cameras: Nullable<Camera[]>): void;
  70540. /**
  70541. * Disables the effect on the given cameras
  70542. * @param cameras The camera to disable.
  70543. * @hidden
  70544. */
  70545. _disable(cameras: Camera): void;
  70546. /**
  70547. * Disables the effect on the given cameras
  70548. * @param cameras The camera to disable.
  70549. * @hidden
  70550. */
  70551. _disable(cameras: Nullable<Camera[]>): void;
  70552. /**
  70553. * Gets a list of the post processes contained in the effect.
  70554. * @param camera The camera to get the post processes on.
  70555. * @returns The list of the post processes in the effect.
  70556. */
  70557. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70558. }
  70559. }
  70560. declare module BABYLON {
  70561. /** @hidden */
  70562. export var extractHighlightsPixelShader: {
  70563. name: string;
  70564. shader: string;
  70565. };
  70566. }
  70567. declare module BABYLON {
  70568. /**
  70569. * 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.
  70570. */
  70571. export class ExtractHighlightsPostProcess extends PostProcess {
  70572. /**
  70573. * The luminance threshold, pixels below this value will be set to black.
  70574. */
  70575. threshold: number;
  70576. /** @hidden */
  70577. _exposure: number;
  70578. /**
  70579. * Post process which has the input texture to be used when performing highlight extraction
  70580. * @hidden
  70581. */
  70582. _inputPostProcess: Nullable<PostProcess>;
  70583. /**
  70584. * Gets a string identifying the name of the class
  70585. * @returns "ExtractHighlightsPostProcess" string
  70586. */
  70587. getClassName(): string;
  70588. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70589. }
  70590. }
  70591. declare module BABYLON {
  70592. /** @hidden */
  70593. export var bloomMergePixelShader: {
  70594. name: string;
  70595. shader: string;
  70596. };
  70597. }
  70598. declare module BABYLON {
  70599. /**
  70600. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70601. */
  70602. export class BloomMergePostProcess extends PostProcess {
  70603. /** Weight of the bloom to be added to the original input. */
  70604. weight: number;
  70605. /**
  70606. * Gets a string identifying the name of the class
  70607. * @returns "BloomMergePostProcess" string
  70608. */
  70609. getClassName(): string;
  70610. /**
  70611. * Creates a new instance of @see BloomMergePostProcess
  70612. * @param name The name of the effect.
  70613. * @param originalFromInput Post process which's input will be used for the merge.
  70614. * @param blurred Blurred highlights post process which's output will be used.
  70615. * @param weight Weight of the bloom to be added to the original input.
  70616. * @param options The required width/height ratio to downsize to before computing the render pass.
  70617. * @param camera The camera to apply the render pass to.
  70618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70619. * @param engine The engine which the post process will be applied. (default: current engine)
  70620. * @param reusable If the post process can be reused on the same frame. (default: false)
  70621. * @param textureType Type of textures used when performing the post process. (default: 0)
  70622. * @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)
  70623. */
  70624. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70625. /** Weight of the bloom to be added to the original input. */
  70626. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70627. }
  70628. }
  70629. declare module BABYLON {
  70630. /**
  70631. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70632. */
  70633. export class BloomEffect extends PostProcessRenderEffect {
  70634. private bloomScale;
  70635. /**
  70636. * @hidden Internal
  70637. */
  70638. _effects: Array<PostProcess>;
  70639. /**
  70640. * @hidden Internal
  70641. */
  70642. _downscale: ExtractHighlightsPostProcess;
  70643. private _blurX;
  70644. private _blurY;
  70645. private _merge;
  70646. /**
  70647. * The luminance threshold to find bright areas of the image to bloom.
  70648. */
  70649. get threshold(): number;
  70650. set threshold(value: number);
  70651. /**
  70652. * The strength of the bloom.
  70653. */
  70654. get weight(): number;
  70655. set weight(value: number);
  70656. /**
  70657. * Specifies the size of the bloom blur kernel, relative to the final output size
  70658. */
  70659. get kernel(): number;
  70660. set kernel(value: number);
  70661. /**
  70662. * Creates a new instance of @see BloomEffect
  70663. * @param scene The scene the effect belongs to.
  70664. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70665. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70666. * @param bloomWeight The the strength of bloom.
  70667. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70668. * @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)
  70669. */
  70670. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70671. /**
  70672. * Disposes each of the internal effects for a given camera.
  70673. * @param camera The camera to dispose the effect on.
  70674. */
  70675. disposeEffects(camera: Camera): void;
  70676. /**
  70677. * @hidden Internal
  70678. */
  70679. _updateEffects(): void;
  70680. /**
  70681. * Internal
  70682. * @returns if all the contained post processes are ready.
  70683. * @hidden
  70684. */
  70685. _isReady(): boolean;
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /** @hidden */
  70690. export var chromaticAberrationPixelShader: {
  70691. name: string;
  70692. shader: string;
  70693. };
  70694. }
  70695. declare module BABYLON {
  70696. /**
  70697. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70698. */
  70699. export class ChromaticAberrationPostProcess extends PostProcess {
  70700. /**
  70701. * The amount of seperation of rgb channels (default: 30)
  70702. */
  70703. aberrationAmount: number;
  70704. /**
  70705. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70706. */
  70707. radialIntensity: number;
  70708. /**
  70709. * 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))
  70710. */
  70711. direction: Vector2;
  70712. /**
  70713. * 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))
  70714. */
  70715. centerPosition: Vector2;
  70716. /** The width of the screen to apply the effect on */
  70717. screenWidth: number;
  70718. /** The height of the screen to apply the effect on */
  70719. screenHeight: number;
  70720. /**
  70721. * Gets a string identifying the name of the class
  70722. * @returns "ChromaticAberrationPostProcess" string
  70723. */
  70724. getClassName(): string;
  70725. /**
  70726. * Creates a new instance ChromaticAberrationPostProcess
  70727. * @param name The name of the effect.
  70728. * @param screenWidth The width of the screen to apply the effect on.
  70729. * @param screenHeight The height of the screen to apply the effect on.
  70730. * @param options The required width/height ratio to downsize to before computing the render pass.
  70731. * @param camera The camera to apply the render pass to.
  70732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70733. * @param engine The engine which the post process will be applied. (default: current engine)
  70734. * @param reusable If the post process can be reused on the same frame. (default: false)
  70735. * @param textureType Type of textures used when performing the post process. (default: 0)
  70736. * @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)
  70737. */
  70738. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70739. /** @hidden */
  70740. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70741. }
  70742. }
  70743. declare module BABYLON {
  70744. /** @hidden */
  70745. export var circleOfConfusionPixelShader: {
  70746. name: string;
  70747. shader: string;
  70748. };
  70749. }
  70750. declare module BABYLON {
  70751. /**
  70752. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70753. */
  70754. export class CircleOfConfusionPostProcess extends PostProcess {
  70755. /**
  70756. * 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.
  70757. */
  70758. lensSize: number;
  70759. /**
  70760. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70761. */
  70762. fStop: number;
  70763. /**
  70764. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70765. */
  70766. focusDistance: number;
  70767. /**
  70768. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70769. */
  70770. focalLength: number;
  70771. /**
  70772. * Gets a string identifying the name of the class
  70773. * @returns "CircleOfConfusionPostProcess" string
  70774. */
  70775. getClassName(): string;
  70776. private _depthTexture;
  70777. /**
  70778. * Creates a new instance CircleOfConfusionPostProcess
  70779. * @param name The name of the effect.
  70780. * @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.
  70781. * @param options The required width/height ratio to downsize to before computing the render pass.
  70782. * @param camera The camera to apply the render pass to.
  70783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70784. * @param engine The engine which the post process will be applied. (default: current engine)
  70785. * @param reusable If the post process can be reused on the same frame. (default: false)
  70786. * @param textureType Type of textures used when performing the post process. (default: 0)
  70787. * @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)
  70788. */
  70789. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70790. /**
  70791. * 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.
  70792. */
  70793. set depthTexture(value: RenderTargetTexture);
  70794. }
  70795. }
  70796. declare module BABYLON {
  70797. /** @hidden */
  70798. export var colorCorrectionPixelShader: {
  70799. name: string;
  70800. shader: string;
  70801. };
  70802. }
  70803. declare module BABYLON {
  70804. /**
  70805. *
  70806. * This post-process allows the modification of rendered colors by using
  70807. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70808. *
  70809. * The object needs to be provided an url to a texture containing the color
  70810. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70811. * Use an image editing software to tweak the LUT to match your needs.
  70812. *
  70813. * For an example of a color LUT, see here:
  70814. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70815. * For explanations on color grading, see here:
  70816. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70817. *
  70818. */
  70819. export class ColorCorrectionPostProcess extends PostProcess {
  70820. private _colorTableTexture;
  70821. /**
  70822. * Gets the color table url used to create the LUT texture
  70823. */
  70824. colorTableUrl: string;
  70825. /**
  70826. * Gets a string identifying the name of the class
  70827. * @returns "ColorCorrectionPostProcess" string
  70828. */
  70829. getClassName(): string;
  70830. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70831. /** @hidden */
  70832. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70833. }
  70834. }
  70835. declare module BABYLON {
  70836. /** @hidden */
  70837. export var convolutionPixelShader: {
  70838. name: string;
  70839. shader: string;
  70840. };
  70841. }
  70842. declare module BABYLON {
  70843. /**
  70844. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70845. * input texture to perform effects such as edge detection or sharpening
  70846. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70847. */
  70848. export class ConvolutionPostProcess extends PostProcess {
  70849. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70850. kernel: number[];
  70851. /**
  70852. * Gets a string identifying the name of the class
  70853. * @returns "ConvolutionPostProcess" string
  70854. */
  70855. getClassName(): string;
  70856. /**
  70857. * Creates a new instance ConvolutionPostProcess
  70858. * @param name The name of the effect.
  70859. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70860. * @param options The required width/height ratio to downsize to before computing the render pass.
  70861. * @param camera The camera to apply the render pass to.
  70862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70863. * @param engine The engine which the post process will be applied. (default: current engine)
  70864. * @param reusable If the post process can be reused on the same frame. (default: false)
  70865. * @param textureType Type of textures used when performing the post process. (default: 0)
  70866. */
  70867. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70868. /** @hidden */
  70869. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70870. /**
  70871. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70872. */
  70873. static EdgeDetect0Kernel: number[];
  70874. /**
  70875. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70876. */
  70877. static EdgeDetect1Kernel: number[];
  70878. /**
  70879. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70880. */
  70881. static EdgeDetect2Kernel: number[];
  70882. /**
  70883. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70884. */
  70885. static SharpenKernel: number[];
  70886. /**
  70887. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70888. */
  70889. static EmbossKernel: number[];
  70890. /**
  70891. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70892. */
  70893. static GaussianKernel: number[];
  70894. }
  70895. }
  70896. declare module BABYLON {
  70897. /**
  70898. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70899. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70900. * based on samples that have a large difference in distance than the center pixel.
  70901. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70902. */
  70903. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70904. /**
  70905. * The direction the blur should be applied
  70906. */
  70907. direction: Vector2;
  70908. /**
  70909. * Gets a string identifying the name of the class
  70910. * @returns "DepthOfFieldBlurPostProcess" string
  70911. */
  70912. getClassName(): string;
  70913. /**
  70914. * Creates a new instance CircleOfConfusionPostProcess
  70915. * @param name The name of the effect.
  70916. * @param scene The scene the effect belongs to.
  70917. * @param direction The direction the blur should be applied.
  70918. * @param kernel The size of the kernel used to blur.
  70919. * @param options The required width/height ratio to downsize to before computing the render pass.
  70920. * @param camera The camera to apply the render pass to.
  70921. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70922. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70924. * @param engine The engine which the post process will be applied. (default: current engine)
  70925. * @param reusable If the post process can be reused on the same frame. (default: false)
  70926. * @param textureType Type of textures used when performing the post process. (default: 0)
  70927. * @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)
  70928. */
  70929. 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);
  70930. }
  70931. }
  70932. declare module BABYLON {
  70933. /** @hidden */
  70934. export var depthOfFieldMergePixelShader: {
  70935. name: string;
  70936. shader: string;
  70937. };
  70938. }
  70939. declare module BABYLON {
  70940. /**
  70941. * Options to be set when merging outputs from the default pipeline.
  70942. */
  70943. export class DepthOfFieldMergePostProcessOptions {
  70944. /**
  70945. * The original image to merge on top of
  70946. */
  70947. originalFromInput: PostProcess;
  70948. /**
  70949. * Parameters to perform the merge of the depth of field effect
  70950. */
  70951. depthOfField?: {
  70952. circleOfConfusion: PostProcess;
  70953. blurSteps: Array<PostProcess>;
  70954. };
  70955. /**
  70956. * Parameters to perform the merge of bloom effect
  70957. */
  70958. bloom?: {
  70959. blurred: PostProcess;
  70960. weight: number;
  70961. };
  70962. }
  70963. /**
  70964. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70965. */
  70966. export class DepthOfFieldMergePostProcess extends PostProcess {
  70967. private blurSteps;
  70968. /**
  70969. * Gets a string identifying the name of the class
  70970. * @returns "DepthOfFieldMergePostProcess" string
  70971. */
  70972. getClassName(): string;
  70973. /**
  70974. * Creates a new instance of DepthOfFieldMergePostProcess
  70975. * @param name The name of the effect.
  70976. * @param originalFromInput Post process which's input will be used for the merge.
  70977. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70978. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70979. * @param options The required width/height ratio to downsize to before computing the render pass.
  70980. * @param camera The camera to apply the render pass to.
  70981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70982. * @param engine The engine which the post process will be applied. (default: current engine)
  70983. * @param reusable If the post process can be reused on the same frame. (default: false)
  70984. * @param textureType Type of textures used when performing the post process. (default: 0)
  70985. * @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)
  70986. */
  70987. 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);
  70988. /**
  70989. * Updates the effect with the current post process compile time values and recompiles the shader.
  70990. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70991. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70992. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70993. * @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
  70994. * @param onCompiled Called when the shader has been compiled.
  70995. * @param onError Called if there is an error when compiling a shader.
  70996. */
  70997. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70998. }
  70999. }
  71000. declare module BABYLON {
  71001. /**
  71002. * Specifies the level of max blur that should be applied when using the depth of field effect
  71003. */
  71004. export enum DepthOfFieldEffectBlurLevel {
  71005. /**
  71006. * Subtle blur
  71007. */
  71008. Low = 0,
  71009. /**
  71010. * Medium blur
  71011. */
  71012. Medium = 1,
  71013. /**
  71014. * Large blur
  71015. */
  71016. High = 2
  71017. }
  71018. /**
  71019. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71020. */
  71021. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71022. private _circleOfConfusion;
  71023. /**
  71024. * @hidden Internal, blurs from high to low
  71025. */
  71026. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71027. private _depthOfFieldBlurY;
  71028. private _dofMerge;
  71029. /**
  71030. * @hidden Internal post processes in depth of field effect
  71031. */
  71032. _effects: Array<PostProcess>;
  71033. /**
  71034. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71035. */
  71036. set focalLength(value: number);
  71037. get focalLength(): number;
  71038. /**
  71039. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71040. */
  71041. set fStop(value: number);
  71042. get fStop(): number;
  71043. /**
  71044. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71045. */
  71046. set focusDistance(value: number);
  71047. get focusDistance(): number;
  71048. /**
  71049. * 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.
  71050. */
  71051. set lensSize(value: number);
  71052. get lensSize(): number;
  71053. /**
  71054. * Creates a new instance DepthOfFieldEffect
  71055. * @param scene The scene the effect belongs to.
  71056. * @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.
  71057. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71058. * @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)
  71059. */
  71060. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71061. /**
  71062. * Get the current class name of the current effet
  71063. * @returns "DepthOfFieldEffect"
  71064. */
  71065. getClassName(): string;
  71066. /**
  71067. * 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.
  71068. */
  71069. set depthTexture(value: RenderTargetTexture);
  71070. /**
  71071. * Disposes each of the internal effects for a given camera.
  71072. * @param camera The camera to dispose the effect on.
  71073. */
  71074. disposeEffects(camera: Camera): void;
  71075. /**
  71076. * @hidden Internal
  71077. */
  71078. _updateEffects(): void;
  71079. /**
  71080. * Internal
  71081. * @returns if all the contained post processes are ready.
  71082. * @hidden
  71083. */
  71084. _isReady(): boolean;
  71085. }
  71086. }
  71087. declare module BABYLON {
  71088. /** @hidden */
  71089. export var displayPassPixelShader: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module BABYLON {
  71095. /**
  71096. * DisplayPassPostProcess which produces an output the same as it's input
  71097. */
  71098. export class DisplayPassPostProcess extends PostProcess {
  71099. /**
  71100. * Gets a string identifying the name of the class
  71101. * @returns "DisplayPassPostProcess" string
  71102. */
  71103. getClassName(): string;
  71104. /**
  71105. * Creates the DisplayPassPostProcess
  71106. * @param name The name of the effect.
  71107. * @param options The required width/height ratio to downsize to before computing the render pass.
  71108. * @param camera The camera to apply the render pass to.
  71109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71110. * @param engine The engine which the post process will be applied. (default: current engine)
  71111. * @param reusable If the post process can be reused on the same frame. (default: false)
  71112. */
  71113. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71114. /** @hidden */
  71115. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /** @hidden */
  71120. export var filterPixelShader: {
  71121. name: string;
  71122. shader: string;
  71123. };
  71124. }
  71125. declare module BABYLON {
  71126. /**
  71127. * Applies a kernel filter to the image
  71128. */
  71129. export class FilterPostProcess extends PostProcess {
  71130. /** The matrix to be applied to the image */
  71131. kernelMatrix: Matrix;
  71132. /**
  71133. * Gets a string identifying the name of the class
  71134. * @returns "FilterPostProcess" string
  71135. */
  71136. getClassName(): string;
  71137. /**
  71138. *
  71139. * @param name The name of the effect.
  71140. * @param kernelMatrix The matrix to be applied to the image
  71141. * @param options The required width/height ratio to downsize to before computing the render pass.
  71142. * @param camera The camera to apply the render pass to.
  71143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71144. * @param engine The engine which the post process will be applied. (default: current engine)
  71145. * @param reusable If the post process can be reused on the same frame. (default: false)
  71146. */
  71147. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71148. /** @hidden */
  71149. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71150. }
  71151. }
  71152. declare module BABYLON {
  71153. /** @hidden */
  71154. export var fxaaPixelShader: {
  71155. name: string;
  71156. shader: string;
  71157. };
  71158. }
  71159. declare module BABYLON {
  71160. /** @hidden */
  71161. export var fxaaVertexShader: {
  71162. name: string;
  71163. shader: string;
  71164. };
  71165. }
  71166. declare module BABYLON {
  71167. /**
  71168. * Fxaa post process
  71169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71170. */
  71171. export class FxaaPostProcess extends PostProcess {
  71172. /**
  71173. * Gets a string identifying the name of the class
  71174. * @returns "FxaaPostProcess" string
  71175. */
  71176. getClassName(): string;
  71177. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71178. private _getDefines;
  71179. /** @hidden */
  71180. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71181. }
  71182. }
  71183. declare module BABYLON {
  71184. /** @hidden */
  71185. export var grainPixelShader: {
  71186. name: string;
  71187. shader: string;
  71188. };
  71189. }
  71190. declare module BABYLON {
  71191. /**
  71192. * The GrainPostProcess adds noise to the image at mid luminance levels
  71193. */
  71194. export class GrainPostProcess extends PostProcess {
  71195. /**
  71196. * The intensity of the grain added (default: 30)
  71197. */
  71198. intensity: number;
  71199. /**
  71200. * If the grain should be randomized on every frame
  71201. */
  71202. animated: boolean;
  71203. /**
  71204. * Gets a string identifying the name of the class
  71205. * @returns "GrainPostProcess" string
  71206. */
  71207. getClassName(): string;
  71208. /**
  71209. * Creates a new instance of @see GrainPostProcess
  71210. * @param name The name of the effect.
  71211. * @param options The required width/height ratio to downsize to before computing the render pass.
  71212. * @param camera The camera to apply the render pass to.
  71213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71214. * @param engine The engine which the post process will be applied. (default: current engine)
  71215. * @param reusable If the post process can be reused on the same frame. (default: false)
  71216. * @param textureType Type of textures used when performing the post process. (default: 0)
  71217. * @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)
  71218. */
  71219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71220. /** @hidden */
  71221. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71222. }
  71223. }
  71224. declare module BABYLON {
  71225. /** @hidden */
  71226. export var highlightsPixelShader: {
  71227. name: string;
  71228. shader: string;
  71229. };
  71230. }
  71231. declare module BABYLON {
  71232. /**
  71233. * Extracts highlights from the image
  71234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71235. */
  71236. export class HighlightsPostProcess extends PostProcess {
  71237. /**
  71238. * Gets a string identifying the name of the class
  71239. * @returns "HighlightsPostProcess" string
  71240. */
  71241. getClassName(): string;
  71242. /**
  71243. * Extracts highlights from the image
  71244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71245. * @param name The name of the effect.
  71246. * @param options The required width/height ratio to downsize to before computing the render pass.
  71247. * @param camera The camera to apply the render pass to.
  71248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71249. * @param engine The engine which the post process will be applied. (default: current engine)
  71250. * @param reusable If the post process can be reused on the same frame. (default: false)
  71251. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71252. */
  71253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71254. }
  71255. }
  71256. declare module BABYLON {
  71257. /**
  71258. * Contains all parameters needed for the prepass to perform
  71259. * motion blur
  71260. */
  71261. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71262. /**
  71263. * Is motion blur enabled
  71264. */
  71265. enabled: boolean;
  71266. /**
  71267. * Name of the configuration
  71268. */
  71269. name: string;
  71270. /**
  71271. * Textures that should be present in the MRT for this effect to work
  71272. */
  71273. readonly texturesRequired: number[];
  71274. }
  71275. }
  71276. declare module BABYLON {
  71277. interface Scene {
  71278. /** @hidden (Backing field) */
  71279. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71280. /**
  71281. * Gets or Sets the current geometry buffer associated to the scene.
  71282. */
  71283. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71284. /**
  71285. * Enables a GeometryBufferRender and associates it with the scene
  71286. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71287. * @returns the GeometryBufferRenderer
  71288. */
  71289. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71290. /**
  71291. * Disables the GeometryBufferRender associated with the scene
  71292. */
  71293. disableGeometryBufferRenderer(): void;
  71294. }
  71295. /**
  71296. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71297. * in several rendering techniques.
  71298. */
  71299. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71300. /**
  71301. * The component name helpful to identify the component in the list of scene components.
  71302. */
  71303. readonly name: string;
  71304. /**
  71305. * The scene the component belongs to.
  71306. */
  71307. scene: Scene;
  71308. /**
  71309. * Creates a new instance of the component for the given scene
  71310. * @param scene Defines the scene to register the component in
  71311. */
  71312. constructor(scene: Scene);
  71313. /**
  71314. * Registers the component in a given scene
  71315. */
  71316. register(): void;
  71317. /**
  71318. * Rebuilds the elements related to this component in case of
  71319. * context lost for instance.
  71320. */
  71321. rebuild(): void;
  71322. /**
  71323. * Disposes the component and the associated ressources
  71324. */
  71325. dispose(): void;
  71326. private _gatherRenderTargets;
  71327. }
  71328. }
  71329. declare module BABYLON {
  71330. /** @hidden */
  71331. export var motionBlurPixelShader: {
  71332. name: string;
  71333. shader: string;
  71334. };
  71335. }
  71336. declare module BABYLON {
  71337. /**
  71338. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71339. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71340. * As an example, all you have to do is to create the post-process:
  71341. * var mb = new BABYLON.MotionBlurPostProcess(
  71342. * 'mb', // The name of the effect.
  71343. * scene, // The scene containing the objects to blur according to their velocity.
  71344. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71345. * camera // The camera to apply the render pass to.
  71346. * );
  71347. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71348. */
  71349. export class MotionBlurPostProcess extends PostProcess {
  71350. /**
  71351. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71352. */
  71353. motionStrength: number;
  71354. /**
  71355. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71356. */
  71357. get motionBlurSamples(): number;
  71358. /**
  71359. * Sets the number of iterations to be used for motion blur quality
  71360. */
  71361. set motionBlurSamples(samples: number);
  71362. private _motionBlurSamples;
  71363. /**
  71364. * Gets wether or not the motion blur post-process is in object based mode.
  71365. */
  71366. get isObjectBased(): boolean;
  71367. /**
  71368. * Sets wether or not the motion blur post-process is in object based mode.
  71369. */
  71370. set isObjectBased(value: boolean);
  71371. private _isObjectBased;
  71372. private _forceGeometryBuffer;
  71373. private _geometryBufferRenderer;
  71374. private _prePassRenderer;
  71375. private _invViewProjection;
  71376. private _previousViewProjection;
  71377. /**
  71378. * Gets a string identifying the name of the class
  71379. * @returns "MotionBlurPostProcess" string
  71380. */
  71381. getClassName(): string;
  71382. /**
  71383. * Creates a new instance MotionBlurPostProcess
  71384. * @param name The name of the effect.
  71385. * @param scene The scene containing the objects to blur according to their velocity.
  71386. * @param options The required width/height ratio to downsize to before computing the render pass.
  71387. * @param camera The camera to apply the render pass to.
  71388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71389. * @param engine The engine which the post process will be applied. (default: current engine)
  71390. * @param reusable If the post process can be reused on the same frame. (default: false)
  71391. * @param textureType Type of textures used when performing the post process. (default: 0)
  71392. * @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: true)
  71393. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71394. */
  71395. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71396. /**
  71397. * Excludes the given skinned mesh from computing bones velocities.
  71398. * 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.
  71399. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71400. */
  71401. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71402. /**
  71403. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71404. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71405. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71406. */
  71407. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71408. /**
  71409. * Disposes the post process.
  71410. * @param camera The camera to dispose the post process on.
  71411. */
  71412. dispose(camera?: Camera): void;
  71413. /**
  71414. * Called on the mode changed (object based or screen based).
  71415. */
  71416. private _applyMode;
  71417. /**
  71418. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71419. */
  71420. private _onApplyObjectBased;
  71421. /**
  71422. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71423. */
  71424. private _onApplyScreenBased;
  71425. /**
  71426. * Called on the effect must be updated (changed mode, samples count, etc.).
  71427. */
  71428. private _updateEffect;
  71429. /** @hidden */
  71430. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71431. }
  71432. }
  71433. declare module BABYLON {
  71434. /** @hidden */
  71435. export var refractionPixelShader: {
  71436. name: string;
  71437. shader: string;
  71438. };
  71439. }
  71440. declare module BABYLON {
  71441. /**
  71442. * Post process which applies a refractin texture
  71443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71444. */
  71445. export class RefractionPostProcess extends PostProcess {
  71446. private _refTexture;
  71447. private _ownRefractionTexture;
  71448. /** the base color of the refraction (used to taint the rendering) */
  71449. color: Color3;
  71450. /** simulated refraction depth */
  71451. depth: number;
  71452. /** the coefficient of the base color (0 to remove base color tainting) */
  71453. colorLevel: number;
  71454. /** Gets the url used to load the refraction texture */
  71455. refractionTextureUrl: string;
  71456. /**
  71457. * Gets or sets the refraction texture
  71458. * Please note that you are responsible for disposing the texture if you set it manually
  71459. */
  71460. get refractionTexture(): Texture;
  71461. set refractionTexture(value: Texture);
  71462. /**
  71463. * Gets a string identifying the name of the class
  71464. * @returns "RefractionPostProcess" string
  71465. */
  71466. getClassName(): string;
  71467. /**
  71468. * Initializes the RefractionPostProcess
  71469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71470. * @param name The name of the effect.
  71471. * @param refractionTextureUrl Url of the refraction texture to use
  71472. * @param color the base color of the refraction (used to taint the rendering)
  71473. * @param depth simulated refraction depth
  71474. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71475. * @param camera The camera to apply the render pass to.
  71476. * @param options The required width/height ratio to downsize to before computing the render pass.
  71477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71478. * @param engine The engine which the post process will be applied. (default: current engine)
  71479. * @param reusable If the post process can be reused on the same frame. (default: false)
  71480. */
  71481. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71482. /**
  71483. * Disposes of the post process
  71484. * @param camera Camera to dispose post process on
  71485. */
  71486. dispose(camera: Camera): void;
  71487. /** @hidden */
  71488. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71489. }
  71490. }
  71491. declare module BABYLON {
  71492. /** @hidden */
  71493. export var sharpenPixelShader: {
  71494. name: string;
  71495. shader: string;
  71496. };
  71497. }
  71498. declare module BABYLON {
  71499. /**
  71500. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71501. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71502. */
  71503. export class SharpenPostProcess extends PostProcess {
  71504. /**
  71505. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71506. */
  71507. colorAmount: number;
  71508. /**
  71509. * How much sharpness should be applied (default: 0.3)
  71510. */
  71511. edgeAmount: number;
  71512. /**
  71513. * Gets a string identifying the name of the class
  71514. * @returns "SharpenPostProcess" string
  71515. */
  71516. getClassName(): string;
  71517. /**
  71518. * Creates a new instance ConvolutionPostProcess
  71519. * @param name The name of the effect.
  71520. * @param options The required width/height ratio to downsize to before computing the render pass.
  71521. * @param camera The camera to apply the render pass to.
  71522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71523. * @param engine The engine which the post process will be applied. (default: current engine)
  71524. * @param reusable If the post process can be reused on the same frame. (default: false)
  71525. * @param textureType Type of textures used when performing the post process. (default: 0)
  71526. * @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)
  71527. */
  71528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71529. /** @hidden */
  71530. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71531. }
  71532. }
  71533. declare module BABYLON {
  71534. /**
  71535. * PostProcessRenderPipeline
  71536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71537. */
  71538. export class PostProcessRenderPipeline {
  71539. private engine;
  71540. private _renderEffects;
  71541. private _renderEffectsForIsolatedPass;
  71542. /**
  71543. * List of inspectable custom properties (used by the Inspector)
  71544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71545. */
  71546. inspectableCustomProperties: IInspectable[];
  71547. /**
  71548. * @hidden
  71549. */
  71550. protected _cameras: Camera[];
  71551. /** @hidden */
  71552. _name: string;
  71553. /**
  71554. * Gets pipeline name
  71555. */
  71556. get name(): string;
  71557. /** Gets the list of attached cameras */
  71558. get cameras(): Camera[];
  71559. /**
  71560. * Initializes a PostProcessRenderPipeline
  71561. * @param engine engine to add the pipeline to
  71562. * @param name name of the pipeline
  71563. */
  71564. constructor(engine: Engine, name: string);
  71565. /**
  71566. * Gets the class name
  71567. * @returns "PostProcessRenderPipeline"
  71568. */
  71569. getClassName(): string;
  71570. /**
  71571. * If all the render effects in the pipeline are supported
  71572. */
  71573. get isSupported(): boolean;
  71574. /**
  71575. * Adds an effect to the pipeline
  71576. * @param renderEffect the effect to add
  71577. */
  71578. addEffect(renderEffect: PostProcessRenderEffect): void;
  71579. /** @hidden */
  71580. _rebuild(): void;
  71581. /** @hidden */
  71582. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71583. /** @hidden */
  71584. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71585. /** @hidden */
  71586. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71587. /** @hidden */
  71588. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71589. /** @hidden */
  71590. _attachCameras(cameras: Camera, unique: boolean): void;
  71591. /** @hidden */
  71592. _attachCameras(cameras: Camera[], unique: boolean): void;
  71593. /** @hidden */
  71594. _detachCameras(cameras: Camera): void;
  71595. /** @hidden */
  71596. _detachCameras(cameras: Nullable<Camera[]>): void;
  71597. /** @hidden */
  71598. _update(): void;
  71599. /** @hidden */
  71600. _reset(): void;
  71601. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71602. /**
  71603. * Sets the required values to the prepass renderer.
  71604. * @param prePassRenderer defines the prepass renderer to setup.
  71605. * @returns true if the pre pass is needed.
  71606. */
  71607. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71608. /**
  71609. * Disposes of the pipeline
  71610. */
  71611. dispose(): void;
  71612. }
  71613. }
  71614. declare module BABYLON {
  71615. /**
  71616. * PostProcessRenderPipelineManager class
  71617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71618. */
  71619. export class PostProcessRenderPipelineManager {
  71620. private _renderPipelines;
  71621. /**
  71622. * Initializes a PostProcessRenderPipelineManager
  71623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71624. */
  71625. constructor();
  71626. /**
  71627. * Gets the list of supported render pipelines
  71628. */
  71629. get supportedPipelines(): PostProcessRenderPipeline[];
  71630. /**
  71631. * Adds a pipeline to the manager
  71632. * @param renderPipeline The pipeline to add
  71633. */
  71634. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71635. /**
  71636. * Attaches a camera to the pipeline
  71637. * @param renderPipelineName The name of the pipeline to attach to
  71638. * @param cameras the camera to attach
  71639. * @param unique if the camera can be attached multiple times to the pipeline
  71640. */
  71641. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71642. /**
  71643. * Detaches a camera from the pipeline
  71644. * @param renderPipelineName The name of the pipeline to detach from
  71645. * @param cameras the camera to detach
  71646. */
  71647. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71648. /**
  71649. * Enables an effect by name on a pipeline
  71650. * @param renderPipelineName the name of the pipeline to enable the effect in
  71651. * @param renderEffectName the name of the effect to enable
  71652. * @param cameras the cameras that the effect should be enabled on
  71653. */
  71654. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71655. /**
  71656. * Disables an effect by name on a pipeline
  71657. * @param renderPipelineName the name of the pipeline to disable the effect in
  71658. * @param renderEffectName the name of the effect to disable
  71659. * @param cameras the cameras that the effect should be disabled on
  71660. */
  71661. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71662. /**
  71663. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71664. */
  71665. update(): void;
  71666. /** @hidden */
  71667. _rebuild(): void;
  71668. /**
  71669. * Disposes of the manager and pipelines
  71670. */
  71671. dispose(): void;
  71672. }
  71673. }
  71674. declare module BABYLON {
  71675. interface Scene {
  71676. /** @hidden (Backing field) */
  71677. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71678. /**
  71679. * Gets the postprocess render pipeline manager
  71680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71681. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71682. */
  71683. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71684. }
  71685. /**
  71686. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71687. */
  71688. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71689. /**
  71690. * The component name helpfull to identify the component in the list of scene components.
  71691. */
  71692. readonly name: string;
  71693. /**
  71694. * The scene the component belongs to.
  71695. */
  71696. scene: Scene;
  71697. /**
  71698. * Creates a new instance of the component for the given scene
  71699. * @param scene Defines the scene to register the component in
  71700. */
  71701. constructor(scene: Scene);
  71702. /**
  71703. * Registers the component in a given scene
  71704. */
  71705. register(): void;
  71706. /**
  71707. * Rebuilds the elements related to this component in case of
  71708. * context lost for instance.
  71709. */
  71710. rebuild(): void;
  71711. /**
  71712. * Disposes the component and the associated ressources
  71713. */
  71714. dispose(): void;
  71715. private _gatherRenderTargets;
  71716. }
  71717. }
  71718. declare module BABYLON {
  71719. /**
  71720. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71721. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71722. */
  71723. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71724. private _scene;
  71725. private _camerasToBeAttached;
  71726. /**
  71727. * ID of the sharpen post process,
  71728. */
  71729. private readonly SharpenPostProcessId;
  71730. /**
  71731. * @ignore
  71732. * ID of the image processing post process;
  71733. */
  71734. readonly ImageProcessingPostProcessId: string;
  71735. /**
  71736. * @ignore
  71737. * ID of the Fast Approximate Anti-Aliasing post process;
  71738. */
  71739. readonly FxaaPostProcessId: string;
  71740. /**
  71741. * ID of the chromatic aberration post process,
  71742. */
  71743. private readonly ChromaticAberrationPostProcessId;
  71744. /**
  71745. * ID of the grain post process
  71746. */
  71747. private readonly GrainPostProcessId;
  71748. /**
  71749. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71750. */
  71751. sharpen: SharpenPostProcess;
  71752. private _sharpenEffect;
  71753. private bloom;
  71754. /**
  71755. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71756. */
  71757. depthOfField: DepthOfFieldEffect;
  71758. /**
  71759. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71760. */
  71761. fxaa: FxaaPostProcess;
  71762. /**
  71763. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71764. */
  71765. imageProcessing: ImageProcessingPostProcess;
  71766. /**
  71767. * Chromatic aberration post process which will shift rgb colors in the image
  71768. */
  71769. chromaticAberration: ChromaticAberrationPostProcess;
  71770. private _chromaticAberrationEffect;
  71771. /**
  71772. * Grain post process which add noise to the image
  71773. */
  71774. grain: GrainPostProcess;
  71775. private _grainEffect;
  71776. /**
  71777. * Glow post process which adds a glow to emissive areas of the image
  71778. */
  71779. private _glowLayer;
  71780. /**
  71781. * Animations which can be used to tweak settings over a period of time
  71782. */
  71783. animations: Animation[];
  71784. private _imageProcessingConfigurationObserver;
  71785. private _sharpenEnabled;
  71786. private _bloomEnabled;
  71787. private _depthOfFieldEnabled;
  71788. private _depthOfFieldBlurLevel;
  71789. private _fxaaEnabled;
  71790. private _imageProcessingEnabled;
  71791. private _defaultPipelineTextureType;
  71792. private _bloomScale;
  71793. private _chromaticAberrationEnabled;
  71794. private _grainEnabled;
  71795. private _buildAllowed;
  71796. /**
  71797. * This is triggered each time the pipeline has been built.
  71798. */
  71799. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71800. /**
  71801. * Gets active scene
  71802. */
  71803. get scene(): Scene;
  71804. /**
  71805. * Enable or disable the sharpen process from the pipeline
  71806. */
  71807. set sharpenEnabled(enabled: boolean);
  71808. get sharpenEnabled(): boolean;
  71809. private _resizeObserver;
  71810. private _hardwareScaleLevel;
  71811. private _bloomKernel;
  71812. /**
  71813. * Specifies the size of the bloom blur kernel, relative to the final output size
  71814. */
  71815. get bloomKernel(): number;
  71816. set bloomKernel(value: number);
  71817. /**
  71818. * Specifies the weight of the bloom in the final rendering
  71819. */
  71820. private _bloomWeight;
  71821. /**
  71822. * Specifies the luma threshold for the area that will be blurred by the bloom
  71823. */
  71824. private _bloomThreshold;
  71825. private _hdr;
  71826. /**
  71827. * The strength of the bloom.
  71828. */
  71829. set bloomWeight(value: number);
  71830. get bloomWeight(): number;
  71831. /**
  71832. * The strength of the bloom.
  71833. */
  71834. set bloomThreshold(value: number);
  71835. get bloomThreshold(): number;
  71836. /**
  71837. * The scale of the bloom, lower value will provide better performance.
  71838. */
  71839. set bloomScale(value: number);
  71840. get bloomScale(): number;
  71841. /**
  71842. * Enable or disable the bloom from the pipeline
  71843. */
  71844. set bloomEnabled(enabled: boolean);
  71845. get bloomEnabled(): boolean;
  71846. private _rebuildBloom;
  71847. /**
  71848. * If the depth of field is enabled.
  71849. */
  71850. get depthOfFieldEnabled(): boolean;
  71851. set depthOfFieldEnabled(enabled: boolean);
  71852. /**
  71853. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71854. */
  71855. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71856. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71857. /**
  71858. * If the anti aliasing is enabled.
  71859. */
  71860. set fxaaEnabled(enabled: boolean);
  71861. get fxaaEnabled(): boolean;
  71862. private _samples;
  71863. /**
  71864. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71865. */
  71866. set samples(sampleCount: number);
  71867. get samples(): number;
  71868. /**
  71869. * If image processing is enabled.
  71870. */
  71871. set imageProcessingEnabled(enabled: boolean);
  71872. get imageProcessingEnabled(): boolean;
  71873. /**
  71874. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71875. */
  71876. set glowLayerEnabled(enabled: boolean);
  71877. get glowLayerEnabled(): boolean;
  71878. /**
  71879. * Gets the glow layer (or null if not defined)
  71880. */
  71881. get glowLayer(): Nullable<GlowLayer>;
  71882. /**
  71883. * Enable or disable the chromaticAberration process from the pipeline
  71884. */
  71885. set chromaticAberrationEnabled(enabled: boolean);
  71886. get chromaticAberrationEnabled(): boolean;
  71887. /**
  71888. * Enable or disable the grain process from the pipeline
  71889. */
  71890. set grainEnabled(enabled: boolean);
  71891. get grainEnabled(): boolean;
  71892. /**
  71893. * @constructor
  71894. * @param name - The rendering pipeline name (default: "")
  71895. * @param hdr - If high dynamic range textures should be used (default: true)
  71896. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71897. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71898. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71899. */
  71900. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71901. /**
  71902. * Get the class name
  71903. * @returns "DefaultRenderingPipeline"
  71904. */
  71905. getClassName(): string;
  71906. /**
  71907. * Force the compilation of the entire pipeline.
  71908. */
  71909. prepare(): void;
  71910. private _hasCleared;
  71911. private _prevPostProcess;
  71912. private _prevPrevPostProcess;
  71913. private _setAutoClearAndTextureSharing;
  71914. private _depthOfFieldSceneObserver;
  71915. private _buildPipeline;
  71916. private _disposePostProcesses;
  71917. /**
  71918. * Adds a camera to the pipeline
  71919. * @param camera the camera to be added
  71920. */
  71921. addCamera(camera: Camera): void;
  71922. /**
  71923. * Removes a camera from the pipeline
  71924. * @param camera the camera to remove
  71925. */
  71926. removeCamera(camera: Camera): void;
  71927. /**
  71928. * Dispose of the pipeline and stop all post processes
  71929. */
  71930. dispose(): void;
  71931. /**
  71932. * Serialize the rendering pipeline (Used when exporting)
  71933. * @returns the serialized object
  71934. */
  71935. serialize(): any;
  71936. /**
  71937. * Parse the serialized pipeline
  71938. * @param source Source pipeline.
  71939. * @param scene The scene to load the pipeline to.
  71940. * @param rootUrl The URL of the serialized pipeline.
  71941. * @returns An instantiated pipeline from the serialized object.
  71942. */
  71943. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71944. }
  71945. }
  71946. declare module BABYLON {
  71947. /** @hidden */
  71948. export var lensHighlightsPixelShader: {
  71949. name: string;
  71950. shader: string;
  71951. };
  71952. }
  71953. declare module BABYLON {
  71954. /** @hidden */
  71955. export var depthOfFieldPixelShader: {
  71956. name: string;
  71957. shader: string;
  71958. };
  71959. }
  71960. declare module BABYLON {
  71961. /**
  71962. * BABYLON.JS Chromatic Aberration GLSL Shader
  71963. * Author: Olivier Guyot
  71964. * Separates very slightly R, G and B colors on the edges of the screen
  71965. * Inspired by Francois Tarlier & Martins Upitis
  71966. */
  71967. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71968. /**
  71969. * @ignore
  71970. * The chromatic aberration PostProcess id in the pipeline
  71971. */
  71972. LensChromaticAberrationEffect: string;
  71973. /**
  71974. * @ignore
  71975. * The highlights enhancing PostProcess id in the pipeline
  71976. */
  71977. HighlightsEnhancingEffect: string;
  71978. /**
  71979. * @ignore
  71980. * The depth-of-field PostProcess id in the pipeline
  71981. */
  71982. LensDepthOfFieldEffect: string;
  71983. private _scene;
  71984. private _depthTexture;
  71985. private _grainTexture;
  71986. private _chromaticAberrationPostProcess;
  71987. private _highlightsPostProcess;
  71988. private _depthOfFieldPostProcess;
  71989. private _edgeBlur;
  71990. private _grainAmount;
  71991. private _chromaticAberration;
  71992. private _distortion;
  71993. private _highlightsGain;
  71994. private _highlightsThreshold;
  71995. private _dofDistance;
  71996. private _dofAperture;
  71997. private _dofDarken;
  71998. private _dofPentagon;
  71999. private _blurNoise;
  72000. /**
  72001. * @constructor
  72002. *
  72003. * Effect parameters are as follow:
  72004. * {
  72005. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72006. * edge_blur: number; // from 0 to x (1 for realism)
  72007. * distortion: number; // from 0 to x (1 for realism)
  72008. * grain_amount: number; // from 0 to 1
  72009. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72010. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72011. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72012. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72013. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72014. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72015. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72016. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72017. * }
  72018. * Note: if an effect parameter is unset, effect is disabled
  72019. *
  72020. * @param name The rendering pipeline name
  72021. * @param parameters - An object containing all parameters (see above)
  72022. * @param scene The scene linked to this pipeline
  72023. * @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)
  72024. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72025. */
  72026. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72027. /**
  72028. * Get the class name
  72029. * @returns "LensRenderingPipeline"
  72030. */
  72031. getClassName(): string;
  72032. /**
  72033. * Gets associated scene
  72034. */
  72035. get scene(): Scene;
  72036. /**
  72037. * Gets or sets the edge blur
  72038. */
  72039. get edgeBlur(): number;
  72040. set edgeBlur(value: number);
  72041. /**
  72042. * Gets or sets the grain amount
  72043. */
  72044. get grainAmount(): number;
  72045. set grainAmount(value: number);
  72046. /**
  72047. * Gets or sets the chromatic aberration amount
  72048. */
  72049. get chromaticAberration(): number;
  72050. set chromaticAberration(value: number);
  72051. /**
  72052. * Gets or sets the depth of field aperture
  72053. */
  72054. get dofAperture(): number;
  72055. set dofAperture(value: number);
  72056. /**
  72057. * Gets or sets the edge distortion
  72058. */
  72059. get edgeDistortion(): number;
  72060. set edgeDistortion(value: number);
  72061. /**
  72062. * Gets or sets the depth of field distortion
  72063. */
  72064. get dofDistortion(): number;
  72065. set dofDistortion(value: number);
  72066. /**
  72067. * Gets or sets the darken out of focus amount
  72068. */
  72069. get darkenOutOfFocus(): number;
  72070. set darkenOutOfFocus(value: number);
  72071. /**
  72072. * Gets or sets a boolean indicating if blur noise is enabled
  72073. */
  72074. get blurNoise(): boolean;
  72075. set blurNoise(value: boolean);
  72076. /**
  72077. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72078. */
  72079. get pentagonBokeh(): boolean;
  72080. set pentagonBokeh(value: boolean);
  72081. /**
  72082. * Gets or sets the highlight grain amount
  72083. */
  72084. get highlightsGain(): number;
  72085. set highlightsGain(value: number);
  72086. /**
  72087. * Gets or sets the highlight threshold
  72088. */
  72089. get highlightsThreshold(): number;
  72090. set highlightsThreshold(value: number);
  72091. /**
  72092. * Sets the amount of blur at the edges
  72093. * @param amount blur amount
  72094. */
  72095. setEdgeBlur(amount: number): void;
  72096. /**
  72097. * Sets edge blur to 0
  72098. */
  72099. disableEdgeBlur(): void;
  72100. /**
  72101. * Sets the amout of grain
  72102. * @param amount Amount of grain
  72103. */
  72104. setGrainAmount(amount: number): void;
  72105. /**
  72106. * Set grain amount to 0
  72107. */
  72108. disableGrain(): void;
  72109. /**
  72110. * Sets the chromatic aberration amount
  72111. * @param amount amount of chromatic aberration
  72112. */
  72113. setChromaticAberration(amount: number): void;
  72114. /**
  72115. * Sets chromatic aberration amount to 0
  72116. */
  72117. disableChromaticAberration(): void;
  72118. /**
  72119. * Sets the EdgeDistortion amount
  72120. * @param amount amount of EdgeDistortion
  72121. */
  72122. setEdgeDistortion(amount: number): void;
  72123. /**
  72124. * Sets edge distortion to 0
  72125. */
  72126. disableEdgeDistortion(): void;
  72127. /**
  72128. * Sets the FocusDistance amount
  72129. * @param amount amount of FocusDistance
  72130. */
  72131. setFocusDistance(amount: number): void;
  72132. /**
  72133. * Disables depth of field
  72134. */
  72135. disableDepthOfField(): void;
  72136. /**
  72137. * Sets the Aperture amount
  72138. * @param amount amount of Aperture
  72139. */
  72140. setAperture(amount: number): void;
  72141. /**
  72142. * Sets the DarkenOutOfFocus amount
  72143. * @param amount amount of DarkenOutOfFocus
  72144. */
  72145. setDarkenOutOfFocus(amount: number): void;
  72146. private _pentagonBokehIsEnabled;
  72147. /**
  72148. * Creates a pentagon bokeh effect
  72149. */
  72150. enablePentagonBokeh(): void;
  72151. /**
  72152. * Disables the pentagon bokeh effect
  72153. */
  72154. disablePentagonBokeh(): void;
  72155. /**
  72156. * Enables noise blur
  72157. */
  72158. enableNoiseBlur(): void;
  72159. /**
  72160. * Disables noise blur
  72161. */
  72162. disableNoiseBlur(): void;
  72163. /**
  72164. * Sets the HighlightsGain amount
  72165. * @param amount amount of HighlightsGain
  72166. */
  72167. setHighlightsGain(amount: number): void;
  72168. /**
  72169. * Sets the HighlightsThreshold amount
  72170. * @param amount amount of HighlightsThreshold
  72171. */
  72172. setHighlightsThreshold(amount: number): void;
  72173. /**
  72174. * Disables highlights
  72175. */
  72176. disableHighlights(): void;
  72177. /**
  72178. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72179. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72180. */
  72181. dispose(disableDepthRender?: boolean): void;
  72182. private _createChromaticAberrationPostProcess;
  72183. private _createHighlightsPostProcess;
  72184. private _createDepthOfFieldPostProcess;
  72185. private _createGrainTexture;
  72186. }
  72187. }
  72188. declare module BABYLON {
  72189. /**
  72190. * Contains all parameters needed for the prepass to perform
  72191. * screen space subsurface scattering
  72192. */
  72193. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72194. /**
  72195. * Is subsurface enabled
  72196. */
  72197. enabled: boolean;
  72198. /**
  72199. * Name of the configuration
  72200. */
  72201. name: string;
  72202. /**
  72203. * Textures that should be present in the MRT for this effect to work
  72204. */
  72205. readonly texturesRequired: number[];
  72206. }
  72207. }
  72208. declare module BABYLON {
  72209. /** @hidden */
  72210. export var ssao2PixelShader: {
  72211. name: string;
  72212. shader: string;
  72213. };
  72214. }
  72215. declare module BABYLON {
  72216. /** @hidden */
  72217. export var ssaoCombinePixelShader: {
  72218. name: string;
  72219. shader: string;
  72220. };
  72221. }
  72222. declare module BABYLON {
  72223. /**
  72224. * Render pipeline to produce ssao effect
  72225. */
  72226. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72227. /**
  72228. * @ignore
  72229. * The PassPostProcess id in the pipeline that contains the original scene color
  72230. */
  72231. SSAOOriginalSceneColorEffect: string;
  72232. /**
  72233. * @ignore
  72234. * The SSAO PostProcess id in the pipeline
  72235. */
  72236. SSAORenderEffect: string;
  72237. /**
  72238. * @ignore
  72239. * The horizontal blur PostProcess id in the pipeline
  72240. */
  72241. SSAOBlurHRenderEffect: string;
  72242. /**
  72243. * @ignore
  72244. * The vertical blur PostProcess id in the pipeline
  72245. */
  72246. SSAOBlurVRenderEffect: string;
  72247. /**
  72248. * @ignore
  72249. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72250. */
  72251. SSAOCombineRenderEffect: string;
  72252. /**
  72253. * The output strength of the SSAO post-process. Default value is 1.0.
  72254. */
  72255. totalStrength: number;
  72256. /**
  72257. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72258. */
  72259. maxZ: number;
  72260. /**
  72261. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72262. */
  72263. minZAspect: number;
  72264. private _samples;
  72265. /**
  72266. * Number of samples used for the SSAO calculations. Default value is 8
  72267. */
  72268. set samples(n: number);
  72269. get samples(): number;
  72270. private _textureSamples;
  72271. /**
  72272. * Number of samples to use for antialiasing
  72273. */
  72274. set textureSamples(n: number);
  72275. get textureSamples(): number;
  72276. /**
  72277. * Force rendering the geometry through geometry buffer
  72278. */
  72279. private _forceGeometryBuffer;
  72280. /**
  72281. * Ratio object used for SSAO ratio and blur ratio
  72282. */
  72283. private _ratio;
  72284. /**
  72285. * Dynamically generated sphere sampler.
  72286. */
  72287. private _sampleSphere;
  72288. /**
  72289. * Blur filter offsets
  72290. */
  72291. private _samplerOffsets;
  72292. private _expensiveBlur;
  72293. /**
  72294. * If bilateral blur should be used
  72295. */
  72296. set expensiveBlur(b: boolean);
  72297. get expensiveBlur(): boolean;
  72298. /**
  72299. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72300. */
  72301. radius: number;
  72302. /**
  72303. * The base color of the SSAO post-process
  72304. * The final result is "base + ssao" between [0, 1]
  72305. */
  72306. base: number;
  72307. /**
  72308. * Support test.
  72309. */
  72310. static get IsSupported(): boolean;
  72311. private _scene;
  72312. private _randomTexture;
  72313. private _originalColorPostProcess;
  72314. private _ssaoPostProcess;
  72315. private _blurHPostProcess;
  72316. private _blurVPostProcess;
  72317. private _ssaoCombinePostProcess;
  72318. private _prePassRenderer;
  72319. /**
  72320. * Gets active scene
  72321. */
  72322. get scene(): Scene;
  72323. /**
  72324. * @constructor
  72325. * @param name The rendering pipeline name
  72326. * @param scene The scene linked to this pipeline
  72327. * @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 }
  72328. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72329. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72330. */
  72331. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72332. /**
  72333. * Get the class name
  72334. * @returns "SSAO2RenderingPipeline"
  72335. */
  72336. getClassName(): string;
  72337. /**
  72338. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72339. */
  72340. dispose(disableGeometryBufferRenderer?: boolean): void;
  72341. private _createBlurPostProcess;
  72342. /** @hidden */
  72343. _rebuild(): void;
  72344. private _bits;
  72345. private _radicalInverse_VdC;
  72346. private _hammersley;
  72347. private _hemisphereSample_uniform;
  72348. private _generateHemisphere;
  72349. private _getDefinesForSSAO;
  72350. private _createSSAOPostProcess;
  72351. private _createSSAOCombinePostProcess;
  72352. private _createRandomTexture;
  72353. /**
  72354. * Serialize the rendering pipeline (Used when exporting)
  72355. * @returns the serialized object
  72356. */
  72357. serialize(): any;
  72358. /**
  72359. * Parse the serialized pipeline
  72360. * @param source Source pipeline.
  72361. * @param scene The scene to load the pipeline to.
  72362. * @param rootUrl The URL of the serialized pipeline.
  72363. * @returns An instantiated pipeline from the serialized object.
  72364. */
  72365. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72366. }
  72367. }
  72368. declare module BABYLON {
  72369. /** @hidden */
  72370. export var ssaoPixelShader: {
  72371. name: string;
  72372. shader: string;
  72373. };
  72374. }
  72375. declare module BABYLON {
  72376. /**
  72377. * Render pipeline to produce ssao effect
  72378. */
  72379. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72380. /**
  72381. * @ignore
  72382. * The PassPostProcess id in the pipeline that contains the original scene color
  72383. */
  72384. SSAOOriginalSceneColorEffect: string;
  72385. /**
  72386. * @ignore
  72387. * The SSAO PostProcess id in the pipeline
  72388. */
  72389. SSAORenderEffect: string;
  72390. /**
  72391. * @ignore
  72392. * The horizontal blur PostProcess id in the pipeline
  72393. */
  72394. SSAOBlurHRenderEffect: string;
  72395. /**
  72396. * @ignore
  72397. * The vertical blur PostProcess id in the pipeline
  72398. */
  72399. SSAOBlurVRenderEffect: string;
  72400. /**
  72401. * @ignore
  72402. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72403. */
  72404. SSAOCombineRenderEffect: string;
  72405. /**
  72406. * The output strength of the SSAO post-process. Default value is 1.0.
  72407. */
  72408. totalStrength: number;
  72409. /**
  72410. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72411. */
  72412. radius: number;
  72413. /**
  72414. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72415. * Must not be equal to fallOff and superior to fallOff.
  72416. * Default value is 0.0075
  72417. */
  72418. area: number;
  72419. /**
  72420. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72421. * Must not be equal to area and inferior to area.
  72422. * Default value is 0.000001
  72423. */
  72424. fallOff: number;
  72425. /**
  72426. * The base color of the SSAO post-process
  72427. * The final result is "base + ssao" between [0, 1]
  72428. */
  72429. base: number;
  72430. private _scene;
  72431. private _depthTexture;
  72432. private _randomTexture;
  72433. private _originalColorPostProcess;
  72434. private _ssaoPostProcess;
  72435. private _blurHPostProcess;
  72436. private _blurVPostProcess;
  72437. private _ssaoCombinePostProcess;
  72438. private _firstUpdate;
  72439. /**
  72440. * Gets active scene
  72441. */
  72442. get scene(): Scene;
  72443. /**
  72444. * @constructor
  72445. * @param name - The rendering pipeline name
  72446. * @param scene - The scene linked to this pipeline
  72447. * @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 }
  72448. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72449. */
  72450. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72451. /**
  72452. * Get the class name
  72453. * @returns "SSAORenderingPipeline"
  72454. */
  72455. getClassName(): string;
  72456. /**
  72457. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72458. */
  72459. dispose(disableDepthRender?: boolean): void;
  72460. private _createBlurPostProcess;
  72461. /** @hidden */
  72462. _rebuild(): void;
  72463. private _createSSAOPostProcess;
  72464. private _createSSAOCombinePostProcess;
  72465. private _createRandomTexture;
  72466. }
  72467. }
  72468. declare module BABYLON {
  72469. /**
  72470. * Contains all parameters needed for the prepass to perform
  72471. * screen space reflections
  72472. */
  72473. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72474. /**
  72475. * Is ssr enabled
  72476. */
  72477. enabled: boolean;
  72478. /**
  72479. * Name of the configuration
  72480. */
  72481. name: string;
  72482. /**
  72483. * Textures that should be present in the MRT for this effect to work
  72484. */
  72485. readonly texturesRequired: number[];
  72486. }
  72487. }
  72488. declare module BABYLON {
  72489. /** @hidden */
  72490. export var screenSpaceReflectionPixelShader: {
  72491. name: string;
  72492. shader: string;
  72493. };
  72494. }
  72495. declare module BABYLON {
  72496. /**
  72497. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72498. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72499. */
  72500. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72501. /**
  72502. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72503. */
  72504. threshold: number;
  72505. /**
  72506. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72507. */
  72508. strength: number;
  72509. /**
  72510. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72511. */
  72512. reflectionSpecularFalloffExponent: number;
  72513. /**
  72514. * 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]
  72515. */
  72516. step: number;
  72517. /**
  72518. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72519. */
  72520. roughnessFactor: number;
  72521. private _forceGeometryBuffer;
  72522. private _geometryBufferRenderer;
  72523. private _prePassRenderer;
  72524. private _enableSmoothReflections;
  72525. private _reflectionSamples;
  72526. private _smoothSteps;
  72527. /**
  72528. * Gets a string identifying the name of the class
  72529. * @returns "ScreenSpaceReflectionPostProcess" string
  72530. */
  72531. getClassName(): string;
  72532. /**
  72533. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72534. * @param name The name of the effect.
  72535. * @param scene The scene containing the objects to calculate reflections.
  72536. * @param options The required width/height ratio to downsize to before computing the render pass.
  72537. * @param camera The camera to apply the render pass to.
  72538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72539. * @param engine The engine which the post process will be applied. (default: current engine)
  72540. * @param reusable If the post process can be reused on the same frame. (default: false)
  72541. * @param textureType Type of textures used when performing the post process. (default: 0)
  72542. * @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: true)
  72543. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72544. */
  72545. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72546. /**
  72547. * Gets wether or not smoothing reflections is enabled.
  72548. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72549. */
  72550. get enableSmoothReflections(): boolean;
  72551. /**
  72552. * Sets wether or not smoothing reflections is enabled.
  72553. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72554. */
  72555. set enableSmoothReflections(enabled: boolean);
  72556. /**
  72557. * Gets the number of samples taken while computing reflections. More samples count is high,
  72558. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72559. */
  72560. get reflectionSamples(): number;
  72561. /**
  72562. * Sets the number of samples taken while computing reflections. More samples count is high,
  72563. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72564. */
  72565. set reflectionSamples(samples: number);
  72566. /**
  72567. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72568. * more the post-process will require GPU power and can generate a drop in FPS.
  72569. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72570. */
  72571. get smoothSteps(): number;
  72572. set smoothSteps(steps: number);
  72573. private _updateEffectDefines;
  72574. /** @hidden */
  72575. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72576. }
  72577. }
  72578. declare module BABYLON {
  72579. /** @hidden */
  72580. export var standardPixelShader: {
  72581. name: string;
  72582. shader: string;
  72583. };
  72584. }
  72585. declare module BABYLON {
  72586. /**
  72587. * Standard rendering pipeline
  72588. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72589. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72590. */
  72591. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72592. /**
  72593. * Public members
  72594. */
  72595. /**
  72596. * Post-process which contains the original scene color before the pipeline applies all the effects
  72597. */
  72598. originalPostProcess: Nullable<PostProcess>;
  72599. /**
  72600. * Post-process used to down scale an image x4
  72601. */
  72602. downSampleX4PostProcess: Nullable<PostProcess>;
  72603. /**
  72604. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72605. */
  72606. brightPassPostProcess: Nullable<PostProcess>;
  72607. /**
  72608. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72609. */
  72610. blurHPostProcesses: PostProcess[];
  72611. /**
  72612. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72613. */
  72614. blurVPostProcesses: PostProcess[];
  72615. /**
  72616. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72617. */
  72618. textureAdderPostProcess: Nullable<PostProcess>;
  72619. /**
  72620. * Post-process used to create volumetric lighting effect
  72621. */
  72622. volumetricLightPostProcess: Nullable<PostProcess>;
  72623. /**
  72624. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72625. */
  72626. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72627. /**
  72628. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72629. */
  72630. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72631. /**
  72632. * Post-process used to merge the volumetric light effect and the real scene color
  72633. */
  72634. volumetricLightMergePostProces: Nullable<PostProcess>;
  72635. /**
  72636. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72637. */
  72638. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72639. /**
  72640. * Base post-process used to calculate the average luminance of the final image for HDR
  72641. */
  72642. luminancePostProcess: Nullable<PostProcess>;
  72643. /**
  72644. * Post-processes used to create down sample post-processes in order to get
  72645. * the average luminance of the final image for HDR
  72646. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72647. */
  72648. luminanceDownSamplePostProcesses: PostProcess[];
  72649. /**
  72650. * Post-process used to create a HDR effect (light adaptation)
  72651. */
  72652. hdrPostProcess: Nullable<PostProcess>;
  72653. /**
  72654. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72655. */
  72656. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72657. /**
  72658. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72659. */
  72660. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72661. /**
  72662. * Post-process used to merge the final HDR post-process and the real scene color
  72663. */
  72664. hdrFinalPostProcess: Nullable<PostProcess>;
  72665. /**
  72666. * Post-process used to create a lens flare effect
  72667. */
  72668. lensFlarePostProcess: Nullable<PostProcess>;
  72669. /**
  72670. * Post-process that merges the result of the lens flare post-process and the real scene color
  72671. */
  72672. lensFlareComposePostProcess: Nullable<PostProcess>;
  72673. /**
  72674. * Post-process used to create a motion blur effect
  72675. */
  72676. motionBlurPostProcess: Nullable<PostProcess>;
  72677. /**
  72678. * Post-process used to create a depth of field effect
  72679. */
  72680. depthOfFieldPostProcess: Nullable<PostProcess>;
  72681. /**
  72682. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72683. */
  72684. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72685. /**
  72686. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72687. */
  72688. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72689. /**
  72690. * Represents the brightness threshold in order to configure the illuminated surfaces
  72691. */
  72692. brightThreshold: number;
  72693. /**
  72694. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72695. */
  72696. blurWidth: number;
  72697. /**
  72698. * Sets if the blur for highlighted surfaces must be only horizontal
  72699. */
  72700. horizontalBlur: boolean;
  72701. /**
  72702. * Gets the overall exposure used by the pipeline
  72703. */
  72704. get exposure(): number;
  72705. /**
  72706. * Sets the overall exposure used by the pipeline
  72707. */
  72708. set exposure(value: number);
  72709. /**
  72710. * Texture used typically to simulate "dirty" on camera lens
  72711. */
  72712. lensTexture: Nullable<Texture>;
  72713. /**
  72714. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72715. */
  72716. volumetricLightCoefficient: number;
  72717. /**
  72718. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72719. */
  72720. volumetricLightPower: number;
  72721. /**
  72722. * Used the set the blur intensity to smooth the volumetric lights
  72723. */
  72724. volumetricLightBlurScale: number;
  72725. /**
  72726. * Light (spot or directional) used to generate the volumetric lights rays
  72727. * The source light must have a shadow generate so the pipeline can get its
  72728. * depth map
  72729. */
  72730. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72731. /**
  72732. * For eye adaptation, represents the minimum luminance the eye can see
  72733. */
  72734. hdrMinimumLuminance: number;
  72735. /**
  72736. * For eye adaptation, represents the decrease luminance speed
  72737. */
  72738. hdrDecreaseRate: number;
  72739. /**
  72740. * For eye adaptation, represents the increase luminance speed
  72741. */
  72742. hdrIncreaseRate: number;
  72743. /**
  72744. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72745. */
  72746. get hdrAutoExposure(): boolean;
  72747. /**
  72748. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72749. */
  72750. set hdrAutoExposure(value: boolean);
  72751. /**
  72752. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72753. */
  72754. lensColorTexture: Nullable<Texture>;
  72755. /**
  72756. * The overall strengh for the lens flare effect
  72757. */
  72758. lensFlareStrength: number;
  72759. /**
  72760. * Dispersion coefficient for lens flare ghosts
  72761. */
  72762. lensFlareGhostDispersal: number;
  72763. /**
  72764. * Main lens flare halo width
  72765. */
  72766. lensFlareHaloWidth: number;
  72767. /**
  72768. * Based on the lens distortion effect, defines how much the lens flare result
  72769. * is distorted
  72770. */
  72771. lensFlareDistortionStrength: number;
  72772. /**
  72773. * Configures the blur intensity used for for lens flare (halo)
  72774. */
  72775. lensFlareBlurWidth: number;
  72776. /**
  72777. * Lens star texture must be used to simulate rays on the flares and is available
  72778. * in the documentation
  72779. */
  72780. lensStarTexture: Nullable<Texture>;
  72781. /**
  72782. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72783. * flare effect by taking account of the dirt texture
  72784. */
  72785. lensFlareDirtTexture: Nullable<Texture>;
  72786. /**
  72787. * Represents the focal length for the depth of field effect
  72788. */
  72789. depthOfFieldDistance: number;
  72790. /**
  72791. * Represents the blur intensity for the blurred part of the depth of field effect
  72792. */
  72793. depthOfFieldBlurWidth: number;
  72794. /**
  72795. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72796. */
  72797. get motionStrength(): number;
  72798. /**
  72799. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72800. */
  72801. set motionStrength(strength: number);
  72802. /**
  72803. * Gets wether or not the motion blur post-process is object based or screen based.
  72804. */
  72805. get objectBasedMotionBlur(): boolean;
  72806. /**
  72807. * Sets wether or not the motion blur post-process should be object based or screen based
  72808. */
  72809. set objectBasedMotionBlur(value: boolean);
  72810. /**
  72811. * List of animations for the pipeline (IAnimatable implementation)
  72812. */
  72813. animations: Animation[];
  72814. /**
  72815. * Private members
  72816. */
  72817. private _scene;
  72818. private _currentDepthOfFieldSource;
  72819. private _basePostProcess;
  72820. private _fixedExposure;
  72821. private _currentExposure;
  72822. private _hdrAutoExposure;
  72823. private _hdrCurrentLuminance;
  72824. private _motionStrength;
  72825. private _isObjectBasedMotionBlur;
  72826. private _floatTextureType;
  72827. private _camerasToBeAttached;
  72828. private _ratio;
  72829. private _bloomEnabled;
  72830. private _depthOfFieldEnabled;
  72831. private _vlsEnabled;
  72832. private _lensFlareEnabled;
  72833. private _hdrEnabled;
  72834. private _motionBlurEnabled;
  72835. private _fxaaEnabled;
  72836. private _screenSpaceReflectionsEnabled;
  72837. private _motionBlurSamples;
  72838. private _volumetricLightStepsCount;
  72839. private _samples;
  72840. /**
  72841. * @ignore
  72842. * Specifies if the bloom pipeline is enabled
  72843. */
  72844. get BloomEnabled(): boolean;
  72845. set BloomEnabled(enabled: boolean);
  72846. /**
  72847. * @ignore
  72848. * Specifies if the depth of field pipeline is enabed
  72849. */
  72850. get DepthOfFieldEnabled(): boolean;
  72851. set DepthOfFieldEnabled(enabled: boolean);
  72852. /**
  72853. * @ignore
  72854. * Specifies if the lens flare pipeline is enabed
  72855. */
  72856. get LensFlareEnabled(): boolean;
  72857. set LensFlareEnabled(enabled: boolean);
  72858. /**
  72859. * @ignore
  72860. * Specifies if the HDR pipeline is enabled
  72861. */
  72862. get HDREnabled(): boolean;
  72863. set HDREnabled(enabled: boolean);
  72864. /**
  72865. * @ignore
  72866. * Specifies if the volumetric lights scattering effect is enabled
  72867. */
  72868. get VLSEnabled(): boolean;
  72869. set VLSEnabled(enabled: boolean);
  72870. /**
  72871. * @ignore
  72872. * Specifies if the motion blur effect is enabled
  72873. */
  72874. get MotionBlurEnabled(): boolean;
  72875. set MotionBlurEnabled(enabled: boolean);
  72876. /**
  72877. * Specifies if anti-aliasing is enabled
  72878. */
  72879. get fxaaEnabled(): boolean;
  72880. set fxaaEnabled(enabled: boolean);
  72881. /**
  72882. * Specifies if screen space reflections are enabled.
  72883. */
  72884. get screenSpaceReflectionsEnabled(): boolean;
  72885. set screenSpaceReflectionsEnabled(enabled: boolean);
  72886. /**
  72887. * Specifies the number of steps used to calculate the volumetric lights
  72888. * Typically in interval [50, 200]
  72889. */
  72890. get volumetricLightStepsCount(): number;
  72891. set volumetricLightStepsCount(count: number);
  72892. /**
  72893. * Specifies the number of samples used for the motion blur effect
  72894. * Typically in interval [16, 64]
  72895. */
  72896. get motionBlurSamples(): number;
  72897. set motionBlurSamples(samples: number);
  72898. /**
  72899. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72900. */
  72901. get samples(): number;
  72902. set samples(sampleCount: number);
  72903. /**
  72904. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72905. * @constructor
  72906. * @param name The rendering pipeline name
  72907. * @param scene The scene linked to this pipeline
  72908. * @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)
  72909. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72910. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72911. */
  72912. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72913. private _buildPipeline;
  72914. private _createDownSampleX4PostProcess;
  72915. private _createBrightPassPostProcess;
  72916. private _createBlurPostProcesses;
  72917. private _createTextureAdderPostProcess;
  72918. private _createVolumetricLightPostProcess;
  72919. private _createLuminancePostProcesses;
  72920. private _createHdrPostProcess;
  72921. private _createLensFlarePostProcess;
  72922. private _createDepthOfFieldPostProcess;
  72923. private _createMotionBlurPostProcess;
  72924. private _getDepthTexture;
  72925. private _disposePostProcesses;
  72926. /**
  72927. * Dispose of the pipeline and stop all post processes
  72928. */
  72929. dispose(): void;
  72930. /**
  72931. * Serialize the rendering pipeline (Used when exporting)
  72932. * @returns the serialized object
  72933. */
  72934. serialize(): any;
  72935. /**
  72936. * Parse the serialized pipeline
  72937. * @param source Source pipeline.
  72938. * @param scene The scene to load the pipeline to.
  72939. * @param rootUrl The URL of the serialized pipeline.
  72940. * @returns An instantiated pipeline from the serialized object.
  72941. */
  72942. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72943. /**
  72944. * Luminance steps
  72945. */
  72946. static LuminanceSteps: number;
  72947. }
  72948. }
  72949. declare module BABYLON {
  72950. /** @hidden */
  72951. export var stereoscopicInterlacePixelShader: {
  72952. name: string;
  72953. shader: string;
  72954. };
  72955. }
  72956. declare module BABYLON {
  72957. /**
  72958. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72959. */
  72960. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72961. private _stepSize;
  72962. private _passedProcess;
  72963. /**
  72964. * Gets a string identifying the name of the class
  72965. * @returns "StereoscopicInterlacePostProcessI" string
  72966. */
  72967. getClassName(): string;
  72968. /**
  72969. * Initializes a StereoscopicInterlacePostProcessI
  72970. * @param name The name of the effect.
  72971. * @param rigCameras The rig cameras to be appled to the post process
  72972. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72973. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72975. * @param engine The engine which the post process will be applied. (default: current engine)
  72976. * @param reusable If the post process can be reused on the same frame. (default: false)
  72977. */
  72978. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72979. }
  72980. /**
  72981. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72982. */
  72983. export class StereoscopicInterlacePostProcess extends PostProcess {
  72984. private _stepSize;
  72985. private _passedProcess;
  72986. /**
  72987. * Gets a string identifying the name of the class
  72988. * @returns "StereoscopicInterlacePostProcess" string
  72989. */
  72990. getClassName(): string;
  72991. /**
  72992. * Initializes a StereoscopicInterlacePostProcess
  72993. * @param name The name of the effect.
  72994. * @param rigCameras The rig cameras to be appled to the post process
  72995. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72997. * @param engine The engine which the post process will be applied. (default: current engine)
  72998. * @param reusable If the post process can be reused on the same frame. (default: false)
  72999. */
  73000. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73001. }
  73002. }
  73003. declare module BABYLON {
  73004. /** @hidden */
  73005. export var tonemapPixelShader: {
  73006. name: string;
  73007. shader: string;
  73008. };
  73009. }
  73010. declare module BABYLON {
  73011. /** Defines operator used for tonemapping */
  73012. export enum TonemappingOperator {
  73013. /** Hable */
  73014. Hable = 0,
  73015. /** Reinhard */
  73016. Reinhard = 1,
  73017. /** HejiDawson */
  73018. HejiDawson = 2,
  73019. /** Photographic */
  73020. Photographic = 3
  73021. }
  73022. /**
  73023. * Defines a post process to apply tone mapping
  73024. */
  73025. export class TonemapPostProcess extends PostProcess {
  73026. private _operator;
  73027. /** Defines the required exposure adjustement */
  73028. exposureAdjustment: number;
  73029. /**
  73030. * Gets a string identifying the name of the class
  73031. * @returns "TonemapPostProcess" string
  73032. */
  73033. getClassName(): string;
  73034. /**
  73035. * Creates a new TonemapPostProcess
  73036. * @param name defines the name of the postprocess
  73037. * @param _operator defines the operator to use
  73038. * @param exposureAdjustment defines the required exposure adjustement
  73039. * @param camera defines the camera to use (can be null)
  73040. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73041. * @param engine defines the hosting engine (can be ignore if camera is set)
  73042. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73043. */
  73044. constructor(name: string, _operator: TonemappingOperator,
  73045. /** Defines the required exposure adjustement */
  73046. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73047. }
  73048. }
  73049. declare module BABYLON {
  73050. /** @hidden */
  73051. export var volumetricLightScatteringPixelShader: {
  73052. name: string;
  73053. shader: string;
  73054. };
  73055. }
  73056. declare module BABYLON {
  73057. /** @hidden */
  73058. export var volumetricLightScatteringPassVertexShader: {
  73059. name: string;
  73060. shader: string;
  73061. };
  73062. }
  73063. declare module BABYLON {
  73064. /** @hidden */
  73065. export var volumetricLightScatteringPassPixelShader: {
  73066. name: string;
  73067. shader: string;
  73068. };
  73069. }
  73070. declare module BABYLON {
  73071. /**
  73072. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73073. */
  73074. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73075. private _volumetricLightScatteringPass;
  73076. private _volumetricLightScatteringRTT;
  73077. private _viewPort;
  73078. private _screenCoordinates;
  73079. private _cachedDefines;
  73080. /**
  73081. * If not undefined, the mesh position is computed from the attached node position
  73082. */
  73083. attachedNode: {
  73084. position: Vector3;
  73085. };
  73086. /**
  73087. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73088. */
  73089. customMeshPosition: Vector3;
  73090. /**
  73091. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73092. */
  73093. useCustomMeshPosition: boolean;
  73094. /**
  73095. * If the post-process should inverse the light scattering direction
  73096. */
  73097. invert: boolean;
  73098. /**
  73099. * The internal mesh used by the post-process
  73100. */
  73101. mesh: Mesh;
  73102. /**
  73103. * @hidden
  73104. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73105. */
  73106. get useDiffuseColor(): boolean;
  73107. set useDiffuseColor(useDiffuseColor: boolean);
  73108. /**
  73109. * Array containing the excluded meshes not rendered in the internal pass
  73110. */
  73111. excludedMeshes: AbstractMesh[];
  73112. /**
  73113. * Controls the overall intensity of the post-process
  73114. */
  73115. exposure: number;
  73116. /**
  73117. * Dissipates each sample's contribution in range [0, 1]
  73118. */
  73119. decay: number;
  73120. /**
  73121. * Controls the overall intensity of each sample
  73122. */
  73123. weight: number;
  73124. /**
  73125. * Controls the density of each sample
  73126. */
  73127. density: number;
  73128. /**
  73129. * @constructor
  73130. * @param name The post-process name
  73131. * @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)
  73132. * @param camera The camera that the post-process will be attached to
  73133. * @param mesh The mesh used to create the light scattering
  73134. * @param samples The post-process quality, default 100
  73135. * @param samplingModeThe post-process filtering mode
  73136. * @param engine The babylon engine
  73137. * @param reusable If the post-process is reusable
  73138. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73139. */
  73140. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73141. /**
  73142. * Returns the string "VolumetricLightScatteringPostProcess"
  73143. * @returns "VolumetricLightScatteringPostProcess"
  73144. */
  73145. getClassName(): string;
  73146. private _isReady;
  73147. /**
  73148. * Sets the new light position for light scattering effect
  73149. * @param position The new custom light position
  73150. */
  73151. setCustomMeshPosition(position: Vector3): void;
  73152. /**
  73153. * Returns the light position for light scattering effect
  73154. * @return Vector3 The custom light position
  73155. */
  73156. getCustomMeshPosition(): Vector3;
  73157. /**
  73158. * Disposes the internal assets and detaches the post-process from the camera
  73159. */
  73160. dispose(camera: Camera): void;
  73161. /**
  73162. * Returns the render target texture used by the post-process
  73163. * @return the render target texture used by the post-process
  73164. */
  73165. getPass(): RenderTargetTexture;
  73166. private _meshExcluded;
  73167. private _createPass;
  73168. private _updateMeshScreenCoordinates;
  73169. /**
  73170. * Creates a default mesh for the Volumeric Light Scattering post-process
  73171. * @param name The mesh name
  73172. * @param scene The scene where to create the mesh
  73173. * @return the default mesh
  73174. */
  73175. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73176. }
  73177. }
  73178. declare module BABYLON {
  73179. /** @hidden */
  73180. export var screenSpaceCurvaturePixelShader: {
  73181. name: string;
  73182. shader: string;
  73183. };
  73184. }
  73185. declare module BABYLON {
  73186. /**
  73187. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73188. */
  73189. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73190. /**
  73191. * Defines how much ridge the curvature effect displays.
  73192. */
  73193. ridge: number;
  73194. /**
  73195. * Defines how much valley the curvature effect displays.
  73196. */
  73197. valley: number;
  73198. private _geometryBufferRenderer;
  73199. /**
  73200. * Gets a string identifying the name of the class
  73201. * @returns "ScreenSpaceCurvaturePostProcess" string
  73202. */
  73203. getClassName(): string;
  73204. /**
  73205. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73206. * @param name The name of the effect.
  73207. * @param scene The scene containing the objects to blur according to their velocity.
  73208. * @param options The required width/height ratio to downsize to before computing the render pass.
  73209. * @param camera The camera to apply the render pass to.
  73210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73211. * @param engine The engine which the post process will be applied. (default: current engine)
  73212. * @param reusable If the post process can be reused on the same frame. (default: false)
  73213. * @param textureType Type of textures used when performing the post process. (default: 0)
  73214. * @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)
  73215. */
  73216. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73217. /**
  73218. * Support test.
  73219. */
  73220. static get IsSupported(): boolean;
  73221. /** @hidden */
  73222. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73223. }
  73224. }
  73225. declare module BABYLON {
  73226. interface Scene {
  73227. /** @hidden (Backing field) */
  73228. _boundingBoxRenderer: BoundingBoxRenderer;
  73229. /** @hidden (Backing field) */
  73230. _forceShowBoundingBoxes: boolean;
  73231. /**
  73232. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73233. */
  73234. forceShowBoundingBoxes: boolean;
  73235. /**
  73236. * Gets the bounding box renderer associated with the scene
  73237. * @returns a BoundingBoxRenderer
  73238. */
  73239. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73240. }
  73241. interface AbstractMesh {
  73242. /** @hidden (Backing field) */
  73243. _showBoundingBox: boolean;
  73244. /**
  73245. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73246. */
  73247. showBoundingBox: boolean;
  73248. }
  73249. /**
  73250. * Component responsible of rendering the bounding box of the meshes in a scene.
  73251. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73252. */
  73253. export class BoundingBoxRenderer implements ISceneComponent {
  73254. /**
  73255. * The component name helpfull to identify the component in the list of scene components.
  73256. */
  73257. readonly name: string;
  73258. /**
  73259. * The scene the component belongs to.
  73260. */
  73261. scene: Scene;
  73262. /**
  73263. * Color of the bounding box lines placed in front of an object
  73264. */
  73265. frontColor: Color3;
  73266. /**
  73267. * Color of the bounding box lines placed behind an object
  73268. */
  73269. backColor: Color3;
  73270. /**
  73271. * Defines if the renderer should show the back lines or not
  73272. */
  73273. showBackLines: boolean;
  73274. /**
  73275. * Observable raised before rendering a bounding box
  73276. */
  73277. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73278. /**
  73279. * Observable raised after rendering a bounding box
  73280. */
  73281. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73282. /**
  73283. * Observable raised after resources are created
  73284. */
  73285. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73286. /**
  73287. * When false, no bounding boxes will be rendered
  73288. */
  73289. enabled: boolean;
  73290. /**
  73291. * @hidden
  73292. */
  73293. renderList: SmartArray<BoundingBox>;
  73294. private _colorShader;
  73295. private _vertexBuffers;
  73296. private _indexBuffer;
  73297. private _fillIndexBuffer;
  73298. private _fillIndexData;
  73299. /**
  73300. * Instantiates a new bounding box renderer in a scene.
  73301. * @param scene the scene the renderer renders in
  73302. */
  73303. constructor(scene: Scene);
  73304. /**
  73305. * Registers the component in a given scene
  73306. */
  73307. register(): void;
  73308. private _evaluateSubMesh;
  73309. private _preActiveMesh;
  73310. private _prepareResources;
  73311. private _createIndexBuffer;
  73312. /**
  73313. * Rebuilds the elements related to this component in case of
  73314. * context lost for instance.
  73315. */
  73316. rebuild(): void;
  73317. /**
  73318. * @hidden
  73319. */
  73320. reset(): void;
  73321. /**
  73322. * Render the bounding boxes of a specific rendering group
  73323. * @param renderingGroupId defines the rendering group to render
  73324. */
  73325. render(renderingGroupId: number): void;
  73326. /**
  73327. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73328. * @param mesh Define the mesh to render the occlusion bounding box for
  73329. */
  73330. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73331. /**
  73332. * Dispose and release the resources attached to this renderer.
  73333. */
  73334. dispose(): void;
  73335. }
  73336. }
  73337. declare module BABYLON {
  73338. interface Scene {
  73339. /** @hidden (Backing field) */
  73340. _depthRenderer: {
  73341. [id: string]: DepthRenderer;
  73342. };
  73343. /**
  73344. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73345. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73346. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73347. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73348. * @returns the created depth renderer
  73349. */
  73350. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73351. /**
  73352. * Disables a depth renderer for a given camera
  73353. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73354. */
  73355. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73356. }
  73357. /**
  73358. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73359. * in several rendering techniques.
  73360. */
  73361. export class DepthRendererSceneComponent implements ISceneComponent {
  73362. /**
  73363. * The component name helpfull to identify the component in the list of scene components.
  73364. */
  73365. readonly name: string;
  73366. /**
  73367. * The scene the component belongs to.
  73368. */
  73369. scene: Scene;
  73370. /**
  73371. * Creates a new instance of the component for the given scene
  73372. * @param scene Defines the scene to register the component in
  73373. */
  73374. constructor(scene: Scene);
  73375. /**
  73376. * Registers the component in a given scene
  73377. */
  73378. register(): void;
  73379. /**
  73380. * Rebuilds the elements related to this component in case of
  73381. * context lost for instance.
  73382. */
  73383. rebuild(): void;
  73384. /**
  73385. * Disposes the component and the associated ressources
  73386. */
  73387. dispose(): void;
  73388. private _gatherRenderTargets;
  73389. private _gatherActiveCameraRenderTargets;
  73390. }
  73391. }
  73392. declare module BABYLON {
  73393. interface AbstractScene {
  73394. /** @hidden (Backing field) */
  73395. _prePassRenderer: Nullable<PrePassRenderer>;
  73396. /**
  73397. * Gets or Sets the current prepass renderer associated to the scene.
  73398. */
  73399. prePassRenderer: Nullable<PrePassRenderer>;
  73400. /**
  73401. * Enables the prepass and associates it with the scene
  73402. * @returns the PrePassRenderer
  73403. */
  73404. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73405. /**
  73406. * Disables the prepass associated with the scene
  73407. */
  73408. disablePrePassRenderer(): void;
  73409. }
  73410. /**
  73411. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73412. * in several rendering techniques.
  73413. */
  73414. export class PrePassRendererSceneComponent implements ISceneComponent {
  73415. /**
  73416. * The component name helpful to identify the component in the list of scene components.
  73417. */
  73418. readonly name: string;
  73419. /**
  73420. * The scene the component belongs to.
  73421. */
  73422. scene: Scene;
  73423. /**
  73424. * Creates a new instance of the component for the given scene
  73425. * @param scene Defines the scene to register the component in
  73426. */
  73427. constructor(scene: Scene);
  73428. /**
  73429. * Registers the component in a given scene
  73430. */
  73431. register(): void;
  73432. private _beforeCameraDraw;
  73433. private _afterCameraDraw;
  73434. private _beforeClearStage;
  73435. private _beforeRenderingMeshStage;
  73436. private _afterRenderingMeshStage;
  73437. /**
  73438. * Rebuilds the elements related to this component in case of
  73439. * context lost for instance.
  73440. */
  73441. rebuild(): void;
  73442. /**
  73443. * Disposes the component and the associated ressources
  73444. */
  73445. dispose(): void;
  73446. }
  73447. }
  73448. declare module BABYLON {
  73449. /** @hidden */
  73450. export var fibonacci: {
  73451. name: string;
  73452. shader: string;
  73453. };
  73454. }
  73455. declare module BABYLON {
  73456. /** @hidden */
  73457. export var diffusionProfile: {
  73458. name: string;
  73459. shader: string;
  73460. };
  73461. }
  73462. declare module BABYLON {
  73463. /** @hidden */
  73464. export var subSurfaceScatteringPixelShader: {
  73465. name: string;
  73466. shader: string;
  73467. };
  73468. }
  73469. declare module BABYLON {
  73470. /**
  73471. * Sub surface scattering post process
  73472. */
  73473. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73474. /**
  73475. * Gets a string identifying the name of the class
  73476. * @returns "SubSurfaceScatteringPostProcess" string
  73477. */
  73478. getClassName(): string;
  73479. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73480. }
  73481. }
  73482. declare module BABYLON {
  73483. /**
  73484. * Contains all parameters needed for the prepass to perform
  73485. * screen space subsurface scattering
  73486. */
  73487. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73488. /** @hidden */
  73489. static _SceneComponentInitialization: (scene: Scene) => void;
  73490. private _ssDiffusionS;
  73491. private _ssFilterRadii;
  73492. private _ssDiffusionD;
  73493. /**
  73494. * Post process to attach for screen space subsurface scattering
  73495. */
  73496. postProcess: SubSurfaceScatteringPostProcess;
  73497. /**
  73498. * Diffusion profile color for subsurface scattering
  73499. */
  73500. get ssDiffusionS(): number[];
  73501. /**
  73502. * Diffusion profile max color channel value for subsurface scattering
  73503. */
  73504. get ssDiffusionD(): number[];
  73505. /**
  73506. * Diffusion profile filter radius for subsurface scattering
  73507. */
  73508. get ssFilterRadii(): number[];
  73509. /**
  73510. * Is subsurface enabled
  73511. */
  73512. enabled: boolean;
  73513. /**
  73514. * Name of the configuration
  73515. */
  73516. name: string;
  73517. /**
  73518. * Diffusion profile colors for subsurface scattering
  73519. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73520. * See ...
  73521. * Note that you can only store up to 5 of them
  73522. */
  73523. ssDiffusionProfileColors: Color3[];
  73524. /**
  73525. * Defines the ratio real world => scene units.
  73526. * Used for subsurface scattering
  73527. */
  73528. metersPerUnit: number;
  73529. /**
  73530. * Textures that should be present in the MRT for this effect to work
  73531. */
  73532. readonly texturesRequired: number[];
  73533. private _scene;
  73534. /**
  73535. * Builds a subsurface configuration object
  73536. * @param scene The scene
  73537. */
  73538. constructor(scene: Scene);
  73539. /**
  73540. * Adds a new diffusion profile.
  73541. * Useful for more realistic subsurface scattering on diverse materials.
  73542. * @param color The color of the diffusion profile. Should be the average color of the material.
  73543. * @return The index of the diffusion profile for the material subsurface configuration
  73544. */
  73545. addDiffusionProfile(color: Color3): number;
  73546. /**
  73547. * Creates the sss post process
  73548. * @return The created post process
  73549. */
  73550. createPostProcess(): SubSurfaceScatteringPostProcess;
  73551. /**
  73552. * Deletes all diffusion profiles.
  73553. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73554. */
  73555. clearAllDiffusionProfiles(): void;
  73556. /**
  73557. * Disposes this object
  73558. */
  73559. dispose(): void;
  73560. /**
  73561. * @hidden
  73562. * https://zero-radiance.github.io/post/sampling-diffusion/
  73563. *
  73564. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73565. * ------------------------------------------------------------------------------------
  73566. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73567. * PDF[r, phi, s] = r * R[r, phi, s]
  73568. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73569. * ------------------------------------------------------------------------------------
  73570. * We importance sample the color channel with the widest scattering distance.
  73571. */
  73572. getDiffusionProfileParameters(color: Color3): number;
  73573. /**
  73574. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73575. * 'u' is the random number (the value of the CDF): [0, 1).
  73576. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73577. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73578. */
  73579. private _sampleBurleyDiffusionProfile;
  73580. }
  73581. }
  73582. declare module BABYLON {
  73583. interface AbstractScene {
  73584. /** @hidden (Backing field) */
  73585. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73586. /**
  73587. * Gets or Sets the current prepass renderer associated to the scene.
  73588. */
  73589. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73590. /**
  73591. * Enables the subsurface effect for prepass
  73592. * @returns the SubSurfaceConfiguration
  73593. */
  73594. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73595. /**
  73596. * Disables the subsurface effect for prepass
  73597. */
  73598. disableSubSurfaceForPrePass(): void;
  73599. }
  73600. /**
  73601. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73602. * in several rendering techniques.
  73603. */
  73604. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73605. /**
  73606. * The component name helpful to identify the component in the list of scene components.
  73607. */
  73608. readonly name: string;
  73609. /**
  73610. * The scene the component belongs to.
  73611. */
  73612. scene: Scene;
  73613. /**
  73614. * Creates a new instance of the component for the given scene
  73615. * @param scene Defines the scene to register the component in
  73616. */
  73617. constructor(scene: Scene);
  73618. /**
  73619. * Registers the component in a given scene
  73620. */
  73621. register(): void;
  73622. /**
  73623. * Serializes the component data to the specified json object
  73624. * @param serializationObject The object to serialize to
  73625. */
  73626. serialize(serializationObject: any): void;
  73627. /**
  73628. * Adds all the elements from the container to the scene
  73629. * @param container the container holding the elements
  73630. */
  73631. addFromContainer(container: AbstractScene): void;
  73632. /**
  73633. * Removes all the elements in the container from the scene
  73634. * @param container contains the elements to remove
  73635. * @param dispose if the removed element should be disposed (default: false)
  73636. */
  73637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73638. /**
  73639. * Rebuilds the elements related to this component in case of
  73640. * context lost for instance.
  73641. */
  73642. rebuild(): void;
  73643. /**
  73644. * Disposes the component and the associated ressources
  73645. */
  73646. dispose(): void;
  73647. }
  73648. }
  73649. declare module BABYLON {
  73650. /** @hidden */
  73651. export var outlinePixelShader: {
  73652. name: string;
  73653. shader: string;
  73654. };
  73655. }
  73656. declare module BABYLON {
  73657. /** @hidden */
  73658. export var outlineVertexShader: {
  73659. name: string;
  73660. shader: string;
  73661. };
  73662. }
  73663. declare module BABYLON {
  73664. interface Scene {
  73665. /** @hidden */
  73666. _outlineRenderer: OutlineRenderer;
  73667. /**
  73668. * Gets the outline renderer associated with the scene
  73669. * @returns a OutlineRenderer
  73670. */
  73671. getOutlineRenderer(): OutlineRenderer;
  73672. }
  73673. interface AbstractMesh {
  73674. /** @hidden (Backing field) */
  73675. _renderOutline: boolean;
  73676. /**
  73677. * Gets or sets a boolean indicating if the outline must be rendered as well
  73678. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73679. */
  73680. renderOutline: boolean;
  73681. /** @hidden (Backing field) */
  73682. _renderOverlay: boolean;
  73683. /**
  73684. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73685. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73686. */
  73687. renderOverlay: boolean;
  73688. }
  73689. /**
  73690. * This class is responsible to draw bothe outline/overlay of meshes.
  73691. * It should not be used directly but through the available method on mesh.
  73692. */
  73693. export class OutlineRenderer implements ISceneComponent {
  73694. /**
  73695. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73696. */
  73697. private static _StencilReference;
  73698. /**
  73699. * The name of the component. Each component must have a unique name.
  73700. */
  73701. name: string;
  73702. /**
  73703. * The scene the component belongs to.
  73704. */
  73705. scene: Scene;
  73706. /**
  73707. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73708. */
  73709. zOffset: number;
  73710. private _engine;
  73711. private _effect;
  73712. private _cachedDefines;
  73713. private _savedDepthWrite;
  73714. /**
  73715. * Instantiates a new outline renderer. (There could be only one per scene).
  73716. * @param scene Defines the scene it belongs to
  73717. */
  73718. constructor(scene: Scene);
  73719. /**
  73720. * Register the component to one instance of a scene.
  73721. */
  73722. register(): void;
  73723. /**
  73724. * Rebuilds the elements related to this component in case of
  73725. * context lost for instance.
  73726. */
  73727. rebuild(): void;
  73728. /**
  73729. * Disposes the component and the associated ressources.
  73730. */
  73731. dispose(): void;
  73732. /**
  73733. * Renders the outline in the canvas.
  73734. * @param subMesh Defines the sumesh to render
  73735. * @param batch Defines the batch of meshes in case of instances
  73736. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73737. */
  73738. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73739. /**
  73740. * Returns whether or not the outline renderer is ready for a given submesh.
  73741. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73742. * @param subMesh Defines the submesh to check readyness for
  73743. * @param useInstances Defines wheter wee are trying to render instances or not
  73744. * @returns true if ready otherwise false
  73745. */
  73746. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73747. private _beforeRenderingMesh;
  73748. private _afterRenderingMesh;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Defines the basic options interface of a Sprite Frame Source Size.
  73754. */
  73755. export interface ISpriteJSONSpriteSourceSize {
  73756. /**
  73757. * number of the original width of the Frame
  73758. */
  73759. w: number;
  73760. /**
  73761. * number of the original height of the Frame
  73762. */
  73763. h: number;
  73764. }
  73765. /**
  73766. * Defines the basic options interface of a Sprite Frame Data.
  73767. */
  73768. export interface ISpriteJSONSpriteFrameData {
  73769. /**
  73770. * number of the x offset of the Frame
  73771. */
  73772. x: number;
  73773. /**
  73774. * number of the y offset of the Frame
  73775. */
  73776. y: number;
  73777. /**
  73778. * number of the width of the Frame
  73779. */
  73780. w: number;
  73781. /**
  73782. * number of the height of the Frame
  73783. */
  73784. h: number;
  73785. }
  73786. /**
  73787. * Defines the basic options interface of a JSON Sprite.
  73788. */
  73789. export interface ISpriteJSONSprite {
  73790. /**
  73791. * string name of the Frame
  73792. */
  73793. filename: string;
  73794. /**
  73795. * ISpriteJSONSpriteFrame basic object of the frame data
  73796. */
  73797. frame: ISpriteJSONSpriteFrameData;
  73798. /**
  73799. * boolean to flag is the frame was rotated.
  73800. */
  73801. rotated: boolean;
  73802. /**
  73803. * boolean to flag is the frame was trimmed.
  73804. */
  73805. trimmed: boolean;
  73806. /**
  73807. * ISpriteJSONSpriteFrame basic object of the source data
  73808. */
  73809. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73810. /**
  73811. * ISpriteJSONSpriteFrame basic object of the source data
  73812. */
  73813. sourceSize: ISpriteJSONSpriteSourceSize;
  73814. }
  73815. /**
  73816. * Defines the basic options interface of a JSON atlas.
  73817. */
  73818. export interface ISpriteJSONAtlas {
  73819. /**
  73820. * Array of objects that contain the frame data.
  73821. */
  73822. frames: Array<ISpriteJSONSprite>;
  73823. /**
  73824. * object basic object containing the sprite meta data.
  73825. */
  73826. meta?: object;
  73827. }
  73828. }
  73829. declare module BABYLON {
  73830. /** @hidden */
  73831. export var spriteMapPixelShader: {
  73832. name: string;
  73833. shader: string;
  73834. };
  73835. }
  73836. declare module BABYLON {
  73837. /** @hidden */
  73838. export var spriteMapVertexShader: {
  73839. name: string;
  73840. shader: string;
  73841. };
  73842. }
  73843. declare module BABYLON {
  73844. /**
  73845. * Defines the basic options interface of a SpriteMap
  73846. */
  73847. export interface ISpriteMapOptions {
  73848. /**
  73849. * Vector2 of the number of cells in the grid.
  73850. */
  73851. stageSize?: Vector2;
  73852. /**
  73853. * Vector2 of the size of the output plane in World Units.
  73854. */
  73855. outputSize?: Vector2;
  73856. /**
  73857. * Vector3 of the position of the output plane in World Units.
  73858. */
  73859. outputPosition?: Vector3;
  73860. /**
  73861. * Vector3 of the rotation of the output plane.
  73862. */
  73863. outputRotation?: Vector3;
  73864. /**
  73865. * number of layers that the system will reserve in resources.
  73866. */
  73867. layerCount?: number;
  73868. /**
  73869. * number of max animation frames a single cell will reserve in resources.
  73870. */
  73871. maxAnimationFrames?: number;
  73872. /**
  73873. * number cell index of the base tile when the system compiles.
  73874. */
  73875. baseTile?: number;
  73876. /**
  73877. * boolean flip the sprite after its been repositioned by the framing data.
  73878. */
  73879. flipU?: boolean;
  73880. /**
  73881. * Vector3 scalar of the global RGB values of the SpriteMap.
  73882. */
  73883. colorMultiply?: Vector3;
  73884. }
  73885. /**
  73886. * Defines the IDisposable interface in order to be cleanable from resources.
  73887. */
  73888. export interface ISpriteMap extends IDisposable {
  73889. /**
  73890. * String name of the SpriteMap.
  73891. */
  73892. name: string;
  73893. /**
  73894. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73895. */
  73896. atlasJSON: ISpriteJSONAtlas;
  73897. /**
  73898. * Texture of the SpriteMap.
  73899. */
  73900. spriteSheet: Texture;
  73901. /**
  73902. * The parameters to initialize the SpriteMap with.
  73903. */
  73904. options: ISpriteMapOptions;
  73905. }
  73906. /**
  73907. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73908. */
  73909. export class SpriteMap implements ISpriteMap {
  73910. /** The Name of the spriteMap */
  73911. name: string;
  73912. /** The JSON file with the frame and meta data */
  73913. atlasJSON: ISpriteJSONAtlas;
  73914. /** The systems Sprite Sheet Texture */
  73915. spriteSheet: Texture;
  73916. /** Arguments passed with the Constructor */
  73917. options: ISpriteMapOptions;
  73918. /** Public Sprite Storage array, parsed from atlasJSON */
  73919. sprites: Array<ISpriteJSONSprite>;
  73920. /** Returns the Number of Sprites in the System */
  73921. get spriteCount(): number;
  73922. /** Returns the Position of Output Plane*/
  73923. get position(): Vector3;
  73924. /** Returns the Position of Output Plane*/
  73925. set position(v: Vector3);
  73926. /** Returns the Rotation of Output Plane*/
  73927. get rotation(): Vector3;
  73928. /** Returns the Rotation of Output Plane*/
  73929. set rotation(v: Vector3);
  73930. /** Sets the AnimationMap*/
  73931. get animationMap(): RawTexture;
  73932. /** Sets the AnimationMap*/
  73933. set animationMap(v: RawTexture);
  73934. /** Scene that the SpriteMap was created in */
  73935. private _scene;
  73936. /** Texture Buffer of Float32 that holds tile frame data*/
  73937. private _frameMap;
  73938. /** Texture Buffers of Float32 that holds tileMap data*/
  73939. private _tileMaps;
  73940. /** Texture Buffer of Float32 that holds Animation Data*/
  73941. private _animationMap;
  73942. /** Custom ShaderMaterial Central to the System*/
  73943. private _material;
  73944. /** Custom ShaderMaterial Central to the System*/
  73945. private _output;
  73946. /** Systems Time Ticker*/
  73947. private _time;
  73948. /**
  73949. * Creates a new SpriteMap
  73950. * @param name defines the SpriteMaps Name
  73951. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73952. * @param spriteSheet is the Texture that the Sprites are on.
  73953. * @param options a basic deployment configuration
  73954. * @param scene The Scene that the map is deployed on
  73955. */
  73956. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73957. /**
  73958. * Returns tileID location
  73959. * @returns Vector2 the cell position ID
  73960. */
  73961. getTileID(): Vector2;
  73962. /**
  73963. * Gets the UV location of the mouse over the SpriteMap.
  73964. * @returns Vector2 the UV position of the mouse interaction
  73965. */
  73966. getMousePosition(): Vector2;
  73967. /**
  73968. * Creates the "frame" texture Buffer
  73969. * -------------------------------------
  73970. * Structure of frames
  73971. * "filename": "Falling-Water-2.png",
  73972. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73973. * "rotated": true,
  73974. * "trimmed": true,
  73975. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73976. * "sourceSize": {"w":32,"h":32}
  73977. * @returns RawTexture of the frameMap
  73978. */
  73979. private _createFrameBuffer;
  73980. /**
  73981. * Creates the tileMap texture Buffer
  73982. * @param buffer normally and array of numbers, or a false to generate from scratch
  73983. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73984. * @returns RawTexture of the tileMap
  73985. */
  73986. private _createTileBuffer;
  73987. /**
  73988. * Modifies the data of the tileMaps
  73989. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73990. * @param pos is the iVector2 Coordinates of the Tile
  73991. * @param tile The SpriteIndex of the new Tile
  73992. */
  73993. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73994. /**
  73995. * Creates the animationMap texture Buffer
  73996. * @param buffer normally and array of numbers, or a false to generate from scratch
  73997. * @returns RawTexture of the animationMap
  73998. */
  73999. private _createTileAnimationBuffer;
  74000. /**
  74001. * Modifies the data of the animationMap
  74002. * @param cellID is the Index of the Sprite
  74003. * @param _frame is the target Animation frame
  74004. * @param toCell is the Target Index of the next frame of the animation
  74005. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74006. * @param speed is a global scalar of the time variable on the map.
  74007. */
  74008. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74009. /**
  74010. * Exports the .tilemaps file
  74011. */
  74012. saveTileMaps(): void;
  74013. /**
  74014. * Imports the .tilemaps file
  74015. * @param url of the .tilemaps file
  74016. */
  74017. loadTileMaps(url: string): void;
  74018. /**
  74019. * Release associated resources
  74020. */
  74021. dispose(): void;
  74022. }
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74027. * @see https://doc.babylonjs.com/babylon101/sprites
  74028. */
  74029. export class SpritePackedManager extends SpriteManager {
  74030. /** defines the packed manager's name */
  74031. name: string;
  74032. /**
  74033. * Creates a new sprite manager from a packed sprite sheet
  74034. * @param name defines the manager's name
  74035. * @param imgUrl defines the sprite sheet url
  74036. * @param capacity defines the maximum allowed number of sprites
  74037. * @param scene defines the hosting scene
  74038. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74039. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74040. * @param samplingMode defines the smapling mode to use with spritesheet
  74041. * @param fromPacked set to true; do not alter
  74042. */
  74043. constructor(
  74044. /** defines the packed manager's name */
  74045. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74046. }
  74047. }
  74048. declare module BABYLON {
  74049. /**
  74050. * Defines the list of states available for a task inside a AssetsManager
  74051. */
  74052. export enum AssetTaskState {
  74053. /**
  74054. * Initialization
  74055. */
  74056. INIT = 0,
  74057. /**
  74058. * Running
  74059. */
  74060. RUNNING = 1,
  74061. /**
  74062. * Done
  74063. */
  74064. DONE = 2,
  74065. /**
  74066. * Error
  74067. */
  74068. ERROR = 3
  74069. }
  74070. /**
  74071. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74072. */
  74073. export abstract class AbstractAssetTask {
  74074. /**
  74075. * Task name
  74076. */ name: string;
  74077. /**
  74078. * Callback called when the task is successful
  74079. */
  74080. onSuccess: (task: any) => void;
  74081. /**
  74082. * Callback called when the task is not successful
  74083. */
  74084. onError: (task: any, message?: string, exception?: any) => void;
  74085. /**
  74086. * Creates a new AssetsManager
  74087. * @param name defines the name of the task
  74088. */
  74089. constructor(
  74090. /**
  74091. * Task name
  74092. */ name: string);
  74093. private _isCompleted;
  74094. private _taskState;
  74095. private _errorObject;
  74096. /**
  74097. * Get if the task is completed
  74098. */
  74099. get isCompleted(): boolean;
  74100. /**
  74101. * Gets the current state of the task
  74102. */
  74103. get taskState(): AssetTaskState;
  74104. /**
  74105. * Gets the current error object (if task is in error)
  74106. */
  74107. get errorObject(): {
  74108. message?: string;
  74109. exception?: any;
  74110. };
  74111. /**
  74112. * Internal only
  74113. * @hidden
  74114. */
  74115. _setErrorObject(message?: string, exception?: any): void;
  74116. /**
  74117. * Execute the current task
  74118. * @param scene defines the scene where you want your assets to be loaded
  74119. * @param onSuccess is a callback called when the task is successfully executed
  74120. * @param onError is a callback called if an error occurs
  74121. */
  74122. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74123. /**
  74124. * Execute the current task
  74125. * @param scene defines the scene where you want your assets to be loaded
  74126. * @param onSuccess is a callback called when the task is successfully executed
  74127. * @param onError is a callback called if an error occurs
  74128. */
  74129. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74130. /**
  74131. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74132. * This can be used with failed tasks that have the reason for failure fixed.
  74133. */
  74134. reset(): void;
  74135. private onErrorCallback;
  74136. private onDoneCallback;
  74137. }
  74138. /**
  74139. * Define the interface used by progress events raised during assets loading
  74140. */
  74141. export interface IAssetsProgressEvent {
  74142. /**
  74143. * Defines the number of remaining tasks to process
  74144. */
  74145. remainingCount: number;
  74146. /**
  74147. * Defines the total number of tasks
  74148. */
  74149. totalCount: number;
  74150. /**
  74151. * Defines the task that was just processed
  74152. */
  74153. task: AbstractAssetTask;
  74154. }
  74155. /**
  74156. * Class used to share progress information about assets loading
  74157. */
  74158. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74159. /**
  74160. * Defines the number of remaining tasks to process
  74161. */
  74162. remainingCount: number;
  74163. /**
  74164. * Defines the total number of tasks
  74165. */
  74166. totalCount: number;
  74167. /**
  74168. * Defines the task that was just processed
  74169. */
  74170. task: AbstractAssetTask;
  74171. /**
  74172. * Creates a AssetsProgressEvent
  74173. * @param remainingCount defines the number of remaining tasks to process
  74174. * @param totalCount defines the total number of tasks
  74175. * @param task defines the task that was just processed
  74176. */
  74177. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74178. }
  74179. /**
  74180. * Define a task used by AssetsManager to load assets into a container
  74181. */
  74182. export class ContainerAssetTask extends AbstractAssetTask {
  74183. /**
  74184. * Defines the name of the task
  74185. */
  74186. name: string;
  74187. /**
  74188. * Defines the list of mesh's names you want to load
  74189. */
  74190. meshesNames: any;
  74191. /**
  74192. * Defines the root url to use as a base to load your meshes and associated resources
  74193. */
  74194. rootUrl: string;
  74195. /**
  74196. * Defines the filename or File of the scene to load from
  74197. */
  74198. sceneFilename: string | File;
  74199. /**
  74200. * Get the loaded asset container
  74201. */
  74202. loadedContainer: AssetContainer;
  74203. /**
  74204. * Gets the list of loaded meshes
  74205. */
  74206. loadedMeshes: Array<AbstractMesh>;
  74207. /**
  74208. * Gets the list of loaded particle systems
  74209. */
  74210. loadedParticleSystems: Array<IParticleSystem>;
  74211. /**
  74212. * Gets the list of loaded skeletons
  74213. */
  74214. loadedSkeletons: Array<Skeleton>;
  74215. /**
  74216. * Gets the list of loaded animation groups
  74217. */
  74218. loadedAnimationGroups: Array<AnimationGroup>;
  74219. /**
  74220. * Callback called when the task is successful
  74221. */
  74222. onSuccess: (task: ContainerAssetTask) => void;
  74223. /**
  74224. * Callback called when the task is successful
  74225. */
  74226. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74227. /**
  74228. * Creates a new ContainerAssetTask
  74229. * @param name defines the name of the task
  74230. * @param meshesNames defines the list of mesh's names you want to load
  74231. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74232. * @param sceneFilename defines the filename or File of the scene to load from
  74233. */
  74234. constructor(
  74235. /**
  74236. * Defines the name of the task
  74237. */
  74238. name: string,
  74239. /**
  74240. * Defines the list of mesh's names you want to load
  74241. */
  74242. meshesNames: any,
  74243. /**
  74244. * Defines the root url to use as a base to load your meshes and associated resources
  74245. */
  74246. rootUrl: string,
  74247. /**
  74248. * Defines the filename or File of the scene to load from
  74249. */
  74250. sceneFilename: string | File);
  74251. /**
  74252. * Execute the current task
  74253. * @param scene defines the scene where you want your assets to be loaded
  74254. * @param onSuccess is a callback called when the task is successfully executed
  74255. * @param onError is a callback called if an error occurs
  74256. */
  74257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74258. }
  74259. /**
  74260. * Define a task used by AssetsManager to load meshes
  74261. */
  74262. export class MeshAssetTask extends AbstractAssetTask {
  74263. /**
  74264. * Defines the name of the task
  74265. */
  74266. name: string;
  74267. /**
  74268. * Defines the list of mesh's names you want to load
  74269. */
  74270. meshesNames: any;
  74271. /**
  74272. * Defines the root url to use as a base to load your meshes and associated resources
  74273. */
  74274. rootUrl: string;
  74275. /**
  74276. * Defines the filename or File of the scene to load from
  74277. */
  74278. sceneFilename: string | File;
  74279. /**
  74280. * Gets the list of loaded meshes
  74281. */
  74282. loadedMeshes: Array<AbstractMesh>;
  74283. /**
  74284. * Gets the list of loaded particle systems
  74285. */
  74286. loadedParticleSystems: Array<IParticleSystem>;
  74287. /**
  74288. * Gets the list of loaded skeletons
  74289. */
  74290. loadedSkeletons: Array<Skeleton>;
  74291. /**
  74292. * Gets the list of loaded animation groups
  74293. */
  74294. loadedAnimationGroups: Array<AnimationGroup>;
  74295. /**
  74296. * Callback called when the task is successful
  74297. */
  74298. onSuccess: (task: MeshAssetTask) => void;
  74299. /**
  74300. * Callback called when the task is successful
  74301. */
  74302. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74303. /**
  74304. * Creates a new MeshAssetTask
  74305. * @param name defines the name of the task
  74306. * @param meshesNames defines the list of mesh's names you want to load
  74307. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74308. * @param sceneFilename defines the filename or File of the scene to load from
  74309. */
  74310. constructor(
  74311. /**
  74312. * Defines the name of the task
  74313. */
  74314. name: string,
  74315. /**
  74316. * Defines the list of mesh's names you want to load
  74317. */
  74318. meshesNames: any,
  74319. /**
  74320. * Defines the root url to use as a base to load your meshes and associated resources
  74321. */
  74322. rootUrl: string,
  74323. /**
  74324. * Defines the filename or File of the scene to load from
  74325. */
  74326. sceneFilename: string | File);
  74327. /**
  74328. * Execute the current task
  74329. * @param scene defines the scene where you want your assets to be loaded
  74330. * @param onSuccess is a callback called when the task is successfully executed
  74331. * @param onError is a callback called if an error occurs
  74332. */
  74333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74334. }
  74335. /**
  74336. * Define a task used by AssetsManager to load text content
  74337. */
  74338. export class TextFileAssetTask extends AbstractAssetTask {
  74339. /**
  74340. * Defines the name of the task
  74341. */
  74342. name: string;
  74343. /**
  74344. * Defines the location of the file to load
  74345. */
  74346. url: string;
  74347. /**
  74348. * Gets the loaded text string
  74349. */
  74350. text: string;
  74351. /**
  74352. * Callback called when the task is successful
  74353. */
  74354. onSuccess: (task: TextFileAssetTask) => void;
  74355. /**
  74356. * Callback called when the task is successful
  74357. */
  74358. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74359. /**
  74360. * Creates a new TextFileAssetTask object
  74361. * @param name defines the name of the task
  74362. * @param url defines the location of the file to load
  74363. */
  74364. constructor(
  74365. /**
  74366. * Defines the name of the task
  74367. */
  74368. name: string,
  74369. /**
  74370. * Defines the location of the file to load
  74371. */
  74372. url: string);
  74373. /**
  74374. * Execute the current task
  74375. * @param scene defines the scene where you want your assets to be loaded
  74376. * @param onSuccess is a callback called when the task is successfully executed
  74377. * @param onError is a callback called if an error occurs
  74378. */
  74379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74380. }
  74381. /**
  74382. * Define a task used by AssetsManager to load binary data
  74383. */
  74384. export class BinaryFileAssetTask extends AbstractAssetTask {
  74385. /**
  74386. * Defines the name of the task
  74387. */
  74388. name: string;
  74389. /**
  74390. * Defines the location of the file to load
  74391. */
  74392. url: string;
  74393. /**
  74394. * Gets the lodaded data (as an array buffer)
  74395. */
  74396. data: ArrayBuffer;
  74397. /**
  74398. * Callback called when the task is successful
  74399. */
  74400. onSuccess: (task: BinaryFileAssetTask) => void;
  74401. /**
  74402. * Callback called when the task is successful
  74403. */
  74404. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74405. /**
  74406. * Creates a new BinaryFileAssetTask object
  74407. * @param name defines the name of the new task
  74408. * @param url defines the location of the file to load
  74409. */
  74410. constructor(
  74411. /**
  74412. * Defines the name of the task
  74413. */
  74414. name: string,
  74415. /**
  74416. * Defines the location of the file to load
  74417. */
  74418. url: string);
  74419. /**
  74420. * Execute the current task
  74421. * @param scene defines the scene where you want your assets to be loaded
  74422. * @param onSuccess is a callback called when the task is successfully executed
  74423. * @param onError is a callback called if an error occurs
  74424. */
  74425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74426. }
  74427. /**
  74428. * Define a task used by AssetsManager to load images
  74429. */
  74430. export class ImageAssetTask extends AbstractAssetTask {
  74431. /**
  74432. * Defines the name of the task
  74433. */
  74434. name: string;
  74435. /**
  74436. * Defines the location of the image to load
  74437. */
  74438. url: string;
  74439. /**
  74440. * Gets the loaded images
  74441. */
  74442. image: HTMLImageElement;
  74443. /**
  74444. * Callback called when the task is successful
  74445. */
  74446. onSuccess: (task: ImageAssetTask) => void;
  74447. /**
  74448. * Callback called when the task is successful
  74449. */
  74450. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74451. /**
  74452. * Creates a new ImageAssetTask
  74453. * @param name defines the name of the task
  74454. * @param url defines the location of the image to load
  74455. */
  74456. constructor(
  74457. /**
  74458. * Defines the name of the task
  74459. */
  74460. name: string,
  74461. /**
  74462. * Defines the location of the image to load
  74463. */
  74464. url: string);
  74465. /**
  74466. * Execute the current task
  74467. * @param scene defines the scene where you want your assets to be loaded
  74468. * @param onSuccess is a callback called when the task is successfully executed
  74469. * @param onError is a callback called if an error occurs
  74470. */
  74471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74472. }
  74473. /**
  74474. * Defines the interface used by texture loading tasks
  74475. */
  74476. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74477. /**
  74478. * Gets the loaded texture
  74479. */
  74480. texture: TEX;
  74481. }
  74482. /**
  74483. * Define a task used by AssetsManager to load 2D textures
  74484. */
  74485. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74486. /**
  74487. * Defines the name of the task
  74488. */
  74489. name: string;
  74490. /**
  74491. * Defines the location of the file to load
  74492. */
  74493. url: string;
  74494. /**
  74495. * Defines if mipmap should not be generated (default is false)
  74496. */
  74497. noMipmap?: boolean | undefined;
  74498. /**
  74499. * Defines if texture must be inverted on Y axis (default is true)
  74500. */
  74501. invertY: boolean;
  74502. /**
  74503. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74504. */
  74505. samplingMode: number;
  74506. /**
  74507. * Gets the loaded texture
  74508. */
  74509. texture: Texture;
  74510. /**
  74511. * Callback called when the task is successful
  74512. */
  74513. onSuccess: (task: TextureAssetTask) => void;
  74514. /**
  74515. * Callback called when the task is successful
  74516. */
  74517. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74518. /**
  74519. * Creates a new TextureAssetTask object
  74520. * @param name defines the name of the task
  74521. * @param url defines the location of the file to load
  74522. * @param noMipmap defines if mipmap should not be generated (default is false)
  74523. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74524. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74525. */
  74526. constructor(
  74527. /**
  74528. * Defines the name of the task
  74529. */
  74530. name: string,
  74531. /**
  74532. * Defines the location of the file to load
  74533. */
  74534. url: string,
  74535. /**
  74536. * Defines if mipmap should not be generated (default is false)
  74537. */
  74538. noMipmap?: boolean | undefined,
  74539. /**
  74540. * Defines if texture must be inverted on Y axis (default is true)
  74541. */
  74542. invertY?: boolean,
  74543. /**
  74544. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74545. */
  74546. samplingMode?: number);
  74547. /**
  74548. * Execute the current task
  74549. * @param scene defines the scene where you want your assets to be loaded
  74550. * @param onSuccess is a callback called when the task is successfully executed
  74551. * @param onError is a callback called if an error occurs
  74552. */
  74553. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74554. }
  74555. /**
  74556. * Define a task used by AssetsManager to load cube textures
  74557. */
  74558. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74559. /**
  74560. * Defines the name of the task
  74561. */
  74562. name: string;
  74563. /**
  74564. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74565. */
  74566. url: string;
  74567. /**
  74568. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74569. */
  74570. extensions?: string[] | undefined;
  74571. /**
  74572. * Defines if mipmaps should not be generated (default is false)
  74573. */
  74574. noMipmap?: boolean | undefined;
  74575. /**
  74576. * Defines the explicit list of files (undefined by default)
  74577. */
  74578. files?: string[] | undefined;
  74579. /**
  74580. * Gets the loaded texture
  74581. */
  74582. texture: CubeTexture;
  74583. /**
  74584. * Callback called when the task is successful
  74585. */
  74586. onSuccess: (task: CubeTextureAssetTask) => void;
  74587. /**
  74588. * Callback called when the task is successful
  74589. */
  74590. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74591. /**
  74592. * Creates a new CubeTextureAssetTask
  74593. * @param name defines the name of the task
  74594. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74595. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74596. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74597. * @param files defines the explicit list of files (undefined by default)
  74598. */
  74599. constructor(
  74600. /**
  74601. * Defines the name of the task
  74602. */
  74603. name: string,
  74604. /**
  74605. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74606. */
  74607. url: string,
  74608. /**
  74609. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74610. */
  74611. extensions?: string[] | undefined,
  74612. /**
  74613. * Defines if mipmaps should not be generated (default is false)
  74614. */
  74615. noMipmap?: boolean | undefined,
  74616. /**
  74617. * Defines the explicit list of files (undefined by default)
  74618. */
  74619. files?: string[] | undefined);
  74620. /**
  74621. * Execute the current task
  74622. * @param scene defines the scene where you want your assets to be loaded
  74623. * @param onSuccess is a callback called when the task is successfully executed
  74624. * @param onError is a callback called if an error occurs
  74625. */
  74626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74627. }
  74628. /**
  74629. * Define a task used by AssetsManager to load HDR cube textures
  74630. */
  74631. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74632. /**
  74633. * Defines the name of the task
  74634. */
  74635. name: string;
  74636. /**
  74637. * Defines the location of the file to load
  74638. */
  74639. url: string;
  74640. /**
  74641. * Defines the desired size (the more it increases the longer the generation will be)
  74642. */
  74643. size: number;
  74644. /**
  74645. * Defines if mipmaps should not be generated (default is false)
  74646. */
  74647. noMipmap: boolean;
  74648. /**
  74649. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74650. */
  74651. generateHarmonics: boolean;
  74652. /**
  74653. * 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)
  74654. */
  74655. gammaSpace: boolean;
  74656. /**
  74657. * Internal Use Only
  74658. */
  74659. reserved: boolean;
  74660. /**
  74661. * Gets the loaded texture
  74662. */
  74663. texture: HDRCubeTexture;
  74664. /**
  74665. * Callback called when the task is successful
  74666. */
  74667. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74668. /**
  74669. * Callback called when the task is successful
  74670. */
  74671. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74672. /**
  74673. * Creates a new HDRCubeTextureAssetTask object
  74674. * @param name defines the name of the task
  74675. * @param url defines the location of the file to load
  74676. * @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.
  74677. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74678. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74679. * @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)
  74680. * @param reserved Internal use only
  74681. */
  74682. constructor(
  74683. /**
  74684. * Defines the name of the task
  74685. */
  74686. name: string,
  74687. /**
  74688. * Defines the location of the file to load
  74689. */
  74690. url: string,
  74691. /**
  74692. * Defines the desired size (the more it increases the longer the generation will be)
  74693. */
  74694. size: number,
  74695. /**
  74696. * Defines if mipmaps should not be generated (default is false)
  74697. */
  74698. noMipmap?: boolean,
  74699. /**
  74700. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74701. */
  74702. generateHarmonics?: boolean,
  74703. /**
  74704. * 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)
  74705. */
  74706. gammaSpace?: boolean,
  74707. /**
  74708. * Internal Use Only
  74709. */
  74710. reserved?: boolean);
  74711. /**
  74712. * Execute the current task
  74713. * @param scene defines the scene where you want your assets to be loaded
  74714. * @param onSuccess is a callback called when the task is successfully executed
  74715. * @param onError is a callback called if an error occurs
  74716. */
  74717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74718. }
  74719. /**
  74720. * Define a task used by AssetsManager to load Equirectangular cube textures
  74721. */
  74722. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74723. /**
  74724. * Defines the name of the task
  74725. */
  74726. name: string;
  74727. /**
  74728. * Defines the location of the file to load
  74729. */
  74730. url: string;
  74731. /**
  74732. * Defines the desired size (the more it increases the longer the generation will be)
  74733. */
  74734. size: number;
  74735. /**
  74736. * Defines if mipmaps should not be generated (default is false)
  74737. */
  74738. noMipmap: boolean;
  74739. /**
  74740. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74741. * but the standard material would require them in Gamma space) (default is true)
  74742. */
  74743. gammaSpace: boolean;
  74744. /**
  74745. * Gets the loaded texture
  74746. */
  74747. texture: EquiRectangularCubeTexture;
  74748. /**
  74749. * Callback called when the task is successful
  74750. */
  74751. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74752. /**
  74753. * Callback called when the task is successful
  74754. */
  74755. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74756. /**
  74757. * Creates a new EquiRectangularCubeTextureAssetTask object
  74758. * @param name defines the name of the task
  74759. * @param url defines the location of the file to load
  74760. * @param size defines the desired size (the more it increases the longer the generation will be)
  74761. * If the size is omitted this implies you are using a preprocessed cubemap.
  74762. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74763. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74764. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74765. * (default is true)
  74766. */
  74767. constructor(
  74768. /**
  74769. * Defines the name of the task
  74770. */
  74771. name: string,
  74772. /**
  74773. * Defines the location of the file to load
  74774. */
  74775. url: string,
  74776. /**
  74777. * Defines the desired size (the more it increases the longer the generation will be)
  74778. */
  74779. size: number,
  74780. /**
  74781. * Defines if mipmaps should not be generated (default is false)
  74782. */
  74783. noMipmap?: boolean,
  74784. /**
  74785. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74786. * but the standard material would require them in Gamma space) (default is true)
  74787. */
  74788. gammaSpace?: boolean);
  74789. /**
  74790. * Execute the current task
  74791. * @param scene defines the scene where you want your assets to be loaded
  74792. * @param onSuccess is a callback called when the task is successfully executed
  74793. * @param onError is a callback called if an error occurs
  74794. */
  74795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74796. }
  74797. /**
  74798. * This class can be used to easily import assets into a scene
  74799. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74800. */
  74801. export class AssetsManager {
  74802. private _scene;
  74803. private _isLoading;
  74804. protected _tasks: AbstractAssetTask[];
  74805. protected _waitingTasksCount: number;
  74806. protected _totalTasksCount: number;
  74807. /**
  74808. * Callback called when all tasks are processed
  74809. */
  74810. onFinish: (tasks: AbstractAssetTask[]) => void;
  74811. /**
  74812. * Callback called when a task is successful
  74813. */
  74814. onTaskSuccess: (task: AbstractAssetTask) => void;
  74815. /**
  74816. * Callback called when a task had an error
  74817. */
  74818. onTaskError: (task: AbstractAssetTask) => void;
  74819. /**
  74820. * Callback called when a task is done (whatever the result is)
  74821. */
  74822. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74823. /**
  74824. * Observable called when all tasks are processed
  74825. */
  74826. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74827. /**
  74828. * Observable called when a task had an error
  74829. */
  74830. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74831. /**
  74832. * Observable called when all tasks were executed
  74833. */
  74834. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74835. /**
  74836. * Observable called when a task is done (whatever the result is)
  74837. */
  74838. onProgressObservable: Observable<IAssetsProgressEvent>;
  74839. /**
  74840. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74841. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74842. */
  74843. useDefaultLoadingScreen: boolean;
  74844. /**
  74845. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74846. * when all assets have been downloaded.
  74847. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74848. */
  74849. autoHideLoadingUI: boolean;
  74850. /**
  74851. * Creates a new AssetsManager
  74852. * @param scene defines the scene to work on
  74853. */
  74854. constructor(scene: Scene);
  74855. /**
  74856. * Add a ContainerAssetTask to the list of active tasks
  74857. * @param taskName defines the name of the new task
  74858. * @param meshesNames defines the name of meshes to load
  74859. * @param rootUrl defines the root url to use to locate files
  74860. * @param sceneFilename defines the filename of the scene file
  74861. * @returns a new ContainerAssetTask object
  74862. */
  74863. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74864. /**
  74865. * Add a MeshAssetTask to the list of active tasks
  74866. * @param taskName defines the name of the new task
  74867. * @param meshesNames defines the name of meshes to load
  74868. * @param rootUrl defines the root url to use to locate files
  74869. * @param sceneFilename defines the filename of the scene file
  74870. * @returns a new MeshAssetTask object
  74871. */
  74872. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74873. /**
  74874. * Add a TextFileAssetTask to the list of active tasks
  74875. * @param taskName defines the name of the new task
  74876. * @param url defines the url of the file to load
  74877. * @returns a new TextFileAssetTask object
  74878. */
  74879. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74880. /**
  74881. * Add a BinaryFileAssetTask to the list of active tasks
  74882. * @param taskName defines the name of the new task
  74883. * @param url defines the url of the file to load
  74884. * @returns a new BinaryFileAssetTask object
  74885. */
  74886. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74887. /**
  74888. * Add a ImageAssetTask to the list of active tasks
  74889. * @param taskName defines the name of the new task
  74890. * @param url defines the url of the file to load
  74891. * @returns a new ImageAssetTask object
  74892. */
  74893. addImageTask(taskName: string, url: string): ImageAssetTask;
  74894. /**
  74895. * Add a TextureAssetTask to the list of active tasks
  74896. * @param taskName defines the name of the new task
  74897. * @param url defines the url of the file to load
  74898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74899. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74900. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74901. * @returns a new TextureAssetTask object
  74902. */
  74903. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74904. /**
  74905. * Add a CubeTextureAssetTask to the list of active tasks
  74906. * @param taskName defines the name of the new task
  74907. * @param url defines the url of the file to load
  74908. * @param extensions defines the extension to use to load the cube map (can be null)
  74909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74910. * @param files defines the list of files to load (can be null)
  74911. * @returns a new CubeTextureAssetTask object
  74912. */
  74913. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74914. /**
  74915. *
  74916. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74917. * @param taskName defines the name of the new task
  74918. * @param url defines the url of the file to load
  74919. * @param size defines the size you want for the cubemap (can be null)
  74920. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74921. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74922. * @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)
  74923. * @param reserved Internal use only
  74924. * @returns a new HDRCubeTextureAssetTask object
  74925. */
  74926. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74927. /**
  74928. *
  74929. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74930. * @param taskName defines the name of the new task
  74931. * @param url defines the url of the file to load
  74932. * @param size defines the size you want for the cubemap (can be null)
  74933. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74934. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74935. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74936. * @returns a new EquiRectangularCubeTextureAssetTask object
  74937. */
  74938. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74939. /**
  74940. * Remove a task from the assets manager.
  74941. * @param task the task to remove
  74942. */
  74943. removeTask(task: AbstractAssetTask): void;
  74944. private _decreaseWaitingTasksCount;
  74945. private _runTask;
  74946. /**
  74947. * Reset the AssetsManager and remove all tasks
  74948. * @return the current instance of the AssetsManager
  74949. */
  74950. reset(): AssetsManager;
  74951. /**
  74952. * Start the loading process
  74953. * @return the current instance of the AssetsManager
  74954. */
  74955. load(): AssetsManager;
  74956. /**
  74957. * Start the loading process as an async operation
  74958. * @return a promise returning the list of failed tasks
  74959. */
  74960. loadAsync(): Promise<void>;
  74961. }
  74962. }
  74963. declare module BABYLON {
  74964. /**
  74965. * Wrapper class for promise with external resolve and reject.
  74966. */
  74967. export class Deferred<T> {
  74968. /**
  74969. * The promise associated with this deferred object.
  74970. */
  74971. readonly promise: Promise<T>;
  74972. private _resolve;
  74973. private _reject;
  74974. /**
  74975. * The resolve method of the promise associated with this deferred object.
  74976. */
  74977. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74978. /**
  74979. * The reject method of the promise associated with this deferred object.
  74980. */
  74981. get reject(): (reason?: any) => void;
  74982. /**
  74983. * Constructor for this deferred object.
  74984. */
  74985. constructor();
  74986. }
  74987. }
  74988. declare module BABYLON {
  74989. /**
  74990. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74991. */
  74992. export class MeshExploder {
  74993. private _centerMesh;
  74994. private _meshes;
  74995. private _meshesOrigins;
  74996. private _toCenterVectors;
  74997. private _scaledDirection;
  74998. private _newPosition;
  74999. private _centerPosition;
  75000. /**
  75001. * Explodes meshes from a center mesh.
  75002. * @param meshes The meshes to explode.
  75003. * @param centerMesh The mesh to be center of explosion.
  75004. */
  75005. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75006. private _setCenterMesh;
  75007. /**
  75008. * Get class name
  75009. * @returns "MeshExploder"
  75010. */
  75011. getClassName(): string;
  75012. /**
  75013. * "Exploded meshes"
  75014. * @returns Array of meshes with the centerMesh at index 0.
  75015. */
  75016. getMeshes(): Array<Mesh>;
  75017. /**
  75018. * Explodes meshes giving a specific direction
  75019. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75020. */
  75021. explode(direction?: number): void;
  75022. }
  75023. }
  75024. declare module BABYLON {
  75025. /**
  75026. * Class used to help managing file picking and drag'n'drop
  75027. */
  75028. export class FilesInput {
  75029. /**
  75030. * List of files ready to be loaded
  75031. */
  75032. static get FilesToLoad(): {
  75033. [key: string]: File;
  75034. };
  75035. /**
  75036. * Callback called when a file is processed
  75037. */
  75038. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  75039. private _engine;
  75040. private _currentScene;
  75041. private _sceneLoadedCallback;
  75042. private _progressCallback;
  75043. private _additionalRenderLoopLogicCallback;
  75044. private _textureLoadingCallback;
  75045. private _startingProcessingFilesCallback;
  75046. private _onReloadCallback;
  75047. private _errorCallback;
  75048. private _elementToMonitor;
  75049. private _sceneFileToLoad;
  75050. private _filesToLoad;
  75051. /**
  75052. * Creates a new FilesInput
  75053. * @param engine defines the rendering engine
  75054. * @param scene defines the hosting scene
  75055. * @param sceneLoadedCallback callback called when scene is loaded
  75056. * @param progressCallback callback called to track progress
  75057. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75058. * @param textureLoadingCallback callback called when a texture is loading
  75059. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75060. * @param onReloadCallback callback called when a reload is requested
  75061. * @param errorCallback callback call if an error occurs
  75062. */
  75063. 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>);
  75064. private _dragEnterHandler;
  75065. private _dragOverHandler;
  75066. private _dropHandler;
  75067. /**
  75068. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75069. * @param elementToMonitor defines the DOM element to track
  75070. */
  75071. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75072. /** Gets the current list of files to load */
  75073. get filesToLoad(): File[];
  75074. /**
  75075. * Release all associated resources
  75076. */
  75077. dispose(): void;
  75078. private renderFunction;
  75079. private drag;
  75080. private drop;
  75081. private _traverseFolder;
  75082. private _processFiles;
  75083. /**
  75084. * Load files from a drop event
  75085. * @param event defines the drop event to use as source
  75086. */
  75087. loadFiles(event: any): void;
  75088. private _processReload;
  75089. /**
  75090. * Reload the current scene from the loaded files
  75091. */
  75092. reload(): void;
  75093. }
  75094. }
  75095. declare module BABYLON {
  75096. /**
  75097. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75098. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75099. */
  75100. export class SceneOptimization {
  75101. /**
  75102. * Defines the priority of this optimization (0 by default which means first in the list)
  75103. */
  75104. priority: number;
  75105. /**
  75106. * Gets a string describing the action executed by the current optimization
  75107. * @returns description string
  75108. */
  75109. getDescription(): string;
  75110. /**
  75111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75112. * @param scene defines the current scene where to apply this optimization
  75113. * @param optimizer defines the current optimizer
  75114. * @returns true if everything that can be done was applied
  75115. */
  75116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75117. /**
  75118. * Creates the SceneOptimization object
  75119. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75120. * @param desc defines the description associated with the optimization
  75121. */
  75122. constructor(
  75123. /**
  75124. * Defines the priority of this optimization (0 by default which means first in the list)
  75125. */
  75126. priority?: number);
  75127. }
  75128. /**
  75129. * Defines an optimization used to reduce the size of render target textures
  75130. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75131. */
  75132. export class TextureOptimization extends SceneOptimization {
  75133. /**
  75134. * Defines the priority of this optimization (0 by default which means first in the list)
  75135. */
  75136. priority: number;
  75137. /**
  75138. * 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
  75139. */
  75140. maximumSize: number;
  75141. /**
  75142. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75143. */
  75144. step: number;
  75145. /**
  75146. * Gets a string describing the action executed by the current optimization
  75147. * @returns description string
  75148. */
  75149. getDescription(): string;
  75150. /**
  75151. * Creates the TextureOptimization object
  75152. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75153. * @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
  75154. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75155. */
  75156. constructor(
  75157. /**
  75158. * Defines the priority of this optimization (0 by default which means first in the list)
  75159. */
  75160. priority?: number,
  75161. /**
  75162. * 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
  75163. */
  75164. maximumSize?: number,
  75165. /**
  75166. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75167. */
  75168. step?: number);
  75169. /**
  75170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75171. * @param scene defines the current scene where to apply this optimization
  75172. * @param optimizer defines the current optimizer
  75173. * @returns true if everything that can be done was applied
  75174. */
  75175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75176. }
  75177. /**
  75178. * Defines an optimization used to increase or decrease the rendering resolution
  75179. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75180. */
  75181. export class HardwareScalingOptimization extends SceneOptimization {
  75182. /**
  75183. * Defines the priority of this optimization (0 by default which means first in the list)
  75184. */
  75185. priority: number;
  75186. /**
  75187. * Defines the maximum scale to use (2 by default)
  75188. */
  75189. maximumScale: number;
  75190. /**
  75191. * Defines the step to use between two passes (0.5 by default)
  75192. */
  75193. step: number;
  75194. private _currentScale;
  75195. private _directionOffset;
  75196. /**
  75197. * Gets a string describing the action executed by the current optimization
  75198. * @return description string
  75199. */
  75200. getDescription(): string;
  75201. /**
  75202. * Creates the HardwareScalingOptimization object
  75203. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75204. * @param maximumScale defines the maximum scale to use (2 by default)
  75205. * @param step defines the step to use between two passes (0.5 by default)
  75206. */
  75207. constructor(
  75208. /**
  75209. * Defines the priority of this optimization (0 by default which means first in the list)
  75210. */
  75211. priority?: number,
  75212. /**
  75213. * Defines the maximum scale to use (2 by default)
  75214. */
  75215. maximumScale?: number,
  75216. /**
  75217. * Defines the step to use between two passes (0.5 by default)
  75218. */
  75219. step?: number);
  75220. /**
  75221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75222. * @param scene defines the current scene where to apply this optimization
  75223. * @param optimizer defines the current optimizer
  75224. * @returns true if everything that can be done was applied
  75225. */
  75226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75227. }
  75228. /**
  75229. * Defines an optimization used to remove shadows
  75230. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75231. */
  75232. export class ShadowsOptimization extends SceneOptimization {
  75233. /**
  75234. * Gets a string describing the action executed by the current optimization
  75235. * @return description string
  75236. */
  75237. getDescription(): string;
  75238. /**
  75239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75240. * @param scene defines the current scene where to apply this optimization
  75241. * @param optimizer defines the current optimizer
  75242. * @returns true if everything that can be done was applied
  75243. */
  75244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75245. }
  75246. /**
  75247. * Defines an optimization used to turn post-processes off
  75248. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75249. */
  75250. export class PostProcessesOptimization extends SceneOptimization {
  75251. /**
  75252. * Gets a string describing the action executed by the current optimization
  75253. * @return description string
  75254. */
  75255. getDescription(): string;
  75256. /**
  75257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75258. * @param scene defines the current scene where to apply this optimization
  75259. * @param optimizer defines the current optimizer
  75260. * @returns true if everything that can be done was applied
  75261. */
  75262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75263. }
  75264. /**
  75265. * Defines an optimization used to turn lens flares off
  75266. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75267. */
  75268. export class LensFlaresOptimization extends SceneOptimization {
  75269. /**
  75270. * Gets a string describing the action executed by the current optimization
  75271. * @return description string
  75272. */
  75273. getDescription(): string;
  75274. /**
  75275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75276. * @param scene defines the current scene where to apply this optimization
  75277. * @param optimizer defines the current optimizer
  75278. * @returns true if everything that can be done was applied
  75279. */
  75280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75281. }
  75282. /**
  75283. * Defines an optimization based on user defined callback.
  75284. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75285. */
  75286. export class CustomOptimization extends SceneOptimization {
  75287. /**
  75288. * Callback called to apply the custom optimization.
  75289. */
  75290. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75291. /**
  75292. * Callback called to get custom description
  75293. */
  75294. onGetDescription: () => string;
  75295. /**
  75296. * Gets a string describing the action executed by the current optimization
  75297. * @returns description string
  75298. */
  75299. getDescription(): string;
  75300. /**
  75301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75302. * @param scene defines the current scene where to apply this optimization
  75303. * @param optimizer defines the current optimizer
  75304. * @returns true if everything that can be done was applied
  75305. */
  75306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75307. }
  75308. /**
  75309. * Defines an optimization used to turn particles off
  75310. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75311. */
  75312. export class ParticlesOptimization extends SceneOptimization {
  75313. /**
  75314. * Gets a string describing the action executed by the current optimization
  75315. * @return description string
  75316. */
  75317. getDescription(): string;
  75318. /**
  75319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75320. * @param scene defines the current scene where to apply this optimization
  75321. * @param optimizer defines the current optimizer
  75322. * @returns true if everything that can be done was applied
  75323. */
  75324. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75325. }
  75326. /**
  75327. * Defines an optimization used to turn render targets off
  75328. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75329. */
  75330. export class RenderTargetsOptimization extends SceneOptimization {
  75331. /**
  75332. * Gets a string describing the action executed by the current optimization
  75333. * @return description string
  75334. */
  75335. getDescription(): string;
  75336. /**
  75337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75338. * @param scene defines the current scene where to apply this optimization
  75339. * @param optimizer defines the current optimizer
  75340. * @returns true if everything that can be done was applied
  75341. */
  75342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75343. }
  75344. /**
  75345. * Defines an optimization used to merge meshes with compatible materials
  75346. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75347. */
  75348. export class MergeMeshesOptimization extends SceneOptimization {
  75349. private static _UpdateSelectionTree;
  75350. /**
  75351. * Gets or sets a boolean which defines if optimization octree has to be updated
  75352. */
  75353. static get UpdateSelectionTree(): boolean;
  75354. /**
  75355. * Gets or sets a boolean which defines if optimization octree has to be updated
  75356. */
  75357. static set UpdateSelectionTree(value: boolean);
  75358. /**
  75359. * Gets a string describing the action executed by the current optimization
  75360. * @return description string
  75361. */
  75362. getDescription(): string;
  75363. private _canBeMerged;
  75364. /**
  75365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75366. * @param scene defines the current scene where to apply this optimization
  75367. * @param optimizer defines the current optimizer
  75368. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75369. * @returns true if everything that can be done was applied
  75370. */
  75371. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75372. }
  75373. /**
  75374. * Defines a list of options used by SceneOptimizer
  75375. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75376. */
  75377. export class SceneOptimizerOptions {
  75378. /**
  75379. * Defines the target frame rate to reach (60 by default)
  75380. */
  75381. targetFrameRate: number;
  75382. /**
  75383. * Defines the interval between two checkes (2000ms by default)
  75384. */
  75385. trackerDuration: number;
  75386. /**
  75387. * Gets the list of optimizations to apply
  75388. */
  75389. optimizations: SceneOptimization[];
  75390. /**
  75391. * Creates a new list of options used by SceneOptimizer
  75392. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75393. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75394. */
  75395. constructor(
  75396. /**
  75397. * Defines the target frame rate to reach (60 by default)
  75398. */
  75399. targetFrameRate?: number,
  75400. /**
  75401. * Defines the interval between two checkes (2000ms by default)
  75402. */
  75403. trackerDuration?: number);
  75404. /**
  75405. * Add a new optimization
  75406. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75407. * @returns the current SceneOptimizerOptions
  75408. */
  75409. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75410. /**
  75411. * Add a new custom optimization
  75412. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75413. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75415. * @returns the current SceneOptimizerOptions
  75416. */
  75417. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75418. /**
  75419. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75420. * @param targetFrameRate defines the target frame rate (60 by default)
  75421. * @returns a SceneOptimizerOptions object
  75422. */
  75423. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75424. /**
  75425. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75426. * @param targetFrameRate defines the target frame rate (60 by default)
  75427. * @returns a SceneOptimizerOptions object
  75428. */
  75429. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75430. /**
  75431. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75432. * @param targetFrameRate defines the target frame rate (60 by default)
  75433. * @returns a SceneOptimizerOptions object
  75434. */
  75435. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75436. }
  75437. /**
  75438. * Class used to run optimizations in order to reach a target frame rate
  75439. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75440. */
  75441. export class SceneOptimizer implements IDisposable {
  75442. private _isRunning;
  75443. private _options;
  75444. private _scene;
  75445. private _currentPriorityLevel;
  75446. private _targetFrameRate;
  75447. private _trackerDuration;
  75448. private _currentFrameRate;
  75449. private _sceneDisposeObserver;
  75450. private _improvementMode;
  75451. /**
  75452. * Defines an observable called when the optimizer reaches the target frame rate
  75453. */
  75454. onSuccessObservable: Observable<SceneOptimizer>;
  75455. /**
  75456. * Defines an observable called when the optimizer enables an optimization
  75457. */
  75458. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75459. /**
  75460. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75461. */
  75462. onFailureObservable: Observable<SceneOptimizer>;
  75463. /**
  75464. * Gets a boolean indicating if the optimizer is in improvement mode
  75465. */
  75466. get isInImprovementMode(): boolean;
  75467. /**
  75468. * Gets the current priority level (0 at start)
  75469. */
  75470. get currentPriorityLevel(): number;
  75471. /**
  75472. * Gets the current frame rate checked by the SceneOptimizer
  75473. */
  75474. get currentFrameRate(): number;
  75475. /**
  75476. * Gets or sets the current target frame rate (60 by default)
  75477. */
  75478. get targetFrameRate(): number;
  75479. /**
  75480. * Gets or sets the current target frame rate (60 by default)
  75481. */
  75482. set targetFrameRate(value: number);
  75483. /**
  75484. * Gets or sets the current interval between two checks (every 2000ms by default)
  75485. */
  75486. get trackerDuration(): number;
  75487. /**
  75488. * Gets or sets the current interval between two checks (every 2000ms by default)
  75489. */
  75490. set trackerDuration(value: number);
  75491. /**
  75492. * Gets the list of active optimizations
  75493. */
  75494. get optimizations(): SceneOptimization[];
  75495. /**
  75496. * Creates a new SceneOptimizer
  75497. * @param scene defines the scene to work on
  75498. * @param options defines the options to use with the SceneOptimizer
  75499. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75500. * @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)
  75501. */
  75502. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75503. /**
  75504. * Stops the current optimizer
  75505. */
  75506. stop(): void;
  75507. /**
  75508. * Reset the optimizer to initial step (current priority level = 0)
  75509. */
  75510. reset(): void;
  75511. /**
  75512. * Start the optimizer. By default it will try to reach a specific framerate
  75513. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75514. */
  75515. start(): void;
  75516. private _checkCurrentState;
  75517. /**
  75518. * Release all resources
  75519. */
  75520. dispose(): void;
  75521. /**
  75522. * Helper function to create a SceneOptimizer with one single line of code
  75523. * @param scene defines the scene to work on
  75524. * @param options defines the options to use with the SceneOptimizer
  75525. * @param onSuccess defines a callback to call on success
  75526. * @param onFailure defines a callback to call on failure
  75527. * @returns the new SceneOptimizer object
  75528. */
  75529. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75530. }
  75531. }
  75532. declare module BABYLON {
  75533. /**
  75534. * Class used to serialize a scene into a string
  75535. */
  75536. export class SceneSerializer {
  75537. /**
  75538. * Clear cache used by a previous serialization
  75539. */
  75540. static ClearCache(): void;
  75541. /**
  75542. * Serialize a scene into a JSON compatible object
  75543. * @param scene defines the scene to serialize
  75544. * @returns a JSON compatible object
  75545. */
  75546. static Serialize(scene: Scene): any;
  75547. /**
  75548. * Serialize a mesh into a JSON compatible object
  75549. * @param toSerialize defines the mesh to serialize
  75550. * @param withParents defines if parents must be serialized as well
  75551. * @param withChildren defines if children must be serialized as well
  75552. * @returns a JSON compatible object
  75553. */
  75554. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75555. }
  75556. }
  75557. declare module BABYLON {
  75558. /**
  75559. * Class used to host texture specific utilities
  75560. */
  75561. export class TextureTools {
  75562. /**
  75563. * Uses the GPU to create a copy texture rescaled at a given size
  75564. * @param texture Texture to copy from
  75565. * @param width defines the desired width
  75566. * @param height defines the desired height
  75567. * @param useBilinearMode defines if bilinear mode has to be used
  75568. * @return the generated texture
  75569. */
  75570. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75571. }
  75572. }
  75573. declare module BABYLON {
  75574. /**
  75575. * This represents the different options available for the video capture.
  75576. */
  75577. export interface VideoRecorderOptions {
  75578. /** Defines the mime type of the video. */
  75579. mimeType: string;
  75580. /** Defines the FPS the video should be recorded at. */
  75581. fps: number;
  75582. /** Defines the chunk size for the recording data. */
  75583. recordChunckSize: number;
  75584. /** The audio tracks to attach to the recording. */
  75585. audioTracks?: MediaStreamTrack[];
  75586. }
  75587. /**
  75588. * This can help with recording videos from BabylonJS.
  75589. * This is based on the available WebRTC functionalities of the browser.
  75590. *
  75591. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75592. */
  75593. export class VideoRecorder {
  75594. private static readonly _defaultOptions;
  75595. /**
  75596. * Returns whether or not the VideoRecorder is available in your browser.
  75597. * @param engine Defines the Babylon Engine.
  75598. * @returns true if supported otherwise false.
  75599. */
  75600. static IsSupported(engine: Engine): boolean;
  75601. private readonly _options;
  75602. private _canvas;
  75603. private _mediaRecorder;
  75604. private _recordedChunks;
  75605. private _fileName;
  75606. private _resolve;
  75607. private _reject;
  75608. /**
  75609. * True when a recording is already in progress.
  75610. */
  75611. get isRecording(): boolean;
  75612. /**
  75613. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75614. * @param engine Defines the BabylonJS Engine you wish to record.
  75615. * @param options Defines options that can be used to customize the capture.
  75616. */
  75617. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75618. /**
  75619. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75620. */
  75621. stopRecording(): void;
  75622. /**
  75623. * Starts recording the canvas for a max duration specified in parameters.
  75624. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75625. * If null no automatic download will start and you can rely on the promise to get the data back.
  75626. * @param maxDuration Defines the maximum recording time in seconds.
  75627. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75628. * @return A promise callback at the end of the recording with the video data in Blob.
  75629. */
  75630. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75631. /**
  75632. * Releases internal resources used during the recording.
  75633. */
  75634. dispose(): void;
  75635. private _handleDataAvailable;
  75636. private _handleError;
  75637. private _handleStop;
  75638. }
  75639. }
  75640. declare module BABYLON {
  75641. /**
  75642. * Class containing a set of static utilities functions for screenshots
  75643. */
  75644. export class ScreenshotTools {
  75645. /**
  75646. * Captures a screenshot of the current rendering
  75647. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75648. * @param engine defines the rendering engine
  75649. * @param camera defines the source camera
  75650. * @param size This parameter can be set to a single number or to an object with the
  75651. * following (optional) properties: precision, width, height. If a single number is passed,
  75652. * it will be used for both width and height. If an object is passed, the screenshot size
  75653. * will be derived from the parameters. The precision property is a multiplier allowing
  75654. * rendering at a higher or lower resolution
  75655. * @param successCallback defines the callback receives a single parameter which contains the
  75656. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75657. * src parameter of an <img> to display it
  75658. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75659. * Check your browser for supported MIME types
  75660. */
  75661. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75662. /**
  75663. * Captures a screenshot of the current rendering
  75664. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75665. * @param engine defines the rendering engine
  75666. * @param camera defines the source camera
  75667. * @param size This parameter can be set to a single number or to an object with the
  75668. * following (optional) properties: precision, width, height. If a single number is passed,
  75669. * it will be used for both width and height. If an object is passed, the screenshot size
  75670. * will be derived from the parameters. The precision property is a multiplier allowing
  75671. * rendering at a higher or lower resolution
  75672. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75673. * Check your browser for supported MIME types
  75674. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75675. * to the src parameter of an <img> to display it
  75676. */
  75677. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75678. /**
  75679. * Generates an image screenshot from the specified camera.
  75680. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75681. * @param engine The engine to use for rendering
  75682. * @param camera The camera to use for rendering
  75683. * @param size This parameter can be set to a single number or to an object with the
  75684. * following (optional) properties: precision, width, height. If a single number is passed,
  75685. * it will be used for both width and height. If an object is passed, the screenshot size
  75686. * will be derived from the parameters. The precision property is a multiplier allowing
  75687. * rendering at a higher or lower resolution
  75688. * @param successCallback The callback receives a single parameter which contains the
  75689. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75690. * src parameter of an <img> to display it
  75691. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75692. * Check your browser for supported MIME types
  75693. * @param samples Texture samples (default: 1)
  75694. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75695. * @param fileName A name for for the downloaded file.
  75696. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75697. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75698. */
  75699. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  75700. /**
  75701. * Generates an image screenshot from the specified camera.
  75702. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75703. * @param engine The engine to use for rendering
  75704. * @param camera The camera to use for rendering
  75705. * @param size This parameter can be set to a single number or to an object with the
  75706. * following (optional) properties: precision, width, height. If a single number is passed,
  75707. * it will be used for both width and height. If an object is passed, the screenshot size
  75708. * will be derived from the parameters. The precision property is a multiplier allowing
  75709. * rendering at a higher or lower resolution
  75710. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75711. * Check your browser for supported MIME types
  75712. * @param samples Texture samples (default: 1)
  75713. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75714. * @param fileName A name for for the downloaded file.
  75715. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75716. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75717. * to the src parameter of an <img> to display it
  75718. */
  75719. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75720. /**
  75721. * Gets height and width for screenshot size
  75722. * @private
  75723. */
  75724. private static _getScreenshotSize;
  75725. }
  75726. }
  75727. declare module BABYLON {
  75728. /**
  75729. * Interface for a data buffer
  75730. */
  75731. export interface IDataBuffer {
  75732. /**
  75733. * Reads bytes from the data buffer.
  75734. * @param byteOffset The byte offset to read
  75735. * @param byteLength The byte length to read
  75736. * @returns A promise that resolves when the bytes are read
  75737. */
  75738. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75739. /**
  75740. * The byte length of the buffer.
  75741. */
  75742. readonly byteLength: number;
  75743. }
  75744. /**
  75745. * Utility class for reading from a data buffer
  75746. */
  75747. export class DataReader {
  75748. /**
  75749. * The data buffer associated with this data reader.
  75750. */
  75751. readonly buffer: IDataBuffer;
  75752. /**
  75753. * The current byte offset from the beginning of the data buffer.
  75754. */
  75755. byteOffset: number;
  75756. private _dataView;
  75757. private _dataByteOffset;
  75758. /**
  75759. * Constructor
  75760. * @param buffer The buffer to read
  75761. */
  75762. constructor(buffer: IDataBuffer);
  75763. /**
  75764. * Loads the given byte length.
  75765. * @param byteLength The byte length to load
  75766. * @returns A promise that resolves when the load is complete
  75767. */
  75768. loadAsync(byteLength: number): Promise<void>;
  75769. /**
  75770. * Read a unsigned 32-bit integer from the currently loaded data range.
  75771. * @returns The 32-bit integer read
  75772. */
  75773. readUint32(): number;
  75774. /**
  75775. * Read a byte array from the currently loaded data range.
  75776. * @param byteLength The byte length to read
  75777. * @returns The byte array read
  75778. */
  75779. readUint8Array(byteLength: number): Uint8Array;
  75780. /**
  75781. * Read a string from the currently loaded data range.
  75782. * @param byteLength The byte length to read
  75783. * @returns The string read
  75784. */
  75785. readString(byteLength: number): string;
  75786. /**
  75787. * Skips the given byte length the currently loaded data range.
  75788. * @param byteLength The byte length to skip
  75789. */
  75790. skipBytes(byteLength: number): void;
  75791. }
  75792. }
  75793. declare module BABYLON {
  75794. /**
  75795. * Class for storing data to local storage if available or in-memory storage otherwise
  75796. */
  75797. export class DataStorage {
  75798. private static _Storage;
  75799. private static _GetStorage;
  75800. /**
  75801. * Reads a string from the data storage
  75802. * @param key The key to read
  75803. * @param defaultValue The value if the key doesn't exist
  75804. * @returns The string value
  75805. */
  75806. static ReadString(key: string, defaultValue: string): string;
  75807. /**
  75808. * Writes a string to the data storage
  75809. * @param key The key to write
  75810. * @param value The value to write
  75811. */
  75812. static WriteString(key: string, value: string): void;
  75813. /**
  75814. * Reads a boolean from the data storage
  75815. * @param key The key to read
  75816. * @param defaultValue The value if the key doesn't exist
  75817. * @returns The boolean value
  75818. */
  75819. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75820. /**
  75821. * Writes a boolean to the data storage
  75822. * @param key The key to write
  75823. * @param value The value to write
  75824. */
  75825. static WriteBoolean(key: string, value: boolean): void;
  75826. /**
  75827. * Reads a number from the data storage
  75828. * @param key The key to read
  75829. * @param defaultValue The value if the key doesn't exist
  75830. * @returns The number value
  75831. */
  75832. static ReadNumber(key: string, defaultValue: number): number;
  75833. /**
  75834. * Writes a number to the data storage
  75835. * @param key The key to write
  75836. * @param value The value to write
  75837. */
  75838. static WriteNumber(key: string, value: number): void;
  75839. }
  75840. }
  75841. declare module BABYLON {
  75842. /**
  75843. * Class used to record delta files between 2 scene states
  75844. */
  75845. export class SceneRecorder {
  75846. private _trackedScene;
  75847. private _savedJSON;
  75848. /**
  75849. * Track a given scene. This means the current scene state will be considered the original state
  75850. * @param scene defines the scene to track
  75851. */
  75852. track(scene: Scene): void;
  75853. /**
  75854. * Get the delta between current state and original state
  75855. * @returns a string containing the delta
  75856. */
  75857. getDelta(): any;
  75858. private _compareArray;
  75859. private _compareObjects;
  75860. private _compareCollections;
  75861. private static GetShadowGeneratorById;
  75862. /**
  75863. * Apply a given delta to a given scene
  75864. * @param deltaJSON defines the JSON containing the delta
  75865. * @param scene defines the scene to apply the delta to
  75866. */
  75867. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75868. private static _ApplyPropertiesToEntity;
  75869. private static _ApplyDeltaForEntity;
  75870. }
  75871. }
  75872. declare module BABYLON {
  75873. /**
  75874. * A 3D trajectory consisting of an order list of vectors describing a
  75875. * path of motion through 3D space.
  75876. */
  75877. export class Trajectory {
  75878. private _points;
  75879. private readonly _segmentLength;
  75880. /**
  75881. * Serialize to JSON.
  75882. * @returns serialized JSON string
  75883. */
  75884. serialize(): string;
  75885. /**
  75886. * Deserialize from JSON.
  75887. * @param json serialized JSON string
  75888. * @returns deserialized Trajectory
  75889. */
  75890. static Deserialize(json: string): Trajectory;
  75891. /**
  75892. * Create a new empty Trajectory.
  75893. * @param segmentLength radius of discretization for Trajectory points
  75894. */
  75895. constructor(segmentLength?: number);
  75896. /**
  75897. * Get the length of the Trajectory.
  75898. * @returns length of the Trajectory
  75899. */
  75900. getLength(): number;
  75901. /**
  75902. * Append a new point to the Trajectory.
  75903. * NOTE: This implementation has many allocations.
  75904. * @param point point to append to the Trajectory
  75905. */
  75906. add(point: DeepImmutable<Vector3>): void;
  75907. /**
  75908. * Create a new Trajectory with a segment length chosen to make it
  75909. * probable that the new Trajectory will have a specified number of
  75910. * segments. This operation is imprecise.
  75911. * @param targetResolution number of segments desired
  75912. * @returns new Trajectory with approximately the requested number of segments
  75913. */
  75914. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75915. /**
  75916. * Convert Trajectory segments into tokenized representation. This
  75917. * representation is an array of numbers where each nth number is the
  75918. * index of the token which is most similar to the nth segment of the
  75919. * Trajectory.
  75920. * @param tokens list of vectors which serve as discrete tokens
  75921. * @returns list of indices of most similar token per segment
  75922. */
  75923. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75924. private static _forwardDir;
  75925. private static _inverseFromVec;
  75926. private static _upDir;
  75927. private static _fromToVec;
  75928. private static _lookMatrix;
  75929. /**
  75930. * Transform the rotation (i.e., direction) of a segment to isolate
  75931. * the relative transformation represented by the segment. This operation
  75932. * may or may not succeed due to singularities in the equations that define
  75933. * motion relativity in this context.
  75934. * @param priorVec the origin of the prior segment
  75935. * @param fromVec the origin of the current segment
  75936. * @param toVec the destination of the current segment
  75937. * @param result reference to output variable
  75938. * @returns whether or not transformation was successful
  75939. */
  75940. private static _transformSegmentDirToRef;
  75941. private static _bestMatch;
  75942. private static _score;
  75943. private static _bestScore;
  75944. /**
  75945. * Determine which token vector is most similar to the
  75946. * segment vector.
  75947. * @param segment segment vector
  75948. * @param tokens token vector list
  75949. * @returns index of the most similar token to the segment
  75950. */
  75951. private static _tokenizeSegment;
  75952. }
  75953. /**
  75954. * Class representing a set of known, named trajectories to which Trajectories can be
  75955. * added and using which Trajectories can be recognized.
  75956. */
  75957. export class TrajectoryClassifier {
  75958. private _maximumAllowableMatchCost;
  75959. private _vector3Alphabet;
  75960. private _levenshteinAlphabet;
  75961. private _nameToDescribedTrajectory;
  75962. /**
  75963. * Serialize to JSON.
  75964. * @returns JSON serialization
  75965. */
  75966. serialize(): string;
  75967. /**
  75968. * Deserialize from JSON.
  75969. * @param json JSON serialization
  75970. * @returns deserialized TrajectorySet
  75971. */
  75972. static Deserialize(json: string): TrajectoryClassifier;
  75973. /**
  75974. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75975. * VERY naive, need to be generating these things from known
  75976. * sets. Better version later, probably eliminating this one.
  75977. * @returns auto-generated TrajectorySet
  75978. */
  75979. static Generate(): TrajectoryClassifier;
  75980. private constructor();
  75981. /**
  75982. * Add a new Trajectory to the set with a given name.
  75983. * @param trajectory new Trajectory to be added
  75984. * @param classification name to which to add the Trajectory
  75985. */
  75986. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75987. /**
  75988. * Remove a known named trajectory and all Trajectories associated with it.
  75989. * @param classification name to remove
  75990. * @returns whether anything was removed
  75991. */
  75992. deleteClassification(classification: string): boolean;
  75993. /**
  75994. * Attempt to recognize a Trajectory from among all the classifications
  75995. * already known to the classifier.
  75996. * @param trajectory Trajectory to be recognized
  75997. * @returns classification of Trajectory if recognized, null otherwise
  75998. */
  75999. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  76000. }
  76001. }
  76002. declare module BABYLON {
  76003. /**
  76004. * An interface for all Hit test features
  76005. */
  76006. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76007. /**
  76008. * Triggered when new babylon (transformed) hit test results are available
  76009. */
  76010. onHitTestResultObservable: Observable<T[]>;
  76011. }
  76012. /**
  76013. * Options used for hit testing
  76014. */
  76015. export interface IWebXRLegacyHitTestOptions {
  76016. /**
  76017. * Only test when user interacted with the scene. Default - hit test every frame
  76018. */
  76019. testOnPointerDownOnly?: boolean;
  76020. /**
  76021. * The node to use to transform the local results to world coordinates
  76022. */
  76023. worldParentNode?: TransformNode;
  76024. }
  76025. /**
  76026. * Interface defining the babylon result of raycasting/hit-test
  76027. */
  76028. export interface IWebXRLegacyHitResult {
  76029. /**
  76030. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76031. */
  76032. transformationMatrix: Matrix;
  76033. /**
  76034. * The native hit test result
  76035. */
  76036. xrHitResult: XRHitResult | XRHitTestResult;
  76037. }
  76038. /**
  76039. * The currently-working hit-test module.
  76040. * Hit test (or Ray-casting) is used to interact with the real world.
  76041. * For further information read here - https://github.com/immersive-web/hit-test
  76042. */
  76043. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76044. /**
  76045. * options to use when constructing this feature
  76046. */
  76047. readonly options: IWebXRLegacyHitTestOptions;
  76048. private _direction;
  76049. private _mat;
  76050. private _onSelectEnabled;
  76051. private _origin;
  76052. /**
  76053. * The module's name
  76054. */
  76055. static readonly Name: string;
  76056. /**
  76057. * The (Babylon) version of this module.
  76058. * This is an integer representing the implementation version.
  76059. * This number does not correspond to the WebXR specs version
  76060. */
  76061. static readonly Version: number;
  76062. /**
  76063. * Populated with the last native XR Hit Results
  76064. */
  76065. lastNativeXRHitResults: XRHitResult[];
  76066. /**
  76067. * Triggered when new babylon (transformed) hit test results are available
  76068. */
  76069. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76070. /**
  76071. * Creates a new instance of the (legacy version) hit test feature
  76072. * @param _xrSessionManager an instance of WebXRSessionManager
  76073. * @param options options to use when constructing this feature
  76074. */
  76075. constructor(_xrSessionManager: WebXRSessionManager,
  76076. /**
  76077. * options to use when constructing this feature
  76078. */
  76079. options?: IWebXRLegacyHitTestOptions);
  76080. /**
  76081. * execute a hit test with an XR Ray
  76082. *
  76083. * @param xrSession a native xrSession that will execute this hit test
  76084. * @param xrRay the ray (position and direction) to use for ray-casting
  76085. * @param referenceSpace native XR reference space to use for the hit-test
  76086. * @param filter filter function that will filter the results
  76087. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76088. */
  76089. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76090. /**
  76091. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76092. * @param event the (select) event to use to select with
  76093. * @param referenceSpace the reference space to use for this hit test
  76094. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76095. */
  76096. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76097. /**
  76098. * attach this feature
  76099. * Will usually be called by the features manager
  76100. *
  76101. * @returns true if successful.
  76102. */
  76103. attach(): boolean;
  76104. /**
  76105. * detach this feature.
  76106. * Will usually be called by the features manager
  76107. *
  76108. * @returns true if successful.
  76109. */
  76110. detach(): boolean;
  76111. /**
  76112. * Dispose this feature and all of the resources attached
  76113. */
  76114. dispose(): void;
  76115. protected _onXRFrame(frame: XRFrame): void;
  76116. private _onHitTestResults;
  76117. private _onSelect;
  76118. }
  76119. }
  76120. declare module BABYLON {
  76121. /**
  76122. * Options used for hit testing (version 2)
  76123. */
  76124. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76125. /**
  76126. * Do not create a permanent hit test. Will usually be used when only
  76127. * transient inputs are needed.
  76128. */
  76129. disablePermanentHitTest?: boolean;
  76130. /**
  76131. * Enable transient (for example touch-based) hit test inspections
  76132. */
  76133. enableTransientHitTest?: boolean;
  76134. /**
  76135. * Offset ray for the permanent hit test
  76136. */
  76137. offsetRay?: Vector3;
  76138. /**
  76139. * Offset ray for the transient hit test
  76140. */
  76141. transientOffsetRay?: Vector3;
  76142. /**
  76143. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76144. */
  76145. useReferenceSpace?: boolean;
  76146. /**
  76147. * Override the default entity type(s) of the hit-test result
  76148. */
  76149. entityTypes?: XRHitTestTrackableType[];
  76150. }
  76151. /**
  76152. * Interface defining the babylon result of hit-test
  76153. */
  76154. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76155. /**
  76156. * The input source that generated this hit test (if transient)
  76157. */
  76158. inputSource?: XRInputSource;
  76159. /**
  76160. * Is this a transient hit test
  76161. */
  76162. isTransient?: boolean;
  76163. /**
  76164. * Position of the hit test result
  76165. */
  76166. position: Vector3;
  76167. /**
  76168. * Rotation of the hit test result
  76169. */
  76170. rotationQuaternion: Quaternion;
  76171. /**
  76172. * The native hit test result
  76173. */
  76174. xrHitResult: XRHitTestResult;
  76175. }
  76176. /**
  76177. * The currently-working hit-test module.
  76178. * Hit test (or Ray-casting) is used to interact with the real world.
  76179. * For further information read here - https://github.com/immersive-web/hit-test
  76180. *
  76181. * Tested on chrome (mobile) 80.
  76182. */
  76183. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76184. /**
  76185. * options to use when constructing this feature
  76186. */
  76187. readonly options: IWebXRHitTestOptions;
  76188. private _tmpMat;
  76189. private _tmpPos;
  76190. private _tmpQuat;
  76191. private _transientXrHitTestSource;
  76192. private _xrHitTestSource;
  76193. private initHitTestSource;
  76194. /**
  76195. * The module's name
  76196. */
  76197. static readonly Name: string;
  76198. /**
  76199. * The (Babylon) version of this module.
  76200. * This is an integer representing the implementation version.
  76201. * This number does not correspond to the WebXR specs version
  76202. */
  76203. static readonly Version: number;
  76204. /**
  76205. * When set to true, each hit test will have its own position/rotation objects
  76206. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76207. * the developers will clone them or copy them as they see fit.
  76208. */
  76209. autoCloneTransformation: boolean;
  76210. /**
  76211. * Triggered when new babylon (transformed) hit test results are available
  76212. * Note - this will be called when results come back from the device. It can be an empty array!!
  76213. */
  76214. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76215. /**
  76216. * Use this to temporarily pause hit test checks.
  76217. */
  76218. paused: boolean;
  76219. /**
  76220. * Creates a new instance of the hit test feature
  76221. * @param _xrSessionManager an instance of WebXRSessionManager
  76222. * @param options options to use when constructing this feature
  76223. */
  76224. constructor(_xrSessionManager: WebXRSessionManager,
  76225. /**
  76226. * options to use when constructing this feature
  76227. */
  76228. options?: IWebXRHitTestOptions);
  76229. /**
  76230. * attach this feature
  76231. * Will usually be called by the features manager
  76232. *
  76233. * @returns true if successful.
  76234. */
  76235. attach(): boolean;
  76236. /**
  76237. * detach this feature.
  76238. * Will usually be called by the features manager
  76239. *
  76240. * @returns true if successful.
  76241. */
  76242. detach(): boolean;
  76243. /**
  76244. * Dispose this feature and all of the resources attached
  76245. */
  76246. dispose(): void;
  76247. protected _onXRFrame(frame: XRFrame): void;
  76248. private _processWebXRHitTestResult;
  76249. }
  76250. }
  76251. declare module BABYLON {
  76252. /**
  76253. * Configuration options of the anchor system
  76254. */
  76255. export interface IWebXRAnchorSystemOptions {
  76256. /**
  76257. * a node that will be used to convert local to world coordinates
  76258. */
  76259. worldParentNode?: TransformNode;
  76260. /**
  76261. * If set to true a reference of the created anchors will be kept until the next session starts
  76262. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76263. */
  76264. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76265. }
  76266. /**
  76267. * A babylon container for an XR Anchor
  76268. */
  76269. export interface IWebXRAnchor {
  76270. /**
  76271. * A babylon-assigned ID for this anchor
  76272. */
  76273. id: number;
  76274. /**
  76275. * Transformation matrix to apply to an object attached to this anchor
  76276. */
  76277. transformationMatrix: Matrix;
  76278. /**
  76279. * The native anchor object
  76280. */
  76281. xrAnchor: XRAnchor;
  76282. /**
  76283. * if defined, this object will be constantly updated by the anchor's position and rotation
  76284. */
  76285. attachedNode?: TransformNode;
  76286. /**
  76287. * Remove this anchor from the scene
  76288. */
  76289. remove(): void;
  76290. }
  76291. /**
  76292. * An implementation of the anchor system for WebXR.
  76293. * For further information see https://github.com/immersive-web/anchors/
  76294. */
  76295. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76296. private _options;
  76297. private _lastFrameDetected;
  76298. private _trackedAnchors;
  76299. private _referenceSpaceForFrameAnchors;
  76300. private _futureAnchors;
  76301. /**
  76302. * The module's name
  76303. */
  76304. static readonly Name: string;
  76305. /**
  76306. * The (Babylon) version of this module.
  76307. * This is an integer representing the implementation version.
  76308. * This number does not correspond to the WebXR specs version
  76309. */
  76310. static readonly Version: number;
  76311. /**
  76312. * Observers registered here will be executed when a new anchor was added to the session
  76313. */
  76314. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76315. /**
  76316. * Observers registered here will be executed when an anchor was removed from the session
  76317. */
  76318. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76319. /**
  76320. * Observers registered here will be executed when an existing anchor updates
  76321. * This can execute N times every frame
  76322. */
  76323. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76324. /**
  76325. * Set the reference space to use for anchor creation, when not using a hit test.
  76326. * Will default to the session's reference space if not defined
  76327. */
  76328. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76329. /**
  76330. * constructs a new anchor system
  76331. * @param _xrSessionManager an instance of WebXRSessionManager
  76332. * @param _options configuration object for this feature
  76333. */
  76334. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76335. private _tmpVector;
  76336. private _tmpQuaternion;
  76337. private _populateTmpTransformation;
  76338. /**
  76339. * Create a new anchor point using a hit test result at a specific point in the scene
  76340. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76341. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76342. *
  76343. * @param hitTestResult The hit test result to use for this anchor creation
  76344. * @param position an optional position offset for this anchor
  76345. * @param rotationQuaternion an optional rotation offset for this anchor
  76346. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76347. */
  76348. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76349. /**
  76350. * Add a new anchor at a specific position and rotation
  76351. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76352. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76353. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76354. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76355. *
  76356. * @param position the position in which to add an anchor
  76357. * @param rotationQuaternion an optional rotation for the anchor transformation
  76358. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76359. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76360. */
  76361. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76362. /**
  76363. * Get the list of anchors currently being tracked by the system
  76364. */
  76365. get anchors(): IWebXRAnchor[];
  76366. /**
  76367. * detach this feature.
  76368. * Will usually be called by the features manager
  76369. *
  76370. * @returns true if successful.
  76371. */
  76372. detach(): boolean;
  76373. /**
  76374. * Dispose this feature and all of the resources attached
  76375. */
  76376. dispose(): void;
  76377. protected _onXRFrame(frame: XRFrame): void;
  76378. /**
  76379. * avoiding using Array.find for global support.
  76380. * @param xrAnchor the plane to find in the array
  76381. */
  76382. private _findIndexInAnchorArray;
  76383. private _updateAnchorWithXRFrame;
  76384. private _createAnchorAtTransformation;
  76385. }
  76386. }
  76387. declare module BABYLON {
  76388. /**
  76389. * Options used in the plane detector module
  76390. */
  76391. export interface IWebXRPlaneDetectorOptions {
  76392. /**
  76393. * The node to use to transform the local results to world coordinates
  76394. */
  76395. worldParentNode?: TransformNode;
  76396. /**
  76397. * If set to true a reference of the created planes will be kept until the next session starts
  76398. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76399. */
  76400. doNotRemovePlanesOnSessionEnded?: boolean;
  76401. }
  76402. /**
  76403. * A babylon interface for a WebXR plane.
  76404. * A Plane is actually a polygon, built from N points in space
  76405. *
  76406. * Supported in chrome 79, not supported in canary 81 ATM
  76407. */
  76408. export interface IWebXRPlane {
  76409. /**
  76410. * a babylon-assigned ID for this polygon
  76411. */
  76412. id: number;
  76413. /**
  76414. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76415. */
  76416. polygonDefinition: Array<Vector3>;
  76417. /**
  76418. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76419. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76420. */
  76421. transformationMatrix: Matrix;
  76422. /**
  76423. * the native xr-plane object
  76424. */
  76425. xrPlane: XRPlane;
  76426. }
  76427. /**
  76428. * The plane detector is used to detect planes in the real world when in AR
  76429. * For more information see https://github.com/immersive-web/real-world-geometry/
  76430. */
  76431. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76432. private _options;
  76433. private _detectedPlanes;
  76434. private _enabled;
  76435. private _lastFrameDetected;
  76436. /**
  76437. * The module's name
  76438. */
  76439. static readonly Name: string;
  76440. /**
  76441. * The (Babylon) version of this module.
  76442. * This is an integer representing the implementation version.
  76443. * This number does not correspond to the WebXR specs version
  76444. */
  76445. static readonly Version: number;
  76446. /**
  76447. * Observers registered here will be executed when a new plane was added to the session
  76448. */
  76449. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76450. /**
  76451. * Observers registered here will be executed when a plane is no longer detected in the session
  76452. */
  76453. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76454. /**
  76455. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76456. * This can execute N times every frame
  76457. */
  76458. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76459. /**
  76460. * construct a new Plane Detector
  76461. * @param _xrSessionManager an instance of xr Session manager
  76462. * @param _options configuration to use when constructing this feature
  76463. */
  76464. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76465. /**
  76466. * detach this feature.
  76467. * Will usually be called by the features manager
  76468. *
  76469. * @returns true if successful.
  76470. */
  76471. detach(): boolean;
  76472. /**
  76473. * Dispose this feature and all of the resources attached
  76474. */
  76475. dispose(): void;
  76476. /**
  76477. * Check if the needed objects are defined.
  76478. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76479. */
  76480. isCompatible(): boolean;
  76481. protected _onXRFrame(frame: XRFrame): void;
  76482. private _init;
  76483. private _updatePlaneWithXRPlane;
  76484. /**
  76485. * avoiding using Array.find for global support.
  76486. * @param xrPlane the plane to find in the array
  76487. */
  76488. private findIndexInPlaneArray;
  76489. }
  76490. }
  76491. declare module BABYLON {
  76492. /**
  76493. * Options interface for the background remover plugin
  76494. */
  76495. export interface IWebXRBackgroundRemoverOptions {
  76496. /**
  76497. * Further background meshes to disable when entering AR
  76498. */
  76499. backgroundMeshes?: AbstractMesh[];
  76500. /**
  76501. * flags to configure the removal of the environment helper.
  76502. * If not set, the entire background will be removed. If set, flags should be set as well.
  76503. */
  76504. environmentHelperRemovalFlags?: {
  76505. /**
  76506. * Should the skybox be removed (default false)
  76507. */
  76508. skyBox?: boolean;
  76509. /**
  76510. * Should the ground be removed (default false)
  76511. */
  76512. ground?: boolean;
  76513. };
  76514. /**
  76515. * don't disable the environment helper
  76516. */
  76517. ignoreEnvironmentHelper?: boolean;
  76518. }
  76519. /**
  76520. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76521. */
  76522. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76523. /**
  76524. * read-only options to be used in this module
  76525. */
  76526. readonly options: IWebXRBackgroundRemoverOptions;
  76527. /**
  76528. * The module's name
  76529. */
  76530. static readonly Name: string;
  76531. /**
  76532. * The (Babylon) version of this module.
  76533. * This is an integer representing the implementation version.
  76534. * This number does not correspond to the WebXR specs version
  76535. */
  76536. static readonly Version: number;
  76537. /**
  76538. * registered observers will be triggered when the background state changes
  76539. */
  76540. onBackgroundStateChangedObservable: Observable<boolean>;
  76541. /**
  76542. * constructs a new background remover module
  76543. * @param _xrSessionManager the session manager for this module
  76544. * @param options read-only options to be used in this module
  76545. */
  76546. constructor(_xrSessionManager: WebXRSessionManager,
  76547. /**
  76548. * read-only options to be used in this module
  76549. */
  76550. options?: IWebXRBackgroundRemoverOptions);
  76551. /**
  76552. * attach this feature
  76553. * Will usually be called by the features manager
  76554. *
  76555. * @returns true if successful.
  76556. */
  76557. attach(): boolean;
  76558. /**
  76559. * detach this feature.
  76560. * Will usually be called by the features manager
  76561. *
  76562. * @returns true if successful.
  76563. */
  76564. detach(): boolean;
  76565. /**
  76566. * Dispose this feature and all of the resources attached
  76567. */
  76568. dispose(): void;
  76569. protected _onXRFrame(_xrFrame: XRFrame): void;
  76570. private _setBackgroundState;
  76571. }
  76572. }
  76573. declare module BABYLON {
  76574. /**
  76575. * Options for the controller physics feature
  76576. */
  76577. export class IWebXRControllerPhysicsOptions {
  76578. /**
  76579. * Should the headset get its own impostor
  76580. */
  76581. enableHeadsetImpostor?: boolean;
  76582. /**
  76583. * Optional parameters for the headset impostor
  76584. */
  76585. headsetImpostorParams?: {
  76586. /**
  76587. * The type of impostor to create. Default is sphere
  76588. */
  76589. impostorType: number;
  76590. /**
  76591. * the size of the impostor. Defaults to 10cm
  76592. */
  76593. impostorSize?: number | {
  76594. width: number;
  76595. height: number;
  76596. depth: number;
  76597. };
  76598. /**
  76599. * Friction definitions
  76600. */
  76601. friction?: number;
  76602. /**
  76603. * Restitution
  76604. */
  76605. restitution?: number;
  76606. };
  76607. /**
  76608. * The physics properties of the future impostors
  76609. */
  76610. physicsProperties?: {
  76611. /**
  76612. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76613. * Note that this requires a physics engine that supports mesh impostors!
  76614. */
  76615. useControllerMesh?: boolean;
  76616. /**
  76617. * The type of impostor to create. Default is sphere
  76618. */
  76619. impostorType?: number;
  76620. /**
  76621. * the size of the impostor. Defaults to 10cm
  76622. */
  76623. impostorSize?: number | {
  76624. width: number;
  76625. height: number;
  76626. depth: number;
  76627. };
  76628. /**
  76629. * Friction definitions
  76630. */
  76631. friction?: number;
  76632. /**
  76633. * Restitution
  76634. */
  76635. restitution?: number;
  76636. };
  76637. /**
  76638. * the xr input to use with this pointer selection
  76639. */
  76640. xrInput: WebXRInput;
  76641. }
  76642. /**
  76643. * Add physics impostor to your webxr controllers,
  76644. * including naive calculation of their linear and angular velocity
  76645. */
  76646. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76647. private readonly _options;
  76648. private _attachController;
  76649. private _controllers;
  76650. private _debugMode;
  76651. private _delta;
  76652. private _headsetImpostor?;
  76653. private _headsetMesh?;
  76654. private _lastTimestamp;
  76655. private _tmpQuaternion;
  76656. private _tmpVector;
  76657. /**
  76658. * The module's name
  76659. */
  76660. static readonly Name: string;
  76661. /**
  76662. * The (Babylon) version of this module.
  76663. * This is an integer representing the implementation version.
  76664. * This number does not correspond to the webxr specs version
  76665. */
  76666. static readonly Version: number;
  76667. /**
  76668. * Construct a new Controller Physics Feature
  76669. * @param _xrSessionManager the corresponding xr session manager
  76670. * @param _options options to create this feature with
  76671. */
  76672. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76673. /**
  76674. * @hidden
  76675. * enable debugging - will show console outputs and the impostor mesh
  76676. */
  76677. _enablePhysicsDebug(): void;
  76678. /**
  76679. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76680. * @param xrController the controller to add
  76681. */
  76682. addController(xrController: WebXRInputSource): void;
  76683. /**
  76684. * attach this feature
  76685. * Will usually be called by the features manager
  76686. *
  76687. * @returns true if successful.
  76688. */
  76689. attach(): boolean;
  76690. /**
  76691. * detach this feature.
  76692. * Will usually be called by the features manager
  76693. *
  76694. * @returns true if successful.
  76695. */
  76696. detach(): boolean;
  76697. /**
  76698. * Get the headset impostor, if enabled
  76699. * @returns the impostor
  76700. */
  76701. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76702. /**
  76703. * Get the physics impostor of a specific controller.
  76704. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76705. * @param controller the controller or the controller id of which to get the impostor
  76706. * @returns the impostor or null
  76707. */
  76708. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76709. /**
  76710. * Update the physics properties provided in the constructor
  76711. * @param newProperties the new properties object
  76712. */
  76713. setPhysicsProperties(newProperties: {
  76714. impostorType?: number;
  76715. impostorSize?: number | {
  76716. width: number;
  76717. height: number;
  76718. depth: number;
  76719. };
  76720. friction?: number;
  76721. restitution?: number;
  76722. }): void;
  76723. protected _onXRFrame(_xrFrame: any): void;
  76724. private _detachController;
  76725. }
  76726. }
  76727. declare module BABYLON {
  76728. /**
  76729. * A babylon interface for a "WebXR" feature point.
  76730. * Represents the position and confidence value of a given feature point.
  76731. */
  76732. export interface IWebXRFeaturePoint {
  76733. /**
  76734. * Represents the position of the feature point in world space.
  76735. */
  76736. position: Vector3;
  76737. /**
  76738. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76739. */
  76740. confidenceValue: number;
  76741. }
  76742. /**
  76743. * The feature point system is used to detect feature points from real world geometry.
  76744. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76745. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76746. */
  76747. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76748. private _enabled;
  76749. private _featurePointCloud;
  76750. /**
  76751. * The module's name
  76752. */
  76753. static readonly Name: string;
  76754. /**
  76755. * The (Babylon) version of this module.
  76756. * This is an integer representing the implementation version.
  76757. * This number does not correspond to the WebXR specs version
  76758. */
  76759. static readonly Version: number;
  76760. /**
  76761. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76762. * Will notify the observers about which feature points have been added.
  76763. */
  76764. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76765. /**
  76766. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76767. * Will notify the observers about which feature points have been updated.
  76768. */
  76769. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76770. /**
  76771. * The current feature point cloud maintained across frames.
  76772. */
  76773. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76774. /**
  76775. * construct the feature point system
  76776. * @param _xrSessionManager an instance of xr Session manager
  76777. */
  76778. constructor(_xrSessionManager: WebXRSessionManager);
  76779. /**
  76780. * Detach this feature.
  76781. * Will usually be called by the features manager
  76782. *
  76783. * @returns true if successful.
  76784. */
  76785. detach(): boolean;
  76786. /**
  76787. * Dispose this feature and all of the resources attached
  76788. */
  76789. dispose(): void;
  76790. /**
  76791. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76792. */
  76793. protected _onXRFrame(frame: XRFrame): void;
  76794. /**
  76795. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76796. */
  76797. private _init;
  76798. }
  76799. }
  76800. declare module BABYLON {
  76801. /**
  76802. * Configuration interface for the hand tracking feature
  76803. */
  76804. export interface IWebXRHandTrackingOptions {
  76805. /**
  76806. * The xrInput that will be used as source for new hands
  76807. */
  76808. xrInput: WebXRInput;
  76809. /**
  76810. * Configuration object for the joint meshes
  76811. */
  76812. jointMeshes?: {
  76813. /**
  76814. * Should the meshes created be invisible (defaults to false)
  76815. */
  76816. invisible?: boolean;
  76817. /**
  76818. * A source mesh to be used to create instances. Defaults to a sphere.
  76819. * This mesh will be the source for all other (25) meshes.
  76820. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76821. */
  76822. sourceMesh?: Mesh;
  76823. /**
  76824. * This function will be called after a mesh was created for a specific joint.
  76825. * Using this function you can either manipulate the instance or return a new mesh.
  76826. * When returning a new mesh the instance created before will be disposed
  76827. */
  76828. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76829. /**
  76830. * Should the source mesh stay visible. Defaults to false
  76831. */
  76832. keepOriginalVisible?: boolean;
  76833. /**
  76834. * Scale factor for all instances (defaults to 2)
  76835. */
  76836. scaleFactor?: number;
  76837. /**
  76838. * Should each instance have its own physics impostor
  76839. */
  76840. enablePhysics?: boolean;
  76841. /**
  76842. * If enabled, override default physics properties
  76843. */
  76844. physicsProps?: {
  76845. friction?: number;
  76846. restitution?: number;
  76847. impostorType?: number;
  76848. };
  76849. /**
  76850. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76851. */
  76852. handMesh?: AbstractMesh;
  76853. };
  76854. }
  76855. /**
  76856. * Parts of the hands divided to writs and finger names
  76857. */
  76858. export const enum HandPart {
  76859. /**
  76860. * HandPart - Wrist
  76861. */
  76862. WRIST = "wrist",
  76863. /**
  76864. * HandPart - The THumb
  76865. */
  76866. THUMB = "thumb",
  76867. /**
  76868. * HandPart - Index finger
  76869. */
  76870. INDEX = "index",
  76871. /**
  76872. * HandPart - Middle finger
  76873. */
  76874. MIDDLE = "middle",
  76875. /**
  76876. * HandPart - Ring finger
  76877. */
  76878. RING = "ring",
  76879. /**
  76880. * HandPart - Little finger
  76881. */
  76882. LITTLE = "little"
  76883. }
  76884. /**
  76885. * Representing a single hand (with its corresponding native XRHand object)
  76886. */
  76887. export class WebXRHand implements IDisposable {
  76888. /** the controller to which the hand correlates */
  76889. readonly xrController: WebXRInputSource;
  76890. /** the meshes to be used to track the hand joints */
  76891. readonly trackedMeshes: AbstractMesh[];
  76892. /**
  76893. * Hand-parts definition (key is HandPart)
  76894. */
  76895. handPartsDefinition: {
  76896. [key: string]: number[];
  76897. };
  76898. /**
  76899. * Populate the HandPartsDefinition object.
  76900. * This is called as a side effect since certain browsers don't have XRHand defined.
  76901. */
  76902. private generateHandPartsDefinition;
  76903. /**
  76904. * Construct a new hand object
  76905. * @param xrController the controller to which the hand correlates
  76906. * @param trackedMeshes the meshes to be used to track the hand joints
  76907. */
  76908. constructor(
  76909. /** the controller to which the hand correlates */
  76910. xrController: WebXRInputSource,
  76911. /** the meshes to be used to track the hand joints */
  76912. trackedMeshes: AbstractMesh[]);
  76913. /**
  76914. * Update this hand from the latest xr frame
  76915. * @param xrFrame xrFrame to update from
  76916. * @param referenceSpace The current viewer reference space
  76917. * @param scaleFactor optional scale factor for the meshes
  76918. */
  76919. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76920. /**
  76921. * Get meshes of part of the hand
  76922. * @param part the part of hand to get
  76923. * @returns An array of meshes that correlate to the hand part requested
  76924. */
  76925. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76926. /**
  76927. * Dispose this Hand object
  76928. */
  76929. dispose(): void;
  76930. }
  76931. /**
  76932. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76933. */
  76934. export class WebXRHandTracking extends WebXRAbstractFeature {
  76935. /**
  76936. * options to use when constructing this feature
  76937. */
  76938. readonly options: IWebXRHandTrackingOptions;
  76939. private static _idCounter;
  76940. /**
  76941. * The module's name
  76942. */
  76943. static readonly Name: string;
  76944. /**
  76945. * The (Babylon) version of this module.
  76946. * This is an integer representing the implementation version.
  76947. * This number does not correspond to the WebXR specs version
  76948. */
  76949. static readonly Version: number;
  76950. /**
  76951. * This observable will notify registered observers when a new hand object was added and initialized
  76952. */
  76953. onHandAddedObservable: Observable<WebXRHand>;
  76954. /**
  76955. * This observable will notify its observers right before the hand object is disposed
  76956. */
  76957. onHandRemovedObservable: Observable<WebXRHand>;
  76958. private _hands;
  76959. /**
  76960. * Creates a new instance of the hit test feature
  76961. * @param _xrSessionManager an instance of WebXRSessionManager
  76962. * @param options options to use when constructing this feature
  76963. */
  76964. constructor(_xrSessionManager: WebXRSessionManager,
  76965. /**
  76966. * options to use when constructing this feature
  76967. */
  76968. options: IWebXRHandTrackingOptions);
  76969. /**
  76970. * Check if the needed objects are defined.
  76971. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76972. */
  76973. isCompatible(): boolean;
  76974. /**
  76975. * attach this feature
  76976. * Will usually be called by the features manager
  76977. *
  76978. * @returns true if successful.
  76979. */
  76980. attach(): boolean;
  76981. /**
  76982. * detach this feature.
  76983. * Will usually be called by the features manager
  76984. *
  76985. * @returns true if successful.
  76986. */
  76987. detach(): boolean;
  76988. /**
  76989. * Dispose this feature and all of the resources attached
  76990. */
  76991. dispose(): void;
  76992. /**
  76993. * Get the hand object according to the controller id
  76994. * @param controllerId the controller id to which we want to get the hand
  76995. * @returns null if not found or the WebXRHand object if found
  76996. */
  76997. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76998. /**
  76999. * Get a hand object according to the requested handedness
  77000. * @param handedness the handedness to request
  77001. * @returns null if not found or the WebXRHand object if found
  77002. */
  77003. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  77004. protected _onXRFrame(_xrFrame: XRFrame): void;
  77005. private _attachHand;
  77006. private _detachHand;
  77007. }
  77008. }
  77009. declare module BABYLON {
  77010. /**
  77011. * The motion controller class for all microsoft mixed reality controllers
  77012. */
  77013. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77014. protected readonly _mapping: {
  77015. defaultButton: {
  77016. valueNodeName: string;
  77017. unpressedNodeName: string;
  77018. pressedNodeName: string;
  77019. };
  77020. defaultAxis: {
  77021. valueNodeName: string;
  77022. minNodeName: string;
  77023. maxNodeName: string;
  77024. };
  77025. buttons: {
  77026. "xr-standard-trigger": {
  77027. rootNodeName: string;
  77028. componentProperty: string;
  77029. states: string[];
  77030. };
  77031. "xr-standard-squeeze": {
  77032. rootNodeName: string;
  77033. componentProperty: string;
  77034. states: string[];
  77035. };
  77036. "xr-standard-touchpad": {
  77037. rootNodeName: string;
  77038. labelAnchorNodeName: string;
  77039. touchPointNodeName: string;
  77040. };
  77041. "xr-standard-thumbstick": {
  77042. rootNodeName: string;
  77043. componentProperty: string;
  77044. states: string[];
  77045. };
  77046. };
  77047. axes: {
  77048. "xr-standard-touchpad": {
  77049. "x-axis": {
  77050. rootNodeName: string;
  77051. };
  77052. "y-axis": {
  77053. rootNodeName: string;
  77054. };
  77055. };
  77056. "xr-standard-thumbstick": {
  77057. "x-axis": {
  77058. rootNodeName: string;
  77059. };
  77060. "y-axis": {
  77061. rootNodeName: string;
  77062. };
  77063. };
  77064. };
  77065. };
  77066. /**
  77067. * The base url used to load the left and right controller models
  77068. */
  77069. static MODEL_BASE_URL: string;
  77070. /**
  77071. * The name of the left controller model file
  77072. */
  77073. static MODEL_LEFT_FILENAME: string;
  77074. /**
  77075. * The name of the right controller model file
  77076. */
  77077. static MODEL_RIGHT_FILENAME: string;
  77078. profileId: string;
  77079. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77080. protected _getFilenameAndPath(): {
  77081. filename: string;
  77082. path: string;
  77083. };
  77084. protected _getModelLoadingConstraints(): boolean;
  77085. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77086. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77087. protected _updateModel(): void;
  77088. }
  77089. }
  77090. declare module BABYLON {
  77091. /**
  77092. * The motion controller class for oculus touch (quest, rift).
  77093. * This class supports legacy mapping as well the standard xr mapping
  77094. */
  77095. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77096. private _forceLegacyControllers;
  77097. private _modelRootNode;
  77098. /**
  77099. * The base url used to load the left and right controller models
  77100. */
  77101. static MODEL_BASE_URL: string;
  77102. /**
  77103. * The name of the left controller model file
  77104. */
  77105. static MODEL_LEFT_FILENAME: string;
  77106. /**
  77107. * The name of the right controller model file
  77108. */
  77109. static MODEL_RIGHT_FILENAME: string;
  77110. /**
  77111. * Base Url for the Quest controller model.
  77112. */
  77113. static QUEST_MODEL_BASE_URL: string;
  77114. profileId: string;
  77115. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77116. protected _getFilenameAndPath(): {
  77117. filename: string;
  77118. path: string;
  77119. };
  77120. protected _getModelLoadingConstraints(): boolean;
  77121. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77122. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77123. protected _updateModel(): void;
  77124. /**
  77125. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77126. * between the touch and touch 2.
  77127. */
  77128. private _isQuest;
  77129. }
  77130. }
  77131. declare module BABYLON {
  77132. /**
  77133. * The motion controller class for the standard HTC-Vive controllers
  77134. */
  77135. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77136. private _modelRootNode;
  77137. /**
  77138. * The base url used to load the left and right controller models
  77139. */
  77140. static MODEL_BASE_URL: string;
  77141. /**
  77142. * File name for the controller model.
  77143. */
  77144. static MODEL_FILENAME: string;
  77145. profileId: string;
  77146. /**
  77147. * Create a new Vive motion controller object
  77148. * @param scene the scene to use to create this controller
  77149. * @param gamepadObject the corresponding gamepad object
  77150. * @param handedness the handedness of the controller
  77151. */
  77152. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77153. protected _getFilenameAndPath(): {
  77154. filename: string;
  77155. path: string;
  77156. };
  77157. protected _getModelLoadingConstraints(): boolean;
  77158. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77159. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77160. protected _updateModel(): void;
  77161. }
  77162. }
  77163. declare module BABYLON {
  77164. /**
  77165. * A cursor which tracks a point on a path
  77166. */
  77167. export class PathCursor {
  77168. private path;
  77169. /**
  77170. * Stores path cursor callbacks for when an onchange event is triggered
  77171. */
  77172. private _onchange;
  77173. /**
  77174. * The value of the path cursor
  77175. */
  77176. value: number;
  77177. /**
  77178. * The animation array of the path cursor
  77179. */
  77180. animations: Animation[];
  77181. /**
  77182. * Initializes the path cursor
  77183. * @param path The path to track
  77184. */
  77185. constructor(path: Path2);
  77186. /**
  77187. * Gets the cursor point on the path
  77188. * @returns A point on the path cursor at the cursor location
  77189. */
  77190. getPoint(): Vector3;
  77191. /**
  77192. * Moves the cursor ahead by the step amount
  77193. * @param step The amount to move the cursor forward
  77194. * @returns This path cursor
  77195. */
  77196. moveAhead(step?: number): PathCursor;
  77197. /**
  77198. * Moves the cursor behind by the step amount
  77199. * @param step The amount to move the cursor back
  77200. * @returns This path cursor
  77201. */
  77202. moveBack(step?: number): PathCursor;
  77203. /**
  77204. * Moves the cursor by the step amount
  77205. * If the step amount is greater than one, an exception is thrown
  77206. * @param step The amount to move the cursor
  77207. * @returns This path cursor
  77208. */
  77209. move(step: number): PathCursor;
  77210. /**
  77211. * Ensures that the value is limited between zero and one
  77212. * @returns This path cursor
  77213. */
  77214. private ensureLimits;
  77215. /**
  77216. * Runs onchange callbacks on change (used by the animation engine)
  77217. * @returns This path cursor
  77218. */
  77219. private raiseOnChange;
  77220. /**
  77221. * Executes a function on change
  77222. * @param f A path cursor onchange callback
  77223. * @returns This path cursor
  77224. */
  77225. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77226. }
  77227. }
  77228. declare module BABYLON {
  77229. /** @hidden */
  77230. export var blurPixelShader: {
  77231. name: string;
  77232. shader: string;
  77233. };
  77234. }
  77235. declare module BABYLON {
  77236. /** @hidden */
  77237. export var pointCloudVertexDeclaration: {
  77238. name: string;
  77239. shader: string;
  77240. };
  77241. }
  77242. // Mixins
  77243. interface Window {
  77244. mozIndexedDB: IDBFactory;
  77245. webkitIndexedDB: IDBFactory;
  77246. msIndexedDB: IDBFactory;
  77247. webkitURL: typeof URL;
  77248. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77249. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77250. WebGLRenderingContext: WebGLRenderingContext;
  77251. MSGesture: MSGesture;
  77252. CANNON: any;
  77253. AudioContext: AudioContext;
  77254. webkitAudioContext: AudioContext;
  77255. PointerEvent: any;
  77256. Math: Math;
  77257. Uint8Array: Uint8ArrayConstructor;
  77258. Float32Array: Float32ArrayConstructor;
  77259. mozURL: typeof URL;
  77260. msURL: typeof URL;
  77261. VRFrameData: any; // WebVR, from specs 1.1
  77262. DracoDecoderModule: any;
  77263. setImmediate(handler: (...args: any[]) => void): number;
  77264. }
  77265. interface HTMLCanvasElement {
  77266. requestPointerLock(): void;
  77267. msRequestPointerLock?(): void;
  77268. mozRequestPointerLock?(): void;
  77269. webkitRequestPointerLock?(): void;
  77270. /** Track wether a record is in progress */
  77271. isRecording: boolean;
  77272. /** Capture Stream method defined by some browsers */
  77273. captureStream(fps?: number): MediaStream;
  77274. }
  77275. interface CanvasRenderingContext2D {
  77276. msImageSmoothingEnabled: boolean;
  77277. }
  77278. interface MouseEvent {
  77279. mozMovementX: number;
  77280. mozMovementY: number;
  77281. webkitMovementX: number;
  77282. webkitMovementY: number;
  77283. msMovementX: number;
  77284. msMovementY: number;
  77285. }
  77286. interface Navigator {
  77287. mozGetVRDevices: (any: any) => any;
  77288. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77289. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77290. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77291. webkitGetGamepads(): Gamepad[];
  77292. msGetGamepads(): Gamepad[];
  77293. webkitGamepads(): Gamepad[];
  77294. }
  77295. interface HTMLVideoElement {
  77296. mozSrcObject: any;
  77297. }
  77298. interface Math {
  77299. fround(x: number): number;
  77300. imul(a: number, b: number): number;
  77301. }
  77302. interface WebGLRenderingContext {
  77303. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77304. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77305. vertexAttribDivisor(index: number, divisor: number): void;
  77306. createVertexArray(): any;
  77307. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77308. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77309. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77310. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77311. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77312. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77313. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77314. // Queries
  77315. createQuery(): WebGLQuery;
  77316. deleteQuery(query: WebGLQuery): void;
  77317. beginQuery(target: number, query: WebGLQuery): void;
  77318. endQuery(target: number): void;
  77319. getQueryParameter(query: WebGLQuery, pname: number): any;
  77320. getQuery(target: number, pname: number): any;
  77321. MAX_SAMPLES: number;
  77322. RGBA8: number;
  77323. READ_FRAMEBUFFER: number;
  77324. DRAW_FRAMEBUFFER: number;
  77325. UNIFORM_BUFFER: number;
  77326. HALF_FLOAT_OES: number;
  77327. RGBA16F: number;
  77328. RGBA32F: number;
  77329. R32F: number;
  77330. RG32F: number;
  77331. RGB32F: number;
  77332. R16F: number;
  77333. RG16F: number;
  77334. RGB16F: number;
  77335. RED: number;
  77336. RG: number;
  77337. R8: number;
  77338. RG8: number;
  77339. UNSIGNED_INT_24_8: number;
  77340. DEPTH24_STENCIL8: number;
  77341. MIN: number;
  77342. MAX: number;
  77343. /* Multiple Render Targets */
  77344. drawBuffers(buffers: number[]): void;
  77345. readBuffer(src: number): void;
  77346. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77347. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77348. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77349. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77350. // Occlusion Query
  77351. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77352. ANY_SAMPLES_PASSED: number;
  77353. QUERY_RESULT_AVAILABLE: number;
  77354. QUERY_RESULT: number;
  77355. }
  77356. interface WebGLProgram {
  77357. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77358. }
  77359. interface EXT_disjoint_timer_query {
  77360. QUERY_COUNTER_BITS_EXT: number;
  77361. TIME_ELAPSED_EXT: number;
  77362. TIMESTAMP_EXT: number;
  77363. GPU_DISJOINT_EXT: number;
  77364. QUERY_RESULT_EXT: number;
  77365. QUERY_RESULT_AVAILABLE_EXT: number;
  77366. queryCounterEXT(query: WebGLQuery, target: number): void;
  77367. createQueryEXT(): WebGLQuery;
  77368. beginQueryEXT(target: number, query: WebGLQuery): void;
  77369. endQueryEXT(target: number): void;
  77370. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77371. deleteQueryEXT(query: WebGLQuery): void;
  77372. }
  77373. interface WebGLUniformLocation {
  77374. _currentState: any;
  77375. }
  77376. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77377. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77378. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77379. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77380. interface WebGLRenderingContext {
  77381. readonly RASTERIZER_DISCARD: number;
  77382. readonly DEPTH_COMPONENT24: number;
  77383. readonly TEXTURE_3D: number;
  77384. readonly TEXTURE_2D_ARRAY: number;
  77385. readonly TEXTURE_COMPARE_FUNC: number;
  77386. readonly TEXTURE_COMPARE_MODE: number;
  77387. readonly COMPARE_REF_TO_TEXTURE: number;
  77388. readonly TEXTURE_WRAP_R: number;
  77389. readonly HALF_FLOAT: number;
  77390. readonly RGB8: number;
  77391. readonly RED_INTEGER: number;
  77392. readonly RG_INTEGER: number;
  77393. readonly RGB_INTEGER: number;
  77394. readonly RGBA_INTEGER: number;
  77395. readonly R8_SNORM: number;
  77396. readonly RG8_SNORM: number;
  77397. readonly RGB8_SNORM: number;
  77398. readonly RGBA8_SNORM: number;
  77399. readonly R8I: number;
  77400. readonly RG8I: number;
  77401. readonly RGB8I: number;
  77402. readonly RGBA8I: number;
  77403. readonly R8UI: number;
  77404. readonly RG8UI: number;
  77405. readonly RGB8UI: number;
  77406. readonly RGBA8UI: number;
  77407. readonly R16I: number;
  77408. readonly RG16I: number;
  77409. readonly RGB16I: number;
  77410. readonly RGBA16I: number;
  77411. readonly R16UI: number;
  77412. readonly RG16UI: number;
  77413. readonly RGB16UI: number;
  77414. readonly RGBA16UI: number;
  77415. readonly R32I: number;
  77416. readonly RG32I: number;
  77417. readonly RGB32I: number;
  77418. readonly RGBA32I: number;
  77419. readonly R32UI: number;
  77420. readonly RG32UI: number;
  77421. readonly RGB32UI: number;
  77422. readonly RGBA32UI: number;
  77423. readonly RGB10_A2UI: number;
  77424. readonly R11F_G11F_B10F: number;
  77425. readonly RGB9_E5: number;
  77426. readonly RGB10_A2: number;
  77427. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77428. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77429. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77430. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77431. readonly DEPTH_COMPONENT32F: number;
  77432. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77433. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77434. 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;
  77435. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77436. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77437. readonly TRANSFORM_FEEDBACK: number;
  77438. readonly INTERLEAVED_ATTRIBS: number;
  77439. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77440. createTransformFeedback(): WebGLTransformFeedback;
  77441. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77442. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77443. beginTransformFeedback(primitiveMode: number): void;
  77444. endTransformFeedback(): void;
  77445. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77446. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77447. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77448. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77449. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77450. }
  77451. interface ImageBitmap {
  77452. readonly width: number;
  77453. readonly height: number;
  77454. close(): void;
  77455. }
  77456. interface WebGLQuery extends WebGLObject {
  77457. }
  77458. declare var WebGLQuery: {
  77459. prototype: WebGLQuery;
  77460. new(): WebGLQuery;
  77461. };
  77462. interface WebGLSampler extends WebGLObject {
  77463. }
  77464. declare var WebGLSampler: {
  77465. prototype: WebGLSampler;
  77466. new(): WebGLSampler;
  77467. };
  77468. interface WebGLSync extends WebGLObject {
  77469. }
  77470. declare var WebGLSync: {
  77471. prototype: WebGLSync;
  77472. new(): WebGLSync;
  77473. };
  77474. interface WebGLTransformFeedback extends WebGLObject {
  77475. }
  77476. declare var WebGLTransformFeedback: {
  77477. prototype: WebGLTransformFeedback;
  77478. new(): WebGLTransformFeedback;
  77479. };
  77480. interface WebGLVertexArrayObject extends WebGLObject {
  77481. }
  77482. declare var WebGLVertexArrayObject: {
  77483. prototype: WebGLVertexArrayObject;
  77484. new(): WebGLVertexArrayObject;
  77485. };
  77486. // Type definitions for WebVR API
  77487. // Project: https://w3c.github.io/webvr/
  77488. // Definitions by: six a <https://github.com/lostfictions>
  77489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77490. interface VRDisplay extends EventTarget {
  77491. /**
  77492. * Dictionary of capabilities describing the VRDisplay.
  77493. */
  77494. readonly capabilities: VRDisplayCapabilities;
  77495. /**
  77496. * z-depth defining the far plane of the eye view frustum
  77497. * enables mapping of values in the render target depth
  77498. * attachment to scene coordinates. Initially set to 10000.0.
  77499. */
  77500. depthFar: number;
  77501. /**
  77502. * z-depth defining the near plane of the eye view frustum
  77503. * enables mapping of values in the render target depth
  77504. * attachment to scene coordinates. Initially set to 0.01.
  77505. */
  77506. depthNear: number;
  77507. /**
  77508. * An identifier for this distinct VRDisplay. Used as an
  77509. * association point in the Gamepad API.
  77510. */
  77511. readonly displayId: number;
  77512. /**
  77513. * A display name, a user-readable name identifying it.
  77514. */
  77515. readonly displayName: string;
  77516. readonly isConnected: boolean;
  77517. readonly isPresenting: boolean;
  77518. /**
  77519. * If this VRDisplay supports room-scale experiences, the optional
  77520. * stage attribute contains details on the room-scale parameters.
  77521. */
  77522. readonly stageParameters: VRStageParameters | null;
  77523. /**
  77524. * Passing the value returned by `requestAnimationFrame` to
  77525. * `cancelAnimationFrame` will unregister the callback.
  77526. * @param handle Define the hanle of the request to cancel
  77527. */
  77528. cancelAnimationFrame(handle: number): void;
  77529. /**
  77530. * Stops presenting to the VRDisplay.
  77531. * @returns a promise to know when it stopped
  77532. */
  77533. exitPresent(): Promise<void>;
  77534. /**
  77535. * Return the current VREyeParameters for the given eye.
  77536. * @param whichEye Define the eye we want the parameter for
  77537. * @returns the eye parameters
  77538. */
  77539. getEyeParameters(whichEye: string): VREyeParameters;
  77540. /**
  77541. * Populates the passed VRFrameData with the information required to render
  77542. * the current frame.
  77543. * @param frameData Define the data structure to populate
  77544. * @returns true if ok otherwise false
  77545. */
  77546. getFrameData(frameData: VRFrameData): boolean;
  77547. /**
  77548. * Get the layers currently being presented.
  77549. * @returns the list of VR layers
  77550. */
  77551. getLayers(): VRLayer[];
  77552. /**
  77553. * Return a VRPose containing the future predicted pose of the VRDisplay
  77554. * when the current frame will be presented. The value returned will not
  77555. * change until JavaScript has returned control to the browser.
  77556. *
  77557. * The VRPose will contain the position, orientation, velocity,
  77558. * and acceleration of each of these properties.
  77559. * @returns the pose object
  77560. */
  77561. getPose(): VRPose;
  77562. /**
  77563. * Return the current instantaneous pose of the VRDisplay, with no
  77564. * prediction applied.
  77565. * @returns the current instantaneous pose
  77566. */
  77567. getImmediatePose(): VRPose;
  77568. /**
  77569. * The callback passed to `requestAnimationFrame` will be called
  77570. * any time a new frame should be rendered. When the VRDisplay is
  77571. * presenting the callback will be called at the native refresh
  77572. * rate of the HMD. When not presenting this function acts
  77573. * identically to how window.requestAnimationFrame acts. Content should
  77574. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77575. * asynchronously from other displays and at differing refresh rates.
  77576. * @param callback Define the eaction to run next frame
  77577. * @returns the request handle it
  77578. */
  77579. requestAnimationFrame(callback: FrameRequestCallback): number;
  77580. /**
  77581. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77582. * Repeat calls while already presenting will update the VRLayers being displayed.
  77583. * @param layers Define the list of layer to present
  77584. * @returns a promise to know when the request has been fulfilled
  77585. */
  77586. requestPresent(layers: VRLayer[]): Promise<void>;
  77587. /**
  77588. * Reset the pose for this display, treating its current position and
  77589. * orientation as the "origin/zero" values. VRPose.position,
  77590. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77591. * updated when calling resetPose(). This should be called in only
  77592. * sitting-space experiences.
  77593. */
  77594. resetPose(): void;
  77595. /**
  77596. * The VRLayer provided to the VRDisplay will be captured and presented
  77597. * in the HMD. Calling this function has the same effect on the source
  77598. * canvas as any other operation that uses its source image, and canvases
  77599. * created without preserveDrawingBuffer set to true will be cleared.
  77600. * @param pose Define the pose to submit
  77601. */
  77602. submitFrame(pose?: VRPose): void;
  77603. }
  77604. declare var VRDisplay: {
  77605. prototype: VRDisplay;
  77606. new(): VRDisplay;
  77607. };
  77608. interface VRLayer {
  77609. leftBounds?: number[] | Float32Array | null;
  77610. rightBounds?: number[] | Float32Array | null;
  77611. source?: HTMLCanvasElement | null;
  77612. }
  77613. interface VRDisplayCapabilities {
  77614. readonly canPresent: boolean;
  77615. readonly hasExternalDisplay: boolean;
  77616. readonly hasOrientation: boolean;
  77617. readonly hasPosition: boolean;
  77618. readonly maxLayers: number;
  77619. }
  77620. interface VREyeParameters {
  77621. /** @deprecated */
  77622. readonly fieldOfView: VRFieldOfView;
  77623. readonly offset: Float32Array;
  77624. readonly renderHeight: number;
  77625. readonly renderWidth: number;
  77626. }
  77627. interface VRFieldOfView {
  77628. readonly downDegrees: number;
  77629. readonly leftDegrees: number;
  77630. readonly rightDegrees: number;
  77631. readonly upDegrees: number;
  77632. }
  77633. interface VRFrameData {
  77634. readonly leftProjectionMatrix: Float32Array;
  77635. readonly leftViewMatrix: Float32Array;
  77636. readonly pose: VRPose;
  77637. readonly rightProjectionMatrix: Float32Array;
  77638. readonly rightViewMatrix: Float32Array;
  77639. readonly timestamp: number;
  77640. }
  77641. interface VRPose {
  77642. readonly angularAcceleration: Float32Array | null;
  77643. readonly angularVelocity: Float32Array | null;
  77644. readonly linearAcceleration: Float32Array | null;
  77645. readonly linearVelocity: Float32Array | null;
  77646. readonly orientation: Float32Array | null;
  77647. readonly position: Float32Array | null;
  77648. readonly timestamp: number;
  77649. }
  77650. interface VRStageParameters {
  77651. sittingToStandingTransform?: Float32Array;
  77652. sizeX?: number;
  77653. sizeY?: number;
  77654. }
  77655. interface Navigator {
  77656. getVRDisplays(): Promise<VRDisplay[]>;
  77657. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77658. }
  77659. interface Window {
  77660. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77661. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77662. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77663. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77664. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77665. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77666. }
  77667. interface Gamepad {
  77668. readonly displayId: number;
  77669. }
  77670. /**
  77671. * Available session modes
  77672. */
  77673. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77674. /**
  77675. * Reference space types
  77676. */
  77677. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77678. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77679. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77680. /**
  77681. * Handedness types
  77682. */
  77683. type XRHandedness = "none" | "left" | "right";
  77684. /**
  77685. * InputSource target ray modes
  77686. */
  77687. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77688. /**
  77689. * Eye types
  77690. */
  77691. type XREye = "none" | "left" | "right";
  77692. /**
  77693. * Type of XR events available
  77694. */
  77695. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77696. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77697. type XRPlaneSet = Set<XRPlane>;
  77698. type XRAnchorSet = Set<XRAnchor>;
  77699. type XREventHandler = (callback: any) => void;
  77700. interface XRLayer extends EventTarget {}
  77701. interface XRSessionInit {
  77702. optionalFeatures?: string[];
  77703. requiredFeatures?: string[];
  77704. }
  77705. interface XRSessionEvent extends Event {
  77706. readonly session: XRSession;
  77707. }
  77708. interface XRSystem {
  77709. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77710. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77711. }
  77712. interface XRViewport {
  77713. readonly x: number;
  77714. readonly y: number;
  77715. readonly width: number;
  77716. readonly height: number;
  77717. }
  77718. interface XRWebGLLayerInit {
  77719. antialias?: boolean;
  77720. depth?: boolean;
  77721. stencil?: boolean;
  77722. alpha?: boolean;
  77723. multiview?: boolean;
  77724. framebufferScaleFactor?: number;
  77725. }
  77726. declare class XRWebGLLayer {
  77727. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77728. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77729. readonly antialias: boolean;
  77730. readonly framebuffer: WebGLFramebuffer;
  77731. readonly framebufferWidth: number;
  77732. readonly framebufferHeight: number;
  77733. readonly ignoreDepthValues: boolean;
  77734. getViewport: (view: XRView) => XRViewport;
  77735. }
  77736. // tslint:disable-next-line no-empty-interface
  77737. interface XRSpace extends EventTarget {}
  77738. interface XRRenderState {
  77739. readonly baseLayer?: XRWebGLLayer;
  77740. readonly depthFar: number;
  77741. readonly depthNear: number;
  77742. readonly inlineVerticalFieldOfView?: number;
  77743. }
  77744. interface XRRenderStateInit extends XRRenderState {
  77745. baseLayer: XRWebGLLayer;
  77746. depthFar: number;
  77747. depthNear: number;
  77748. inlineVerticalFieldOfView?: number;
  77749. layers?: XRLayer[];
  77750. }
  77751. interface XRReferenceSpace extends XRSpace {
  77752. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77753. onreset: XREventHandler;
  77754. }
  77755. interface XRBoundedReferenceSpace extends XRSpace {
  77756. readonly boundsGeometry: DOMPointReadOnly[];
  77757. }
  77758. interface XRInputSource {
  77759. readonly handedness: XRHandedness;
  77760. readonly targetRayMode: XRTargetRayMode;
  77761. readonly targetRaySpace: XRSpace;
  77762. readonly gripSpace?: XRSpace;
  77763. readonly gamepad?: Gamepad;
  77764. readonly profiles: Array<string>;
  77765. readonly hand?: XRHand;
  77766. }
  77767. interface XRPose {
  77768. readonly transform: XRRigidTransform;
  77769. readonly emulatedPosition: boolean;
  77770. }
  77771. interface XRFrame {
  77772. readonly session: XRSession;
  77773. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77774. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77775. // AR
  77776. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77777. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77778. // Anchors
  77779. trackedAnchors?: XRAnchorSet;
  77780. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77781. // Planes
  77782. worldInformation?: {
  77783. detectedPlanes?: XRPlaneSet;
  77784. };
  77785. // Hand tracking
  77786. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77787. }
  77788. interface XRInputSourceEvent extends Event {
  77789. readonly frame: XRFrame;
  77790. readonly inputSource: XRInputSource;
  77791. }
  77792. type XRInputSourceArray = XRInputSource[];
  77793. interface XRSession {
  77794. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77795. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77796. /**
  77797. * Returns a list of this session's XRInputSources, each representing an input device
  77798. * used to control the camera and/or scene.
  77799. */
  77800. readonly inputSources: Array<XRInputSource>;
  77801. /**
  77802. * object which contains options affecting how the imagery is rendered.
  77803. * This includes things such as the near and far clipping planes
  77804. */
  77805. readonly renderState: XRRenderState;
  77806. readonly visibilityState: XRVisibilityState;
  77807. /**
  77808. * Removes a callback from the animation frame painting callback from
  77809. * XRSession's set of animation frame rendering callbacks, given the
  77810. * identifying handle returned by a previous call to requestAnimationFrame().
  77811. */
  77812. cancelAnimationFrame: (handle: number) => void;
  77813. /**
  77814. * Ends the WebXR session. Returns a promise which resolves when the
  77815. * session has been shut down.
  77816. */
  77817. end(): Promise<void>;
  77818. /**
  77819. * Schedules the specified method to be called the next time the user agent
  77820. * is working on rendering an animation frame for the WebXR device. Returns an
  77821. * integer value which can be used to identify the request for the purposes of
  77822. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77823. * to the Window.requestAnimationFrame() method.
  77824. */
  77825. requestAnimationFrame: XRFrameRequestCallback;
  77826. /**
  77827. * Requests that a new XRReferenceSpace of the specified type be created.
  77828. * Returns a promise which resolves with the XRReferenceSpace or
  77829. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77830. * the requested space type isn't supported by the device.
  77831. */
  77832. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77833. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77834. onend: XREventHandler;
  77835. oninputsourceschange: XREventHandler;
  77836. onselect: XREventHandler;
  77837. onselectstart: XREventHandler;
  77838. onselectend: XREventHandler;
  77839. onsqueeze: XREventHandler;
  77840. onsqueezestart: XREventHandler;
  77841. onsqueezeend: XREventHandler;
  77842. onvisibilitychange: XREventHandler;
  77843. // hit test
  77844. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77845. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77846. // legacy AR hit test
  77847. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77848. // legacy plane detection
  77849. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77850. }
  77851. interface XRViewerPose extends XRPose {
  77852. readonly views: Array<XRView>;
  77853. }
  77854. declare class XRRigidTransform {
  77855. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77856. position: DOMPointReadOnly;
  77857. orientation: DOMPointReadOnly;
  77858. matrix: Float32Array;
  77859. inverse: XRRigidTransform;
  77860. }
  77861. interface XRView {
  77862. readonly eye: XREye;
  77863. readonly projectionMatrix: Float32Array;
  77864. readonly transform: XRRigidTransform;
  77865. readonly recommendedViewportScale?: number;
  77866. requestViewportScale(scale: number): void;
  77867. }
  77868. interface XRInputSourceChangeEvent extends Event {
  77869. session: XRSession;
  77870. removed: Array<XRInputSource>;
  77871. added: Array<XRInputSource>;
  77872. }
  77873. // Experimental/Draft features
  77874. declare class XRRay {
  77875. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77876. origin: DOMPointReadOnly;
  77877. direction: DOMPointReadOnly;
  77878. matrix: Float32Array;
  77879. }
  77880. declare enum XRHitTestTrackableType {
  77881. "point",
  77882. "plane",
  77883. "mesh",
  77884. }
  77885. interface XRHitResult {
  77886. hitMatrix: Float32Array;
  77887. }
  77888. interface XRTransientInputHitTestResult {
  77889. readonly inputSource: XRInputSource;
  77890. readonly results: Array<XRHitTestResult>;
  77891. }
  77892. interface XRHitTestResult {
  77893. getPose(baseSpace: XRSpace): XRPose | undefined;
  77894. // When anchor system is enabled
  77895. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77896. }
  77897. interface XRHitTestSource {
  77898. cancel(): void;
  77899. }
  77900. interface XRTransientInputHitTestSource {
  77901. cancel(): void;
  77902. }
  77903. interface XRHitTestOptionsInit {
  77904. space: XRSpace;
  77905. entityTypes?: Array<XRHitTestTrackableType>;
  77906. offsetRay?: XRRay;
  77907. }
  77908. interface XRTransientInputHitTestOptionsInit {
  77909. profile: string;
  77910. entityTypes?: Array<XRHitTestTrackableType>;
  77911. offsetRay?: XRRay;
  77912. }
  77913. interface XRAnchor {
  77914. anchorSpace: XRSpace;
  77915. delete(): void;
  77916. }
  77917. interface XRPlane {
  77918. orientation: "Horizontal" | "Vertical";
  77919. planeSpace: XRSpace;
  77920. polygon: Array<DOMPointReadOnly>;
  77921. lastChangedTime: number;
  77922. }
  77923. interface XRJointSpace extends XRSpace {}
  77924. interface XRJointPose extends XRPose {
  77925. radius: number | undefined;
  77926. }
  77927. interface XRHand extends Iterable<XRJointSpace> {
  77928. readonly length: number;
  77929. [index: number]: XRJointSpace;
  77930. readonly WRIST: number;
  77931. readonly THUMB_METACARPAL: number;
  77932. readonly THUMB_PHALANX_PROXIMAL: number;
  77933. readonly THUMB_PHALANX_DISTAL: number;
  77934. readonly THUMB_PHALANX_TIP: number;
  77935. readonly INDEX_METACARPAL: number;
  77936. readonly INDEX_PHALANX_PROXIMAL: number;
  77937. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77938. readonly INDEX_PHALANX_DISTAL: number;
  77939. readonly INDEX_PHALANX_TIP: number;
  77940. readonly MIDDLE_METACARPAL: number;
  77941. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77942. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77943. readonly MIDDLE_PHALANX_DISTAL: number;
  77944. readonly MIDDLE_PHALANX_TIP: number;
  77945. readonly RING_METACARPAL: number;
  77946. readonly RING_PHALANX_PROXIMAL: number;
  77947. readonly RING_PHALANX_INTERMEDIATE: number;
  77948. readonly RING_PHALANX_DISTAL: number;
  77949. readonly RING_PHALANX_TIP: number;
  77950. readonly LITTLE_METACARPAL: number;
  77951. readonly LITTLE_PHALANX_PROXIMAL: number;
  77952. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77953. readonly LITTLE_PHALANX_DISTAL: number;
  77954. readonly LITTLE_PHALANX_TIP: number;
  77955. }
  77956. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77957. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77958. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77959. interface XRSession {
  77960. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77961. }
  77962. interface XRFrame {
  77963. featurePointCloud? : Array<number>;
  77964. }
  77965. /**
  77966. * @ignore
  77967. */
  77968. declare module BABYLON.GLTF2.Exporter {
  77969. }
  77970. /**
  77971. * @ignore
  77972. */
  77973. declare module BABYLON.GLTF1 {
  77974. }
  77975. declare module BABYLON.GUI {
  77976. /**
  77977. * Class used to specific a value and its associated unit
  77978. */
  77979. export class ValueAndUnit {
  77980. /** defines the unit to store */
  77981. unit: number;
  77982. /** defines a boolean indicating if the value can be negative */
  77983. negativeValueAllowed: boolean;
  77984. private _value;
  77985. private _originalUnit;
  77986. /**
  77987. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77988. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77989. */
  77990. ignoreAdaptiveScaling: boolean;
  77991. /**
  77992. * Creates a new ValueAndUnit
  77993. * @param value defines the value to store
  77994. * @param unit defines the unit to store
  77995. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77996. */
  77997. constructor(value: number,
  77998. /** defines the unit to store */
  77999. unit?: number,
  78000. /** defines a boolean indicating if the value can be negative */
  78001. negativeValueAllowed?: boolean);
  78002. /** Gets a boolean indicating if the value is a percentage */
  78003. get isPercentage(): boolean;
  78004. /** Gets a boolean indicating if the value is store as pixel */
  78005. get isPixel(): boolean;
  78006. /** Gets direct internal value */
  78007. get internalValue(): number;
  78008. /**
  78009. * Gets value as pixel
  78010. * @param host defines the root host
  78011. * @param refValue defines the reference value for percentages
  78012. * @returns the value as pixel
  78013. */
  78014. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  78015. /**
  78016. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  78017. * @param value defines the value to store
  78018. * @param unit defines the unit to store
  78019. * @returns the current ValueAndUnit
  78020. */
  78021. updateInPlace(value: number, unit?: number): ValueAndUnit;
  78022. /**
  78023. * Gets the value accordingly to its unit
  78024. * @param host defines the root host
  78025. * @returns the value
  78026. */
  78027. getValue(host: AdvancedDynamicTexture): number;
  78028. /**
  78029. * Gets a string representation of the value
  78030. * @param host defines the root host
  78031. * @param decimals defines an optional number of decimals to display
  78032. * @returns a string
  78033. */
  78034. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  78035. /**
  78036. * Store a value parsed from a string
  78037. * @param source defines the source string
  78038. * @returns true if the value was successfully parsed
  78039. */
  78040. fromString(source: string | number): boolean;
  78041. private static _Regex;
  78042. private static _UNITMODE_PERCENTAGE;
  78043. private static _UNITMODE_PIXEL;
  78044. /** UNITMODE_PERCENTAGE */
  78045. static get UNITMODE_PERCENTAGE(): number;
  78046. /** UNITMODE_PIXEL */
  78047. static get UNITMODE_PIXEL(): number;
  78048. }
  78049. }
  78050. declare module BABYLON.GUI {
  78051. /**
  78052. * Define a style used by control to automatically setup properties based on a template.
  78053. * Only support font related properties so far
  78054. */
  78055. export class Style implements BABYLON.IDisposable {
  78056. private _fontFamily;
  78057. private _fontStyle;
  78058. private _fontWeight;
  78059. /** @hidden */
  78060. _host: AdvancedDynamicTexture;
  78061. /** @hidden */
  78062. _fontSize: ValueAndUnit;
  78063. /**
  78064. * BABYLON.Observable raised when the style values are changed
  78065. */
  78066. onChangedObservable: BABYLON.Observable<Style>;
  78067. /**
  78068. * Creates a new style object
  78069. * @param host defines the AdvancedDynamicTexture which hosts this style
  78070. */
  78071. constructor(host: AdvancedDynamicTexture);
  78072. /**
  78073. * Gets or sets the font size
  78074. */
  78075. get fontSize(): string | number;
  78076. set fontSize(value: string | number);
  78077. /**
  78078. * Gets or sets the font family
  78079. */
  78080. get fontFamily(): string;
  78081. set fontFamily(value: string);
  78082. /**
  78083. * Gets or sets the font style
  78084. */
  78085. get fontStyle(): string;
  78086. set fontStyle(value: string);
  78087. /** Gets or sets font weight */
  78088. get fontWeight(): string;
  78089. set fontWeight(value: string);
  78090. /** Dispose all associated resources */
  78091. dispose(): void;
  78092. }
  78093. }
  78094. declare module BABYLON.GUI {
  78095. /**
  78096. * Class used to transport BABYLON.Vector2 information for pointer events
  78097. */
  78098. export class Vector2WithInfo extends BABYLON.Vector2 {
  78099. /** defines the current mouse button index */
  78100. buttonIndex: number;
  78101. /**
  78102. * Creates a new Vector2WithInfo
  78103. * @param source defines the vector2 data to transport
  78104. * @param buttonIndex defines the current mouse button index
  78105. */
  78106. constructor(source: BABYLON.Vector2,
  78107. /** defines the current mouse button index */
  78108. buttonIndex?: number);
  78109. }
  78110. /** Class used to provide 2D matrix features */
  78111. export class Matrix2D {
  78112. /** Gets the internal array of 6 floats used to store matrix data */
  78113. m: Float32Array;
  78114. /**
  78115. * Creates a new matrix
  78116. * @param m00 defines value for (0, 0)
  78117. * @param m01 defines value for (0, 1)
  78118. * @param m10 defines value for (1, 0)
  78119. * @param m11 defines value for (1, 1)
  78120. * @param m20 defines value for (2, 0)
  78121. * @param m21 defines value for (2, 1)
  78122. */
  78123. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78124. /**
  78125. * Fills the matrix from direct values
  78126. * @param m00 defines value for (0, 0)
  78127. * @param m01 defines value for (0, 1)
  78128. * @param m10 defines value for (1, 0)
  78129. * @param m11 defines value for (1, 1)
  78130. * @param m20 defines value for (2, 0)
  78131. * @param m21 defines value for (2, 1)
  78132. * @returns the current modified matrix
  78133. */
  78134. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78135. /**
  78136. * Gets matrix determinant
  78137. * @returns the determinant
  78138. */
  78139. determinant(): number;
  78140. /**
  78141. * Inverses the matrix and stores it in a target matrix
  78142. * @param result defines the target matrix
  78143. * @returns the current matrix
  78144. */
  78145. invertToRef(result: Matrix2D): Matrix2D;
  78146. /**
  78147. * Multiplies the current matrix with another one
  78148. * @param other defines the second operand
  78149. * @param result defines the target matrix
  78150. * @returns the current matrix
  78151. */
  78152. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78153. /**
  78154. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78155. * @param x defines the x coordinate to transform
  78156. * @param y defines the x coordinate to transform
  78157. * @param result defines the target vector2
  78158. * @returns the current matrix
  78159. */
  78160. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78161. /**
  78162. * Creates an identity matrix
  78163. * @returns a new matrix
  78164. */
  78165. static Identity(): Matrix2D;
  78166. /**
  78167. * Creates a translation matrix and stores it in a target matrix
  78168. * @param x defines the x coordinate of the translation
  78169. * @param y defines the y coordinate of the translation
  78170. * @param result defines the target matrix
  78171. */
  78172. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78173. /**
  78174. * Creates a scaling matrix and stores it in a target matrix
  78175. * @param x defines the x coordinate of the scaling
  78176. * @param y defines the y coordinate of the scaling
  78177. * @param result defines the target matrix
  78178. */
  78179. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78180. /**
  78181. * Creates a rotation matrix and stores it in a target matrix
  78182. * @param angle defines the rotation angle
  78183. * @param result defines the target matrix
  78184. */
  78185. static RotationToRef(angle: number, result: Matrix2D): void;
  78186. private static _TempPreTranslationMatrix;
  78187. private static _TempPostTranslationMatrix;
  78188. private static _TempRotationMatrix;
  78189. private static _TempScalingMatrix;
  78190. private static _TempCompose0;
  78191. private static _TempCompose1;
  78192. private static _TempCompose2;
  78193. /**
  78194. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78195. * @param tx defines the x coordinate of the translation
  78196. * @param ty defines the y coordinate of the translation
  78197. * @param angle defines the rotation angle
  78198. * @param scaleX defines the x coordinate of the scaling
  78199. * @param scaleY defines the y coordinate of the scaling
  78200. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78201. * @param result defines the target matrix
  78202. */
  78203. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78204. }
  78205. }
  78206. declare module BABYLON.GUI {
  78207. /**
  78208. * Class used to store 2D control sizes
  78209. */
  78210. export class Measure {
  78211. /** defines left coordinate */
  78212. left: number;
  78213. /** defines top coordinate */
  78214. top: number;
  78215. /** defines width dimension */
  78216. width: number;
  78217. /** defines height dimension */
  78218. height: number;
  78219. /**
  78220. * Creates a new measure
  78221. * @param left defines left coordinate
  78222. * @param top defines top coordinate
  78223. * @param width defines width dimension
  78224. * @param height defines height dimension
  78225. */
  78226. constructor(
  78227. /** defines left coordinate */
  78228. left: number,
  78229. /** defines top coordinate */
  78230. top: number,
  78231. /** defines width dimension */
  78232. width: number,
  78233. /** defines height dimension */
  78234. height: number);
  78235. /**
  78236. * Copy from another measure
  78237. * @param other defines the other measure to copy from
  78238. */
  78239. copyFrom(other: Measure): void;
  78240. /**
  78241. * Copy from a group of 4 floats
  78242. * @param left defines left coordinate
  78243. * @param top defines top coordinate
  78244. * @param width defines width dimension
  78245. * @param height defines height dimension
  78246. */
  78247. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78248. /**
  78249. * Computes the axis aligned bounding box measure for two given measures
  78250. * @param a Input measure
  78251. * @param b Input measure
  78252. * @param result the resulting bounding measure
  78253. */
  78254. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78255. /**
  78256. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78257. * @param transform the matrix to transform the measure before computing the AABB
  78258. * @param addX number to add to left
  78259. * @param addY number to add to top
  78260. * @param addWidth number to add to width
  78261. * @param addHeight number to add to height
  78262. * @param result the resulting AABB
  78263. */
  78264. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78265. /**
  78266. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78267. * @param transform the matrix to transform the measure before computing the AABB
  78268. * @param result the resulting AABB
  78269. */
  78270. transformToRef(transform: Matrix2D, result: Measure): void;
  78271. /**
  78272. * Check equality between this measure and another one
  78273. * @param other defines the other measures
  78274. * @returns true if both measures are equals
  78275. */
  78276. isEqualsTo(other: Measure): boolean;
  78277. /**
  78278. * Creates an empty measure
  78279. * @returns a new measure
  78280. */
  78281. static Empty(): Measure;
  78282. }
  78283. }
  78284. declare module BABYLON.GUI {
  78285. /**
  78286. * Interface used to define a control that can receive focus
  78287. */
  78288. export interface IFocusableControl {
  78289. /**
  78290. * Function called when the control receives the focus
  78291. */
  78292. onFocus(): void;
  78293. /**
  78294. * Function called when the control loses the focus
  78295. */
  78296. onBlur(): void;
  78297. /**
  78298. * Function called to let the control handle keyboard events
  78299. * @param evt defines the current keyboard event
  78300. */
  78301. processKeyboard(evt: KeyboardEvent): void;
  78302. /**
  78303. * Function called to get the list of controls that should not steal the focus from this control
  78304. * @returns an array of controls
  78305. */
  78306. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78307. }
  78308. /**
  78309. * Class used to create texture to support 2D GUI elements
  78310. * @see https://doc.babylonjs.com/how_to/gui
  78311. */
  78312. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78313. private _isDirty;
  78314. private _renderObserver;
  78315. private _resizeObserver;
  78316. private _preKeyboardObserver;
  78317. private _pointerMoveObserver;
  78318. private _pointerObserver;
  78319. private _canvasPointerOutObserver;
  78320. private _canvasBlurObserver;
  78321. private _background;
  78322. /** @hidden */
  78323. _rootContainer: Container;
  78324. /** @hidden */
  78325. _lastPickedControl: Control;
  78326. /** @hidden */
  78327. _lastControlOver: {
  78328. [pointerId: number]: Control;
  78329. };
  78330. /** @hidden */
  78331. _lastControlDown: {
  78332. [pointerId: number]: Control;
  78333. };
  78334. /** @hidden */
  78335. _capturingControl: {
  78336. [pointerId: number]: Control;
  78337. };
  78338. /** @hidden */
  78339. _shouldBlockPointer: boolean;
  78340. /** @hidden */
  78341. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78342. /** @hidden */
  78343. _linkedControls: Control[];
  78344. private _isFullscreen;
  78345. private _fullscreenViewport;
  78346. private _idealWidth;
  78347. private _idealHeight;
  78348. private _useSmallestIdeal;
  78349. private _renderAtIdealSize;
  78350. private _focusedControl;
  78351. private _blockNextFocusCheck;
  78352. private _renderScale;
  78353. private _rootElement;
  78354. private _cursorChanged;
  78355. private _defaultMousePointerId;
  78356. /** @hidden */
  78357. _numLayoutCalls: number;
  78358. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78359. get numLayoutCalls(): number;
  78360. /** @hidden */
  78361. _numRenderCalls: number;
  78362. /** Gets the number of render calls made the last time the ADT has been rendered */
  78363. get numRenderCalls(): number;
  78364. /**
  78365. * Define type to string to ensure compatibility across browsers
  78366. * Safari doesn't support DataTransfer constructor
  78367. */
  78368. private _clipboardData;
  78369. /**
  78370. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78371. */
  78372. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78373. /**
  78374. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78375. */
  78376. onControlPickedObservable: BABYLON.Observable<Control>;
  78377. /**
  78378. * BABYLON.Observable event triggered before layout is evaluated
  78379. */
  78380. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78381. /**
  78382. * BABYLON.Observable event triggered after the layout was evaluated
  78383. */
  78384. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78385. /**
  78386. * BABYLON.Observable event triggered before the texture is rendered
  78387. */
  78388. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78389. /**
  78390. * BABYLON.Observable event triggered after the texture was rendered
  78391. */
  78392. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78393. /**
  78394. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78395. */
  78396. premulAlpha: boolean;
  78397. /**
  78398. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78399. */
  78400. applyYInversionOnUpdate: boolean;
  78401. /**
  78402. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78403. * Useful when you want more antialiasing
  78404. */
  78405. get renderScale(): number;
  78406. set renderScale(value: number);
  78407. /** Gets or sets the background color */
  78408. get background(): string;
  78409. set background(value: string);
  78410. /**
  78411. * Gets or sets the ideal width used to design controls.
  78412. * The GUI will then rescale everything accordingly
  78413. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78414. */
  78415. get idealWidth(): number;
  78416. set idealWidth(value: number);
  78417. /**
  78418. * Gets or sets the ideal height used to design controls.
  78419. * The GUI will then rescale everything accordingly
  78420. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78421. */
  78422. get idealHeight(): number;
  78423. set idealHeight(value: number);
  78424. /**
  78425. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78426. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78427. */
  78428. get useSmallestIdeal(): boolean;
  78429. set useSmallestIdeal(value: boolean);
  78430. /**
  78431. * Gets or sets a boolean indicating if adaptive scaling must be used
  78432. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78433. */
  78434. get renderAtIdealSize(): boolean;
  78435. set renderAtIdealSize(value: boolean);
  78436. /**
  78437. * Gets the ratio used when in "ideal mode"
  78438. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78439. * */
  78440. get idealRatio(): number;
  78441. /**
  78442. * Gets the underlying layer used to render the texture when in fullscreen mode
  78443. */
  78444. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78445. /**
  78446. * Gets the root container control
  78447. */
  78448. get rootContainer(): Container;
  78449. /**
  78450. * Returns an array containing the root container.
  78451. * This is mostly used to let the Inspector introspects the ADT
  78452. * @returns an array containing the rootContainer
  78453. */
  78454. getChildren(): Array<Container>;
  78455. /**
  78456. * Will return all controls that are inside this texture
  78457. * @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
  78458. * @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
  78459. * @return all child controls
  78460. */
  78461. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78462. /**
  78463. * Gets or sets the current focused control
  78464. */
  78465. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78466. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78467. /**
  78468. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78469. */
  78470. get isForeground(): boolean;
  78471. set isForeground(value: boolean);
  78472. /**
  78473. * Gets or set information about clipboardData
  78474. */
  78475. get clipboardData(): string;
  78476. set clipboardData(value: string);
  78477. /**
  78478. * Creates a new AdvancedDynamicTexture
  78479. * @param name defines the name of the texture
  78480. * @param width defines the width of the texture
  78481. * @param height defines the height of the texture
  78482. * @param scene defines the hosting scene
  78483. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78484. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78485. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78486. */
  78487. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78488. /**
  78489. * Get the current class name of the texture useful for serialization or dynamic coding.
  78490. * @returns "AdvancedDynamicTexture"
  78491. */
  78492. getClassName(): string;
  78493. /**
  78494. * Function used to execute a function on all controls
  78495. * @param func defines the function to execute
  78496. * @param container defines the container where controls belong. If null the root container will be used
  78497. */
  78498. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78499. private _useInvalidateRectOptimization;
  78500. /**
  78501. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78502. */
  78503. get useInvalidateRectOptimization(): boolean;
  78504. set useInvalidateRectOptimization(value: boolean);
  78505. private _invalidatedRectangle;
  78506. /**
  78507. * Invalidates a rectangle area on the gui texture
  78508. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78509. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78510. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78511. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78512. */
  78513. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78514. /**
  78515. * Marks the texture as dirty forcing a complete update
  78516. */
  78517. markAsDirty(): void;
  78518. /**
  78519. * Helper function used to create a new style
  78520. * @returns a new style
  78521. * @see https://doc.babylonjs.com/how_to/gui#styles
  78522. */
  78523. createStyle(): Style;
  78524. /**
  78525. * Adds a new control to the root container
  78526. * @param control defines the control to add
  78527. * @returns the current texture
  78528. */
  78529. addControl(control: Control): AdvancedDynamicTexture;
  78530. /**
  78531. * Removes a control from the root container
  78532. * @param control defines the control to remove
  78533. * @returns the current texture
  78534. */
  78535. removeControl(control: Control): AdvancedDynamicTexture;
  78536. /**
  78537. * Release all resources
  78538. */
  78539. dispose(): void;
  78540. private _onResize;
  78541. /** @hidden */
  78542. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78543. /**
  78544. * Get screen coordinates for a vector3
  78545. * @param position defines the position to project
  78546. * @param worldMatrix defines the world matrix to use
  78547. * @returns the projected position
  78548. */
  78549. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78550. /**
  78551. * Get screen coordinates for a vector3
  78552. * @param position defines the position to project
  78553. * @param worldMatrix defines the world matrix to use
  78554. * @returns the projected position with Z
  78555. */
  78556. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78557. private _checkUpdate;
  78558. private _clearMeasure;
  78559. private _render;
  78560. /** @hidden */
  78561. _changeCursor(cursor: string): void;
  78562. /** @hidden */
  78563. _registerLastControlDown(control: Control, pointerId: number): void;
  78564. private _doPicking;
  78565. /** @hidden */
  78566. _cleanControlAfterRemovalFromList(list: {
  78567. [pointerId: number]: Control;
  78568. }, control: Control): void;
  78569. /** @hidden */
  78570. _cleanControlAfterRemoval(control: Control): void;
  78571. /** Attach to all scene events required to support pointer events */
  78572. attach(): void;
  78573. /** @hidden */
  78574. private onClipboardCopy;
  78575. /** @hidden */
  78576. private onClipboardCut;
  78577. /** @hidden */
  78578. private onClipboardPaste;
  78579. /**
  78580. * Register the clipboard Events onto the canvas
  78581. */
  78582. registerClipboardEvents(): void;
  78583. /**
  78584. * Unregister the clipboard Events from the canvas
  78585. */
  78586. unRegisterClipboardEvents(): void;
  78587. /**
  78588. * Connect the texture to a hosting mesh to enable interactions
  78589. * @param mesh defines the mesh to attach to
  78590. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78591. */
  78592. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78593. /**
  78594. * Move the focus to a specific control
  78595. * @param control defines the control which will receive the focus
  78596. */
  78597. moveFocusToControl(control: IFocusableControl): void;
  78598. private _manageFocus;
  78599. private _attachToOnPointerOut;
  78600. private _attachToOnBlur;
  78601. /**
  78602. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78603. * @param mesh defines the mesh which will receive the texture
  78604. * @param width defines the texture width (1024 by default)
  78605. * @param height defines the texture height (1024 by default)
  78606. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78607. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78608. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78609. * @returns a new AdvancedDynamicTexture
  78610. */
  78611. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78612. /**
  78613. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  78614. * @param mesh defines the mesh which will receive the texture
  78615. * @param width defines the texture width (1024 by default)
  78616. * @param height defines the texture height (1024 by default)
  78617. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78618. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78619. * @returns a new AdvancedDynamicTexture
  78620. */
  78621. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78622. /**
  78623. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78624. * In this mode the texture will rely on a layer for its rendering.
  78625. * This allows it to be treated like any other layer.
  78626. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78627. * LayerMask is set through advancedTexture.layer.layerMask
  78628. * @param name defines name for the texture
  78629. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78630. * @param scene defines the hsoting scene
  78631. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78632. * @returns a new AdvancedDynamicTexture
  78633. */
  78634. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78635. }
  78636. }
  78637. declare module BABYLON.GUI {
  78638. /**
  78639. * Root class used for all 2D controls
  78640. * @see https://doc.babylonjs.com/how_to/gui#controls
  78641. */
  78642. export class Control {
  78643. /** defines the name of the control */
  78644. name?: string | undefined;
  78645. /**
  78646. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78647. */
  78648. static AllowAlphaInheritance: boolean;
  78649. private _alpha;
  78650. private _alphaSet;
  78651. private _zIndex;
  78652. /** @hidden */
  78653. _host: AdvancedDynamicTexture;
  78654. /** Gets or sets the control parent */
  78655. parent: BABYLON.Nullable<Container>;
  78656. /** @hidden */
  78657. _currentMeasure: Measure;
  78658. private _fontFamily;
  78659. private _fontStyle;
  78660. private _fontWeight;
  78661. private _fontSize;
  78662. private _font;
  78663. /** @hidden */
  78664. _width: ValueAndUnit;
  78665. /** @hidden */
  78666. _height: ValueAndUnit;
  78667. /** @hidden */
  78668. protected _fontOffset: {
  78669. ascent: number;
  78670. height: number;
  78671. descent: number;
  78672. };
  78673. private _color;
  78674. private _style;
  78675. private _styleObserver;
  78676. /** @hidden */
  78677. protected _horizontalAlignment: number;
  78678. /** @hidden */
  78679. protected _verticalAlignment: number;
  78680. /** @hidden */
  78681. protected _isDirty: boolean;
  78682. /** @hidden */
  78683. protected _wasDirty: boolean;
  78684. /** @hidden */
  78685. _tempParentMeasure: Measure;
  78686. /** @hidden */
  78687. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78688. /** @hidden */
  78689. protected _cachedParentMeasure: Measure;
  78690. private _paddingLeft;
  78691. private _paddingRight;
  78692. private _paddingTop;
  78693. private _paddingBottom;
  78694. /** @hidden */
  78695. _left: ValueAndUnit;
  78696. /** @hidden */
  78697. _top: ValueAndUnit;
  78698. private _scaleX;
  78699. private _scaleY;
  78700. private _rotation;
  78701. private _transformCenterX;
  78702. private _transformCenterY;
  78703. /** @hidden */
  78704. _transformMatrix: Matrix2D;
  78705. /** @hidden */
  78706. protected _invertTransformMatrix: Matrix2D;
  78707. /** @hidden */
  78708. protected _transformedPosition: BABYLON.Vector2;
  78709. private _isMatrixDirty;
  78710. private _cachedOffsetX;
  78711. private _cachedOffsetY;
  78712. private _isVisible;
  78713. private _isHighlighted;
  78714. /** @hidden */
  78715. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78716. private _fontSet;
  78717. private _dummyVector2;
  78718. private _downCount;
  78719. private _enterCount;
  78720. private _doNotRender;
  78721. private _downPointerIds;
  78722. protected _isEnabled: boolean;
  78723. protected _disabledColor: string;
  78724. protected _disabledColorItem: string;
  78725. /** @hidden */
  78726. protected _rebuildLayout: boolean;
  78727. /** @hidden */
  78728. _customData: any;
  78729. /** @hidden */
  78730. _isClipped: boolean;
  78731. /** @hidden */
  78732. _automaticSize: boolean;
  78733. /** @hidden */
  78734. _tag: any;
  78735. /**
  78736. * 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
  78737. */
  78738. uniqueId: number;
  78739. /**
  78740. * Gets or sets an object used to store user defined information for the node
  78741. */
  78742. metadata: any;
  78743. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78744. isHitTestVisible: boolean;
  78745. /** Gets or sets a boolean indicating if the control can block pointer events */
  78746. isPointerBlocker: boolean;
  78747. /** Gets or sets a boolean indicating if the control can be focusable */
  78748. isFocusInvisible: boolean;
  78749. /**
  78750. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78751. * 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
  78752. */
  78753. clipChildren: boolean;
  78754. /**
  78755. * Gets or sets a boolean indicating that control content must be clipped
  78756. * 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
  78757. */
  78758. clipContent: boolean;
  78759. /**
  78760. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78761. */
  78762. useBitmapCache: boolean;
  78763. private _cacheData;
  78764. private _shadowOffsetX;
  78765. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78766. get shadowOffsetX(): number;
  78767. set shadowOffsetX(value: number);
  78768. private _shadowOffsetY;
  78769. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78770. get shadowOffsetY(): number;
  78771. set shadowOffsetY(value: number);
  78772. private _shadowBlur;
  78773. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78774. get shadowBlur(): number;
  78775. set shadowBlur(value: number);
  78776. private _shadowColor;
  78777. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78778. get shadowColor(): string;
  78779. set shadowColor(value: string);
  78780. /** Gets or sets the cursor to use when the control is hovered */
  78781. hoverCursor: string;
  78782. /** @hidden */
  78783. protected _linkOffsetX: ValueAndUnit;
  78784. /** @hidden */
  78785. protected _linkOffsetY: ValueAndUnit;
  78786. /** Gets the control type name */
  78787. get typeName(): string;
  78788. /**
  78789. * Get the current class name of the control.
  78790. * @returns current class name
  78791. */
  78792. getClassName(): string;
  78793. /**
  78794. * An event triggered when pointer wheel is scrolled
  78795. */
  78796. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78797. /**
  78798. * An event triggered when the pointer move over the control.
  78799. */
  78800. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78801. /**
  78802. * An event triggered when the pointer move out of the control.
  78803. */
  78804. onPointerOutObservable: BABYLON.Observable<Control>;
  78805. /**
  78806. * An event triggered when the pointer taps the control
  78807. */
  78808. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78809. /**
  78810. * An event triggered when pointer up
  78811. */
  78812. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78813. /**
  78814. * An event triggered when a control is clicked on
  78815. */
  78816. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78817. /**
  78818. * An event triggered when pointer enters the control
  78819. */
  78820. onPointerEnterObservable: BABYLON.Observable<Control>;
  78821. /**
  78822. * An event triggered when the control is marked as dirty
  78823. */
  78824. onDirtyObservable: BABYLON.Observable<Control>;
  78825. /**
  78826. * An event triggered before drawing the control
  78827. */
  78828. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78829. /**
  78830. * An event triggered after the control was drawn
  78831. */
  78832. onAfterDrawObservable: BABYLON.Observable<Control>;
  78833. /**
  78834. * An event triggered when the control has been disposed
  78835. */
  78836. onDisposeObservable: BABYLON.Observable<Control>;
  78837. /**
  78838. * Get the hosting AdvancedDynamicTexture
  78839. */
  78840. get host(): AdvancedDynamicTexture;
  78841. /** Gets or set information about font offsets (used to render and align text) */
  78842. get fontOffset(): {
  78843. ascent: number;
  78844. height: number;
  78845. descent: number;
  78846. };
  78847. set fontOffset(offset: {
  78848. ascent: number;
  78849. height: number;
  78850. descent: number;
  78851. });
  78852. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78853. get alpha(): number;
  78854. set alpha(value: number);
  78855. /**
  78856. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78857. */
  78858. get isHighlighted(): boolean;
  78859. set isHighlighted(value: boolean);
  78860. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78861. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78862. */
  78863. get scaleX(): number;
  78864. set scaleX(value: number);
  78865. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78866. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78867. */
  78868. get scaleY(): number;
  78869. set scaleY(value: number);
  78870. /** Gets or sets the rotation angle (0 by default)
  78871. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78872. */
  78873. get rotation(): number;
  78874. set rotation(value: number);
  78875. /** Gets or sets the transformation center on Y axis (0 by default)
  78876. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78877. */
  78878. get transformCenterY(): number;
  78879. set transformCenterY(value: number);
  78880. /** Gets or sets the transformation center on X axis (0 by default)
  78881. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78882. */
  78883. get transformCenterX(): number;
  78884. set transformCenterX(value: number);
  78885. /**
  78886. * Gets or sets the horizontal alignment
  78887. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78888. */
  78889. get horizontalAlignment(): number;
  78890. set horizontalAlignment(value: number);
  78891. /**
  78892. * Gets or sets the vertical alignment
  78893. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78894. */
  78895. get verticalAlignment(): number;
  78896. set verticalAlignment(value: number);
  78897. /**
  78898. * Gets or sets a fixed ratio for this control.
  78899. * When different from 0, the ratio is used to compute the "second" dimension.
  78900. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78901. * second dimension is computed as first dimension * fixedRatio
  78902. */
  78903. fixedRatio: number;
  78904. private _fixedRatioMasterIsWidth;
  78905. /**
  78906. * Gets or sets control width
  78907. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78908. */
  78909. get width(): string | number;
  78910. set width(value: string | number);
  78911. /**
  78912. * Gets or sets the control width in pixel
  78913. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78914. */
  78915. get widthInPixels(): number;
  78916. set widthInPixels(value: number);
  78917. /**
  78918. * Gets or sets control height
  78919. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78920. */
  78921. get height(): string | number;
  78922. set height(value: string | number);
  78923. /**
  78924. * Gets or sets control height in pixel
  78925. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78926. */
  78927. get heightInPixels(): number;
  78928. set heightInPixels(value: number);
  78929. /** Gets or set font family */
  78930. get fontFamily(): string;
  78931. set fontFamily(value: string);
  78932. /** Gets or sets font style */
  78933. get fontStyle(): string;
  78934. set fontStyle(value: string);
  78935. /** Gets or sets font weight */
  78936. get fontWeight(): string;
  78937. set fontWeight(value: string);
  78938. /**
  78939. * Gets or sets style
  78940. * @see https://doc.babylonjs.com/how_to/gui#styles
  78941. */
  78942. get style(): BABYLON.Nullable<Style>;
  78943. set style(value: BABYLON.Nullable<Style>);
  78944. /** @hidden */
  78945. get _isFontSizeInPercentage(): boolean;
  78946. /** Gets or sets font size in pixels */
  78947. get fontSizeInPixels(): number;
  78948. set fontSizeInPixels(value: number);
  78949. /** Gets or sets font size */
  78950. get fontSize(): string | number;
  78951. set fontSize(value: string | number);
  78952. /** Gets or sets foreground color */
  78953. get color(): string;
  78954. set color(value: string);
  78955. /** Gets or sets z index which is used to reorder controls on the z axis */
  78956. get zIndex(): number;
  78957. set zIndex(value: number);
  78958. /** Gets or sets a boolean indicating if the control can be rendered */
  78959. get notRenderable(): boolean;
  78960. set notRenderable(value: boolean);
  78961. /** Gets or sets a boolean indicating if the control is visible */
  78962. get isVisible(): boolean;
  78963. set isVisible(value: boolean);
  78964. /** Gets a boolean indicating that the control needs to update its rendering */
  78965. get isDirty(): boolean;
  78966. /**
  78967. * Gets the current linked mesh (or null if none)
  78968. */
  78969. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78970. /**
  78971. * Gets or sets a value indicating the padding to use on the left of the control
  78972. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78973. */
  78974. get paddingLeft(): string | number;
  78975. set paddingLeft(value: string | number);
  78976. /**
  78977. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78978. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78979. */
  78980. get paddingLeftInPixels(): number;
  78981. set paddingLeftInPixels(value: number);
  78982. /**
  78983. * Gets or sets a value indicating the padding to use on the right of the control
  78984. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78985. */
  78986. get paddingRight(): string | number;
  78987. set paddingRight(value: string | number);
  78988. /**
  78989. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78990. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78991. */
  78992. get paddingRightInPixels(): number;
  78993. set paddingRightInPixels(value: number);
  78994. /**
  78995. * Gets or sets a value indicating the padding to use on the top of the control
  78996. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78997. */
  78998. get paddingTop(): string | number;
  78999. set paddingTop(value: string | number);
  79000. /**
  79001. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  79002. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79003. */
  79004. get paddingTopInPixels(): number;
  79005. set paddingTopInPixels(value: number);
  79006. /**
  79007. * Gets or sets a value indicating the padding to use on the bottom of the control
  79008. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79009. */
  79010. get paddingBottom(): string | number;
  79011. set paddingBottom(value: string | number);
  79012. /**
  79013. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  79014. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79015. */
  79016. get paddingBottomInPixels(): number;
  79017. set paddingBottomInPixels(value: number);
  79018. /**
  79019. * Gets or sets a value indicating the left coordinate of the control
  79020. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79021. */
  79022. get left(): string | number;
  79023. set left(value: string | number);
  79024. /**
  79025. * Gets or sets a value indicating the left coordinate in pixels of the control
  79026. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79027. */
  79028. get leftInPixels(): number;
  79029. set leftInPixels(value: number);
  79030. /**
  79031. * Gets or sets a value indicating the top coordinate of the control
  79032. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79033. */
  79034. get top(): string | number;
  79035. set top(value: string | number);
  79036. /**
  79037. * Gets or sets a value indicating the top coordinate in pixels of the control
  79038. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79039. */
  79040. get topInPixels(): number;
  79041. set topInPixels(value: number);
  79042. /**
  79043. * Gets or sets a value indicating the offset on X axis to the linked mesh
  79044. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79045. */
  79046. get linkOffsetX(): string | number;
  79047. set linkOffsetX(value: string | number);
  79048. /**
  79049. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  79050. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79051. */
  79052. get linkOffsetXInPixels(): number;
  79053. set linkOffsetXInPixels(value: number);
  79054. /**
  79055. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79056. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79057. */
  79058. get linkOffsetY(): string | number;
  79059. set linkOffsetY(value: string | number);
  79060. /**
  79061. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79062. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79063. */
  79064. get linkOffsetYInPixels(): number;
  79065. set linkOffsetYInPixels(value: number);
  79066. /** Gets the center coordinate on X axis */
  79067. get centerX(): number;
  79068. /** Gets the center coordinate on Y axis */
  79069. get centerY(): number;
  79070. /** Gets or sets if control is Enabled*/
  79071. get isEnabled(): boolean;
  79072. set isEnabled(value: boolean);
  79073. /** Gets or sets background color of control if it's disabled*/
  79074. get disabledColor(): string;
  79075. set disabledColor(value: string);
  79076. /** Gets or sets front color of control if it's disabled*/
  79077. get disabledColorItem(): string;
  79078. set disabledColorItem(value: string);
  79079. /**
  79080. * Creates a new control
  79081. * @param name defines the name of the control
  79082. */
  79083. constructor(
  79084. /** defines the name of the control */
  79085. name?: string | undefined);
  79086. /** @hidden */
  79087. protected _getTypeName(): string;
  79088. /**
  79089. * Gets the first ascendant in the hierarchy of the given type
  79090. * @param className defines the required type
  79091. * @returns the ascendant or null if not found
  79092. */
  79093. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79094. /** @hidden */
  79095. _resetFontCache(): void;
  79096. /**
  79097. * Determines if a container is an ascendant of the current control
  79098. * @param container defines the container to look for
  79099. * @returns true if the container is one of the ascendant of the control
  79100. */
  79101. isAscendant(container: Control): boolean;
  79102. /**
  79103. * Gets coordinates in local control space
  79104. * @param globalCoordinates defines the coordinates to transform
  79105. * @returns the new coordinates in local space
  79106. */
  79107. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79108. /**
  79109. * Gets coordinates in local control space
  79110. * @param globalCoordinates defines the coordinates to transform
  79111. * @param result defines the target vector2 where to store the result
  79112. * @returns the current control
  79113. */
  79114. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79115. /**
  79116. * Gets coordinates in parent local control space
  79117. * @param globalCoordinates defines the coordinates to transform
  79118. * @returns the new coordinates in parent local space
  79119. */
  79120. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79121. /**
  79122. * Move the current control to a vector3 position projected onto the screen.
  79123. * @param position defines the target position
  79124. * @param scene defines the hosting scene
  79125. */
  79126. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79127. /**
  79128. * Will store all controls that have this control as ascendant in a given array
  79129. * @param results defines the array where to store the descendants
  79130. * @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
  79131. * @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
  79132. */
  79133. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79134. /**
  79135. * Will return all controls that have this control as ascendant
  79136. * @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
  79137. * @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
  79138. * @return all child controls
  79139. */
  79140. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79141. /**
  79142. * Link current control with a target mesh
  79143. * @param mesh defines the mesh to link with
  79144. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79145. */
  79146. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79147. /** @hidden */
  79148. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79149. /** @hidden */
  79150. _offsetLeft(offset: number): void;
  79151. /** @hidden */
  79152. _offsetTop(offset: number): void;
  79153. /** @hidden */
  79154. _markMatrixAsDirty(): void;
  79155. /** @hidden */
  79156. _flagDescendantsAsMatrixDirty(): void;
  79157. /** @hidden */
  79158. _intersectsRect(rect: Measure): boolean;
  79159. /** @hidden */
  79160. protected invalidateRect(): void;
  79161. /** @hidden */
  79162. _markAsDirty(force?: boolean): void;
  79163. /** @hidden */
  79164. _markAllAsDirty(): void;
  79165. /** @hidden */
  79166. _link(host: AdvancedDynamicTexture): void;
  79167. /** @hidden */
  79168. protected _transform(context?: CanvasRenderingContext2D): void;
  79169. /** @hidden */
  79170. _renderHighlight(context: CanvasRenderingContext2D): void;
  79171. /** @hidden */
  79172. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79173. /** @hidden */
  79174. protected _applyStates(context: CanvasRenderingContext2D): void;
  79175. /** @hidden */
  79176. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79177. /** @hidden */
  79178. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79179. protected _evaluateClippingState(parentMeasure: Measure): void;
  79180. /** @hidden */
  79181. _measure(): void;
  79182. /** @hidden */
  79183. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79184. /** @hidden */
  79185. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79186. /** @hidden */
  79187. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79188. /** @hidden */
  79189. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79190. private static _ClipMeasure;
  79191. private _tmpMeasureA;
  79192. private _clip;
  79193. /** @hidden */
  79194. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79195. /** @hidden */
  79196. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79197. /**
  79198. * Tests if a given coordinates belong to the current control
  79199. * @param x defines x coordinate to test
  79200. * @param y defines y coordinate to test
  79201. * @returns true if the coordinates are inside the control
  79202. */
  79203. contains(x: number, y: number): boolean;
  79204. /** @hidden */
  79205. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79206. /** @hidden */
  79207. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79208. /** @hidden */
  79209. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79210. /** @hidden */
  79211. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79212. /** @hidden */
  79213. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79214. /** @hidden */
  79215. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79216. /** @hidden */
  79217. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79218. /** @hidden */
  79219. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79220. /** @hidden */
  79221. _onCanvasBlur(): void;
  79222. /** @hidden */
  79223. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79224. private _prepareFont;
  79225. /** Releases associated resources */
  79226. dispose(): void;
  79227. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79228. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79229. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79230. private static _VERTICAL_ALIGNMENT_TOP;
  79231. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79232. private static _VERTICAL_ALIGNMENT_CENTER;
  79233. /** HORIZONTAL_ALIGNMENT_LEFT */
  79234. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79235. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79236. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79237. /** HORIZONTAL_ALIGNMENT_CENTER */
  79238. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79239. /** VERTICAL_ALIGNMENT_TOP */
  79240. static get VERTICAL_ALIGNMENT_TOP(): number;
  79241. /** VERTICAL_ALIGNMENT_BOTTOM */
  79242. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79243. /** VERTICAL_ALIGNMENT_CENTER */
  79244. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79245. private static _FontHeightSizes;
  79246. /** @hidden */
  79247. static _GetFontOffset(font: string): {
  79248. ascent: number;
  79249. height: number;
  79250. descent: number;
  79251. };
  79252. /**
  79253. * Creates a stack panel that can be used to render headers
  79254. * @param control defines the control to associate with the header
  79255. * @param text defines the text of the header
  79256. * @param size defines the size of the header
  79257. * @param options defines options used to configure the header
  79258. * @returns a new StackPanel
  79259. * @ignore
  79260. * @hidden
  79261. */
  79262. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79263. isHorizontal: boolean;
  79264. controlFirst: boolean;
  79265. }) => any;
  79266. /** @hidden */
  79267. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79268. }
  79269. }
  79270. declare module BABYLON.GUI {
  79271. /**
  79272. * Root class for 2D containers
  79273. * @see https://doc.babylonjs.com/how_to/gui#containers
  79274. */
  79275. export class Container extends Control {
  79276. name?: string | undefined;
  79277. /** @hidden */
  79278. _children: Control[];
  79279. /** @hidden */
  79280. protected _measureForChildren: Measure;
  79281. /** @hidden */
  79282. protected _background: string;
  79283. /** @hidden */
  79284. protected _adaptWidthToChildren: boolean;
  79285. /** @hidden */
  79286. protected _adaptHeightToChildren: boolean;
  79287. /**
  79288. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79289. */
  79290. logLayoutCycleErrors: boolean;
  79291. /**
  79292. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79293. */
  79294. maxLayoutCycle: number;
  79295. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79296. get adaptHeightToChildren(): boolean;
  79297. set adaptHeightToChildren(value: boolean);
  79298. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79299. get adaptWidthToChildren(): boolean;
  79300. set adaptWidthToChildren(value: boolean);
  79301. /** Gets or sets background color */
  79302. get background(): string;
  79303. set background(value: string);
  79304. /** Gets the list of children */
  79305. get children(): Control[];
  79306. /**
  79307. * Creates a new Container
  79308. * @param name defines the name of the container
  79309. */
  79310. constructor(name?: string | undefined);
  79311. protected _getTypeName(): string;
  79312. _flagDescendantsAsMatrixDirty(): void;
  79313. /**
  79314. * Gets a child using its name
  79315. * @param name defines the child name to look for
  79316. * @returns the child control if found
  79317. */
  79318. getChildByName(name: string): BABYLON.Nullable<Control>;
  79319. /**
  79320. * Gets a child using its type and its name
  79321. * @param name defines the child name to look for
  79322. * @param type defines the child type to look for
  79323. * @returns the child control if found
  79324. */
  79325. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79326. /**
  79327. * Search for a specific control in children
  79328. * @param control defines the control to look for
  79329. * @returns true if the control is in child list
  79330. */
  79331. containsControl(control: Control): boolean;
  79332. /**
  79333. * Adds a new control to the current container
  79334. * @param control defines the control to add
  79335. * @returns the current container
  79336. */
  79337. addControl(control: BABYLON.Nullable<Control>): Container;
  79338. /**
  79339. * Removes all controls from the current container
  79340. * @returns the current container
  79341. */
  79342. clearControls(): Container;
  79343. /**
  79344. * Removes a control from the current container
  79345. * @param control defines the control to remove
  79346. * @returns the current container
  79347. */
  79348. removeControl(control: Control): Container;
  79349. /** @hidden */
  79350. _reOrderControl(control: Control): void;
  79351. /** @hidden */
  79352. _offsetLeft(offset: number): void;
  79353. /** @hidden */
  79354. _offsetTop(offset: number): void;
  79355. /** @hidden */
  79356. _markAllAsDirty(): void;
  79357. /** @hidden */
  79358. protected _localDraw(context: CanvasRenderingContext2D): void;
  79359. /** @hidden */
  79360. _link(host: AdvancedDynamicTexture): void;
  79361. /** @hidden */
  79362. protected _beforeLayout(): void;
  79363. /** @hidden */
  79364. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79365. /** @hidden */
  79366. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79367. protected _postMeasure(): void;
  79368. /** @hidden */
  79369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79370. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79371. /** @hidden */
  79372. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79373. /** @hidden */
  79374. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79375. /** Releases associated resources */
  79376. dispose(): void;
  79377. }
  79378. }
  79379. declare module BABYLON.GUI {
  79380. /** Class used to create rectangle container */
  79381. export class Rectangle extends Container {
  79382. name?: string | undefined;
  79383. private _thickness;
  79384. private _cornerRadius;
  79385. /** Gets or sets border thickness */
  79386. get thickness(): number;
  79387. set thickness(value: number);
  79388. /** Gets or sets the corner radius angle */
  79389. get cornerRadius(): number;
  79390. set cornerRadius(value: number);
  79391. /**
  79392. * Creates a new Rectangle
  79393. * @param name defines the control name
  79394. */
  79395. constructor(name?: string | undefined);
  79396. protected _getTypeName(): string;
  79397. protected _localDraw(context: CanvasRenderingContext2D): void;
  79398. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79399. private _drawRoundedRect;
  79400. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79401. }
  79402. }
  79403. declare module BABYLON.GUI {
  79404. /**
  79405. * Enum that determines the text-wrapping mode to use.
  79406. */
  79407. export enum TextWrapping {
  79408. /**
  79409. * Clip the text when it's larger than Control.width; this is the default mode.
  79410. */
  79411. Clip = 0,
  79412. /**
  79413. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79414. */
  79415. WordWrap = 1,
  79416. /**
  79417. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79418. */
  79419. Ellipsis = 2
  79420. }
  79421. /**
  79422. * Class used to create text block control
  79423. */
  79424. export class TextBlock extends Control {
  79425. /**
  79426. * Defines the name of the control
  79427. */
  79428. name?: string | undefined;
  79429. private _text;
  79430. private _textWrapping;
  79431. private _textHorizontalAlignment;
  79432. private _textVerticalAlignment;
  79433. private _lines;
  79434. private _resizeToFit;
  79435. private _lineSpacing;
  79436. private _outlineWidth;
  79437. private _outlineColor;
  79438. private _underline;
  79439. private _lineThrough;
  79440. /**
  79441. * An event triggered after the text is changed
  79442. */
  79443. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79444. /**
  79445. * An event triggered after the text was broken up into lines
  79446. */
  79447. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79448. /**
  79449. * Function used to split a string into words. By default, a string is split at each space character found
  79450. */
  79451. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79452. /**
  79453. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79454. */
  79455. get lines(): any[];
  79456. /**
  79457. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79458. */
  79459. get resizeToFit(): boolean;
  79460. /**
  79461. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79462. */
  79463. set resizeToFit(value: boolean);
  79464. /**
  79465. * Gets or sets a boolean indicating if text must be wrapped
  79466. */
  79467. get textWrapping(): TextWrapping | boolean;
  79468. /**
  79469. * Gets or sets a boolean indicating if text must be wrapped
  79470. */
  79471. set textWrapping(value: TextWrapping | boolean);
  79472. /**
  79473. * Gets or sets text to display
  79474. */
  79475. get text(): string;
  79476. /**
  79477. * Gets or sets text to display
  79478. */
  79479. set text(value: string);
  79480. /**
  79481. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79482. */
  79483. get textHorizontalAlignment(): number;
  79484. /**
  79485. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79486. */
  79487. set textHorizontalAlignment(value: number);
  79488. /**
  79489. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79490. */
  79491. get textVerticalAlignment(): number;
  79492. /**
  79493. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79494. */
  79495. set textVerticalAlignment(value: number);
  79496. /**
  79497. * Gets or sets line spacing value
  79498. */
  79499. set lineSpacing(value: string | number);
  79500. /**
  79501. * Gets or sets line spacing value
  79502. */
  79503. get lineSpacing(): string | number;
  79504. /**
  79505. * Gets or sets outlineWidth of the text to display
  79506. */
  79507. get outlineWidth(): number;
  79508. /**
  79509. * Gets or sets outlineWidth of the text to display
  79510. */
  79511. set outlineWidth(value: number);
  79512. /**
  79513. * Gets or sets a boolean indicating that text must have underline
  79514. */
  79515. get underline(): boolean;
  79516. /**
  79517. * Gets or sets a boolean indicating that text must have underline
  79518. */
  79519. set underline(value: boolean);
  79520. /**
  79521. * Gets or sets an boolean indicating that text must be crossed out
  79522. */
  79523. get lineThrough(): boolean;
  79524. /**
  79525. * Gets or sets an boolean indicating that text must be crossed out
  79526. */
  79527. set lineThrough(value: boolean);
  79528. /**
  79529. * Gets or sets outlineColor of the text to display
  79530. */
  79531. get outlineColor(): string;
  79532. /**
  79533. * Gets or sets outlineColor of the text to display
  79534. */
  79535. set outlineColor(value: string);
  79536. /**
  79537. * Creates a new TextBlock object
  79538. * @param name defines the name of the control
  79539. * @param text defines the text to display (emptry string by default)
  79540. */
  79541. constructor(
  79542. /**
  79543. * Defines the name of the control
  79544. */
  79545. name?: string | undefined, text?: string);
  79546. protected _getTypeName(): string;
  79547. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79548. private _drawText;
  79549. /** @hidden */
  79550. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79551. protected _applyStates(context: CanvasRenderingContext2D): void;
  79552. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79553. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79554. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79555. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79556. protected _renderLines(context: CanvasRenderingContext2D): void;
  79557. /**
  79558. * Given a width constraint applied on the text block, find the expected height
  79559. * @returns expected height
  79560. */
  79561. computeExpectedHeight(): number;
  79562. dispose(): void;
  79563. }
  79564. }
  79565. declare module BABYLON.GUI {
  79566. /**
  79567. * Class used to create 2D images
  79568. */
  79569. export class Image extends Control {
  79570. name?: string | undefined;
  79571. private _workingCanvas;
  79572. private _domImage;
  79573. private _imageWidth;
  79574. private _imageHeight;
  79575. private _loaded;
  79576. private _stretch;
  79577. private _source;
  79578. private _autoScale;
  79579. private _sourceLeft;
  79580. private _sourceTop;
  79581. private _sourceWidth;
  79582. private _sourceHeight;
  79583. private _svgAttributesComputationCompleted;
  79584. private _isSVG;
  79585. private _cellWidth;
  79586. private _cellHeight;
  79587. private _cellId;
  79588. private _populateNinePatchSlicesFromImage;
  79589. private _sliceLeft;
  79590. private _sliceRight;
  79591. private _sliceTop;
  79592. private _sliceBottom;
  79593. private _detectPointerOnOpaqueOnly;
  79594. private _imageDataCache;
  79595. /**
  79596. * BABYLON.Observable notified when the content is loaded
  79597. */
  79598. onImageLoadedObservable: BABYLON.Observable<Image>;
  79599. /**
  79600. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79601. */
  79602. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79603. /**
  79604. * Gets a boolean indicating that the content is loaded
  79605. */
  79606. get isLoaded(): boolean;
  79607. /**
  79608. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79609. */
  79610. get populateNinePatchSlicesFromImage(): boolean;
  79611. set populateNinePatchSlicesFromImage(value: boolean);
  79612. /**
  79613. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79614. * Beware using this as this will comsume more memory as the image has to be stored twice
  79615. */
  79616. get detectPointerOnOpaqueOnly(): boolean;
  79617. set detectPointerOnOpaqueOnly(value: boolean);
  79618. /**
  79619. * Gets or sets the left value for slicing (9-patch)
  79620. */
  79621. get sliceLeft(): number;
  79622. set sliceLeft(value: number);
  79623. /**
  79624. * Gets or sets the right value for slicing (9-patch)
  79625. */
  79626. get sliceRight(): number;
  79627. set sliceRight(value: number);
  79628. /**
  79629. * Gets or sets the top value for slicing (9-patch)
  79630. */
  79631. get sliceTop(): number;
  79632. set sliceTop(value: number);
  79633. /**
  79634. * Gets or sets the bottom value for slicing (9-patch)
  79635. */
  79636. get sliceBottom(): number;
  79637. set sliceBottom(value: number);
  79638. /**
  79639. * Gets or sets the left coordinate in the source image
  79640. */
  79641. get sourceLeft(): number;
  79642. set sourceLeft(value: number);
  79643. /**
  79644. * Gets or sets the top coordinate in the source image
  79645. */
  79646. get sourceTop(): number;
  79647. set sourceTop(value: number);
  79648. /**
  79649. * Gets or sets the width to capture in the source image
  79650. */
  79651. get sourceWidth(): number;
  79652. set sourceWidth(value: number);
  79653. /**
  79654. * Gets or sets the height to capture in the source image
  79655. */
  79656. get sourceHeight(): number;
  79657. set sourceHeight(value: number);
  79658. /** Indicates if the format of the image is SVG */
  79659. get isSVG(): boolean;
  79660. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79661. get svgAttributesComputationCompleted(): boolean;
  79662. /**
  79663. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79664. * @see https://doc.babylonjs.com/how_to/gui#image
  79665. */
  79666. get autoScale(): boolean;
  79667. set autoScale(value: boolean);
  79668. /** Gets or sets the streching mode used by the image */
  79669. get stretch(): number;
  79670. set stretch(value: number);
  79671. /** @hidden */
  79672. _rotate90(n: number, preserveProperties?: boolean): Image;
  79673. private _handleRotationForSVGImage;
  79674. private _rotate90SourceProperties;
  79675. /**
  79676. * Gets or sets the internal DOM image used to render the control
  79677. */
  79678. set domImage(value: HTMLImageElement);
  79679. get domImage(): HTMLImageElement;
  79680. private _onImageLoaded;
  79681. private _extractNinePatchSliceDataFromImage;
  79682. /**
  79683. * Gets or sets image source url
  79684. */
  79685. set source(value: BABYLON.Nullable<string>);
  79686. /**
  79687. * Checks for svg document with icon id present
  79688. */
  79689. private _svgCheck;
  79690. /**
  79691. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79692. * given external svg file and icon id
  79693. */
  79694. private _getSVGAttribs;
  79695. /**
  79696. * Gets or sets the cell width to use when animation sheet is enabled
  79697. * @see https://doc.babylonjs.com/how_to/gui#image
  79698. */
  79699. get cellWidth(): number;
  79700. set cellWidth(value: number);
  79701. /**
  79702. * Gets or sets the cell height to use when animation sheet is enabled
  79703. * @see https://doc.babylonjs.com/how_to/gui#image
  79704. */
  79705. get cellHeight(): number;
  79706. set cellHeight(value: number);
  79707. /**
  79708. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79709. * @see https://doc.babylonjs.com/how_to/gui#image
  79710. */
  79711. get cellId(): number;
  79712. set cellId(value: number);
  79713. /**
  79714. * Creates a new Image
  79715. * @param name defines the control name
  79716. * @param url defines the image url
  79717. */
  79718. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79719. /**
  79720. * Tests if a given coordinates belong to the current control
  79721. * @param x defines x coordinate to test
  79722. * @param y defines y coordinate to test
  79723. * @returns true if the coordinates are inside the control
  79724. */
  79725. contains(x: number, y: number): boolean;
  79726. protected _getTypeName(): string;
  79727. /** Force the control to synchronize with its content */
  79728. synchronizeSizeWithContent(): void;
  79729. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79730. private _prepareWorkingCanvasForOpaqueDetection;
  79731. private _drawImage;
  79732. _draw(context: CanvasRenderingContext2D): void;
  79733. private _renderCornerPatch;
  79734. private _renderNinePatch;
  79735. dispose(): void;
  79736. /** STRETCH_NONE */
  79737. static readonly STRETCH_NONE: number;
  79738. /** STRETCH_FILL */
  79739. static readonly STRETCH_FILL: number;
  79740. /** STRETCH_UNIFORM */
  79741. static readonly STRETCH_UNIFORM: number;
  79742. /** STRETCH_EXTEND */
  79743. static readonly STRETCH_EXTEND: number;
  79744. /** NINE_PATCH */
  79745. static readonly STRETCH_NINE_PATCH: number;
  79746. }
  79747. }
  79748. declare module BABYLON.GUI {
  79749. /**
  79750. * Class used to create 2D buttons
  79751. */
  79752. export class Button extends Rectangle {
  79753. name?: string | undefined;
  79754. /**
  79755. * Function called to generate a pointer enter animation
  79756. */
  79757. pointerEnterAnimation: () => void;
  79758. /**
  79759. * Function called to generate a pointer out animation
  79760. */
  79761. pointerOutAnimation: () => void;
  79762. /**
  79763. * Function called to generate a pointer down animation
  79764. */
  79765. pointerDownAnimation: () => void;
  79766. /**
  79767. * Function called to generate a pointer up animation
  79768. */
  79769. pointerUpAnimation: () => void;
  79770. /**
  79771. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79772. */
  79773. delegatePickingToChildren: boolean;
  79774. private _image;
  79775. /**
  79776. * Returns the image part of the button (if any)
  79777. */
  79778. get image(): BABYLON.Nullable<Image>;
  79779. private _textBlock;
  79780. /**
  79781. * Returns the image part of the button (if any)
  79782. */
  79783. get textBlock(): BABYLON.Nullable<TextBlock>;
  79784. /**
  79785. * Creates a new Button
  79786. * @param name defines the name of the button
  79787. */
  79788. constructor(name?: string | undefined);
  79789. protected _getTypeName(): string;
  79790. /** @hidden */
  79791. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79792. /** @hidden */
  79793. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79794. /** @hidden */
  79795. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79796. /** @hidden */
  79797. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79798. /** @hidden */
  79799. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79800. /**
  79801. * Creates a new button made with an image and a text
  79802. * @param name defines the name of the button
  79803. * @param text defines the text of the button
  79804. * @param imageUrl defines the url of the image
  79805. * @returns a new Button
  79806. */
  79807. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79808. /**
  79809. * Creates a new button made with an image
  79810. * @param name defines the name of the button
  79811. * @param imageUrl defines the url of the image
  79812. * @returns a new Button
  79813. */
  79814. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79815. /**
  79816. * Creates a new button made with a text
  79817. * @param name defines the name of the button
  79818. * @param text defines the text of the button
  79819. * @returns a new Button
  79820. */
  79821. static CreateSimpleButton(name: string, text: string): Button;
  79822. /**
  79823. * Creates a new button made with an image and a centered text
  79824. * @param name defines the name of the button
  79825. * @param text defines the text of the button
  79826. * @param imageUrl defines the url of the image
  79827. * @returns a new Button
  79828. */
  79829. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79830. }
  79831. }
  79832. declare module BABYLON.GUI {
  79833. /**
  79834. * Class used to create a 2D stack panel container
  79835. */
  79836. export class StackPanel extends Container {
  79837. name?: string | undefined;
  79838. private _isVertical;
  79839. private _manualWidth;
  79840. private _manualHeight;
  79841. private _doNotTrackManualChanges;
  79842. /**
  79843. * Gets or sets a boolean indicating that layou warnings should be ignored
  79844. */
  79845. ignoreLayoutWarnings: boolean;
  79846. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79847. get isVertical(): boolean;
  79848. set isVertical(value: boolean);
  79849. /**
  79850. * Gets or sets panel width.
  79851. * This value should not be set when in horizontal mode as it will be computed automatically
  79852. */
  79853. set width(value: string | number);
  79854. get width(): string | number;
  79855. /**
  79856. * Gets or sets panel height.
  79857. * This value should not be set when in vertical mode as it will be computed automatically
  79858. */
  79859. set height(value: string | number);
  79860. get height(): string | number;
  79861. /**
  79862. * Creates a new StackPanel
  79863. * @param name defines control name
  79864. */
  79865. constructor(name?: string | undefined);
  79866. protected _getTypeName(): string;
  79867. /** @hidden */
  79868. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79869. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79870. protected _postMeasure(): void;
  79871. }
  79872. }
  79873. declare module BABYLON.GUI {
  79874. /**
  79875. * Class used to represent a 2D checkbox
  79876. */
  79877. export class Checkbox extends Control {
  79878. name?: string | undefined;
  79879. private _isChecked;
  79880. private _background;
  79881. private _checkSizeRatio;
  79882. private _thickness;
  79883. /** Gets or sets border thickness */
  79884. get thickness(): number;
  79885. set thickness(value: number);
  79886. /**
  79887. * BABYLON.Observable raised when isChecked property changes
  79888. */
  79889. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79890. /** Gets or sets a value indicating the ratio between overall size and check size */
  79891. get checkSizeRatio(): number;
  79892. set checkSizeRatio(value: number);
  79893. /** Gets or sets background color */
  79894. get background(): string;
  79895. set background(value: string);
  79896. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79897. get isChecked(): boolean;
  79898. set isChecked(value: boolean);
  79899. /**
  79900. * Creates a new CheckBox
  79901. * @param name defines the control name
  79902. */
  79903. constructor(name?: string | undefined);
  79904. protected _getTypeName(): string;
  79905. /** @hidden */
  79906. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79907. /** @hidden */
  79908. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79909. /**
  79910. * Utility function to easily create a checkbox with a header
  79911. * @param title defines the label to use for the header
  79912. * @param onValueChanged defines the callback to call when value changes
  79913. * @returns a StackPanel containing the checkbox and a textBlock
  79914. */
  79915. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79916. }
  79917. }
  79918. declare module BABYLON.GUI {
  79919. /**
  79920. * Class used to store key control properties
  79921. */
  79922. export class KeyPropertySet {
  79923. /** Width */
  79924. width?: string;
  79925. /** Height */
  79926. height?: string;
  79927. /** Left padding */
  79928. paddingLeft?: string;
  79929. /** Right padding */
  79930. paddingRight?: string;
  79931. /** Top padding */
  79932. paddingTop?: string;
  79933. /** Bottom padding */
  79934. paddingBottom?: string;
  79935. /** Foreground color */
  79936. color?: string;
  79937. /** Background color */
  79938. background?: string;
  79939. }
  79940. /**
  79941. * Class used to create virtual keyboard
  79942. */
  79943. export class VirtualKeyboard extends StackPanel {
  79944. /** BABYLON.Observable raised when a key is pressed */
  79945. onKeyPressObservable: BABYLON.Observable<string>;
  79946. /** Gets or sets default key button width */
  79947. defaultButtonWidth: string;
  79948. /** Gets or sets default key button height */
  79949. defaultButtonHeight: string;
  79950. /** Gets or sets default key button left padding */
  79951. defaultButtonPaddingLeft: string;
  79952. /** Gets or sets default key button right padding */
  79953. defaultButtonPaddingRight: string;
  79954. /** Gets or sets default key button top padding */
  79955. defaultButtonPaddingTop: string;
  79956. /** Gets or sets default key button bottom padding */
  79957. defaultButtonPaddingBottom: string;
  79958. /** Gets or sets default key button foreground color */
  79959. defaultButtonColor: string;
  79960. /** Gets or sets default key button background color */
  79961. defaultButtonBackground: string;
  79962. /** Gets or sets shift button foreground color */
  79963. shiftButtonColor: string;
  79964. /** Gets or sets shift button thickness*/
  79965. selectedShiftThickness: number;
  79966. /** Gets shift key state */
  79967. shiftState: number;
  79968. protected _getTypeName(): string;
  79969. private _createKey;
  79970. /**
  79971. * Adds a new row of keys
  79972. * @param keys defines the list of keys to add
  79973. * @param propertySets defines the associated property sets
  79974. */
  79975. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79976. /**
  79977. * Set the shift key to a specific state
  79978. * @param shiftState defines the new shift state
  79979. */
  79980. applyShiftState(shiftState: number): void;
  79981. private _currentlyConnectedInputText;
  79982. private _connectedInputTexts;
  79983. private _onKeyPressObserver;
  79984. /** Gets the input text control currently attached to the keyboard */
  79985. get connectedInputText(): BABYLON.Nullable<InputText>;
  79986. /**
  79987. * Connects the keyboard with an input text control
  79988. *
  79989. * @param input defines the target control
  79990. */
  79991. connect(input: InputText): void;
  79992. /**
  79993. * Disconnects the keyboard from connected InputText controls
  79994. *
  79995. * @param input optionally defines a target control, otherwise all are disconnected
  79996. */
  79997. disconnect(input?: InputText): void;
  79998. private _removeConnectedInputObservables;
  79999. /**
  80000. * Release all resources
  80001. */
  80002. dispose(): void;
  80003. /**
  80004. * Creates a new keyboard using a default layout
  80005. *
  80006. * @param name defines control name
  80007. * @returns a new VirtualKeyboard
  80008. */
  80009. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  80010. }
  80011. }
  80012. declare module BABYLON.GUI {
  80013. /** @hidden */
  80014. export class TextWrapper {
  80015. private _text;
  80016. private _characters;
  80017. get text(): string;
  80018. set text(txt: string);
  80019. get length(): number;
  80020. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  80021. charAt(idx: number): string;
  80022. substr(from: number, length?: number): string;
  80023. substring(from: number, to?: number): string;
  80024. isWord(index: number): boolean;
  80025. }
  80026. }
  80027. declare module BABYLON.GUI {
  80028. /**
  80029. * Class used to create input text control
  80030. */
  80031. export class InputText extends Control implements IFocusableControl {
  80032. name?: string | undefined;
  80033. private _textWrapper;
  80034. private _placeholderText;
  80035. private _background;
  80036. private _focusedBackground;
  80037. private _focusedColor;
  80038. private _placeholderColor;
  80039. private _thickness;
  80040. private _margin;
  80041. private _autoStretchWidth;
  80042. private _maxWidth;
  80043. private _isFocused;
  80044. private _blinkTimeout;
  80045. private _blinkIsEven;
  80046. private _cursorOffset;
  80047. private _scrollLeft;
  80048. private _textWidth;
  80049. private _clickedCoordinate;
  80050. private _deadKey;
  80051. private _addKey;
  80052. private _currentKey;
  80053. private _isTextHighlightOn;
  80054. private _textHighlightColor;
  80055. private _highligherOpacity;
  80056. private _highlightedText;
  80057. private _startHighlightIndex;
  80058. private _endHighlightIndex;
  80059. private _cursorIndex;
  80060. private _onFocusSelectAll;
  80061. private _isPointerDown;
  80062. private _onClipboardObserver;
  80063. private _onPointerDblTapObserver;
  80064. /** @hidden */
  80065. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80066. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80067. promptMessage: string;
  80068. /** Force disable prompt on mobile device */
  80069. disableMobilePrompt: boolean;
  80070. /** BABYLON.Observable raised when the text changes */
  80071. onTextChangedObservable: BABYLON.Observable<InputText>;
  80072. /** BABYLON.Observable raised just before an entered character is to be added */
  80073. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80074. /** BABYLON.Observable raised when the control gets the focus */
  80075. onFocusObservable: BABYLON.Observable<InputText>;
  80076. /** BABYLON.Observable raised when the control loses the focus */
  80077. onBlurObservable: BABYLON.Observable<InputText>;
  80078. /**Observable raised when the text is highlighted */
  80079. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80080. /**Observable raised when copy event is triggered */
  80081. onTextCopyObservable: BABYLON.Observable<InputText>;
  80082. /** BABYLON.Observable raised when cut event is triggered */
  80083. onTextCutObservable: BABYLON.Observable<InputText>;
  80084. /** BABYLON.Observable raised when paste event is triggered */
  80085. onTextPasteObservable: BABYLON.Observable<InputText>;
  80086. /** BABYLON.Observable raised when a key event was processed */
  80087. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80088. /** Gets or sets the maximum width allowed by the control */
  80089. get maxWidth(): string | number;
  80090. /** Gets the maximum width allowed by the control in pixels */
  80091. get maxWidthInPixels(): number;
  80092. set maxWidth(value: string | number);
  80093. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80094. get highligherOpacity(): number;
  80095. set highligherOpacity(value: number);
  80096. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80097. get onFocusSelectAll(): boolean;
  80098. set onFocusSelectAll(value: boolean);
  80099. /** Gets or sets the text hightlight color */
  80100. get textHighlightColor(): string;
  80101. set textHighlightColor(value: string);
  80102. /** Gets or sets control margin */
  80103. get margin(): string;
  80104. /** Gets control margin in pixels */
  80105. get marginInPixels(): number;
  80106. set margin(value: string);
  80107. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80108. get autoStretchWidth(): boolean;
  80109. set autoStretchWidth(value: boolean);
  80110. /** Gets or sets border thickness */
  80111. get thickness(): number;
  80112. set thickness(value: number);
  80113. /** Gets or sets the background color when focused */
  80114. get focusedBackground(): string;
  80115. set focusedBackground(value: string);
  80116. /** Gets or sets the background color when focused */
  80117. get focusedColor(): string;
  80118. set focusedColor(value: string);
  80119. /** Gets or sets the background color */
  80120. get background(): string;
  80121. set background(value: string);
  80122. /** Gets or sets the placeholder color */
  80123. get placeholderColor(): string;
  80124. set placeholderColor(value: string);
  80125. /** Gets or sets the text displayed when the control is empty */
  80126. get placeholderText(): string;
  80127. set placeholderText(value: string);
  80128. /** Gets or sets the dead key flag */
  80129. get deadKey(): boolean;
  80130. set deadKey(flag: boolean);
  80131. /** Gets or sets the highlight text */
  80132. get highlightedText(): string;
  80133. set highlightedText(text: string);
  80134. /** Gets or sets if the current key should be added */
  80135. get addKey(): boolean;
  80136. set addKey(flag: boolean);
  80137. /** Gets or sets the value of the current key being entered */
  80138. get currentKey(): string;
  80139. set currentKey(key: string);
  80140. /** Gets or sets the text displayed in the control */
  80141. get text(): string;
  80142. set text(value: string);
  80143. private _textHasChanged;
  80144. /** Gets or sets control width */
  80145. get width(): string | number;
  80146. set width(value: string | number);
  80147. /**
  80148. * Creates a new InputText
  80149. * @param name defines the control name
  80150. * @param text defines the text of the control
  80151. */
  80152. constructor(name?: string | undefined, text?: string);
  80153. /** @hidden */
  80154. onBlur(): void;
  80155. /** @hidden */
  80156. onFocus(): void;
  80157. protected _getTypeName(): string;
  80158. /**
  80159. * Function called to get the list of controls that should not steal the focus from this control
  80160. * @returns an array of controls
  80161. */
  80162. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80163. /** @hidden */
  80164. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80165. /** @hidden */
  80166. private _updateValueFromCursorIndex;
  80167. /** @hidden */
  80168. private _processDblClick;
  80169. /** @hidden */
  80170. private _selectAllText;
  80171. /**
  80172. * Handles the keyboard event
  80173. * @param evt Defines the KeyboardEvent
  80174. */
  80175. processKeyboard(evt: KeyboardEvent): void;
  80176. /** @hidden */
  80177. private _onCopyText;
  80178. /** @hidden */
  80179. private _onCutText;
  80180. /** @hidden */
  80181. private _onPasteText;
  80182. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80183. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80184. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80185. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80186. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80187. dispose(): void;
  80188. }
  80189. }
  80190. declare module BABYLON.GUI {
  80191. /**
  80192. * Class used to create a 2D grid container
  80193. */
  80194. export class Grid extends Container {
  80195. name?: string | undefined;
  80196. private _rowDefinitions;
  80197. private _columnDefinitions;
  80198. private _cells;
  80199. private _childControls;
  80200. /**
  80201. * Gets the number of columns
  80202. */
  80203. get columnCount(): number;
  80204. /**
  80205. * Gets the number of rows
  80206. */
  80207. get rowCount(): number;
  80208. /** Gets the list of children */
  80209. get children(): Control[];
  80210. /** Gets the list of cells (e.g. the containers) */
  80211. get cells(): {
  80212. [key: string]: Container;
  80213. };
  80214. /**
  80215. * Gets the definition of a specific row
  80216. * @param index defines the index of the row
  80217. * @returns the row definition
  80218. */
  80219. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80220. /**
  80221. * Gets the definition of a specific column
  80222. * @param index defines the index of the column
  80223. * @returns the column definition
  80224. */
  80225. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80226. /**
  80227. * Adds a new row to the grid
  80228. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80229. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80230. * @returns the current grid
  80231. */
  80232. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80233. /**
  80234. * Adds a new column to the grid
  80235. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80236. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80237. * @returns the current grid
  80238. */
  80239. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80240. /**
  80241. * Update a row definition
  80242. * @param index defines the index of the row to update
  80243. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80244. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80245. * @returns the current grid
  80246. */
  80247. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80248. /**
  80249. * Update a column definition
  80250. * @param index defines the index of the column to update
  80251. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80252. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80253. * @returns the current grid
  80254. */
  80255. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80256. /**
  80257. * Gets the list of children stored in a specific cell
  80258. * @param row defines the row to check
  80259. * @param column defines the column to check
  80260. * @returns the list of controls
  80261. */
  80262. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80263. /**
  80264. * Gets a string representing the child cell info (row x column)
  80265. * @param child defines the control to get info from
  80266. * @returns a string containing the child cell info (row x column)
  80267. */
  80268. getChildCellInfo(child: Control): string;
  80269. private _removeCell;
  80270. private _offsetCell;
  80271. /**
  80272. * Remove a column definition at specified index
  80273. * @param index defines the index of the column to remove
  80274. * @returns the current grid
  80275. */
  80276. removeColumnDefinition(index: number): Grid;
  80277. /**
  80278. * Remove a row definition at specified index
  80279. * @param index defines the index of the row to remove
  80280. * @returns the current grid
  80281. */
  80282. removeRowDefinition(index: number): Grid;
  80283. /**
  80284. * Adds a new control to the current grid
  80285. * @param control defines the control to add
  80286. * @param row defines the row where to add the control (0 by default)
  80287. * @param column defines the column where to add the control (0 by default)
  80288. * @returns the current grid
  80289. */
  80290. addControl(control: Control, row?: number, column?: number): Grid;
  80291. /**
  80292. * Removes a control from the current container
  80293. * @param control defines the control to remove
  80294. * @returns the current container
  80295. */
  80296. removeControl(control: Control): Container;
  80297. /**
  80298. * Creates a new Grid
  80299. * @param name defines control name
  80300. */
  80301. constructor(name?: string | undefined);
  80302. protected _getTypeName(): string;
  80303. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80304. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80305. _flagDescendantsAsMatrixDirty(): void;
  80306. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80307. /** Releases associated resources */
  80308. dispose(): void;
  80309. }
  80310. }
  80311. declare module BABYLON.GUI {
  80312. /** Class used to create color pickers */
  80313. export class ColorPicker extends Control {
  80314. name?: string | undefined;
  80315. private static _Epsilon;
  80316. private _colorWheelCanvas;
  80317. private _value;
  80318. private _tmpColor;
  80319. private _pointerStartedOnSquare;
  80320. private _pointerStartedOnWheel;
  80321. private _squareLeft;
  80322. private _squareTop;
  80323. private _squareSize;
  80324. private _h;
  80325. private _s;
  80326. private _v;
  80327. private _lastPointerDownID;
  80328. /**
  80329. * BABYLON.Observable raised when the value changes
  80330. */
  80331. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80332. /** Gets or sets the color of the color picker */
  80333. get value(): BABYLON.Color3;
  80334. set value(value: BABYLON.Color3);
  80335. /**
  80336. * Gets or sets control width
  80337. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80338. */
  80339. get width(): string | number;
  80340. set width(value: string | number);
  80341. /**
  80342. * Gets or sets control height
  80343. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80344. */
  80345. get height(): string | number;
  80346. /** Gets or sets control height */
  80347. set height(value: string | number);
  80348. /** Gets or sets control size */
  80349. get size(): string | number;
  80350. set size(value: string | number);
  80351. /**
  80352. * Creates a new ColorPicker
  80353. * @param name defines the control name
  80354. */
  80355. constructor(name?: string | undefined);
  80356. protected _getTypeName(): string;
  80357. /** @hidden */
  80358. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80359. private _updateSquareProps;
  80360. private _drawGradientSquare;
  80361. private _drawCircle;
  80362. private _createColorWheelCanvas;
  80363. /** @hidden */
  80364. _draw(context: CanvasRenderingContext2D): void;
  80365. private _pointerIsDown;
  80366. private _updateValueFromPointer;
  80367. private _isPointOnSquare;
  80368. private _isPointOnWheel;
  80369. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80370. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80371. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80372. _onCanvasBlur(): void;
  80373. /**
  80374. * This function expands the color picker by creating a color picker dialog with manual
  80375. * color value input and the ability to save colors into an array to be used later in
  80376. * subsequent launches of the dialogue.
  80377. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80378. * @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.
  80379. * @returns picked color as a hex string and the saved colors array as hex strings.
  80380. */
  80381. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80382. pickerWidth?: string;
  80383. pickerHeight?: string;
  80384. headerHeight?: string;
  80385. lastColor?: string;
  80386. swatchLimit?: number;
  80387. numSwatchesPerLine?: number;
  80388. savedColors?: Array<string>;
  80389. }): Promise<{
  80390. savedColors?: string[];
  80391. pickedColor: string;
  80392. }>;
  80393. }
  80394. }
  80395. declare module BABYLON.GUI {
  80396. /** Class used to create 2D ellipse containers */
  80397. export class Ellipse extends Container {
  80398. name?: string | undefined;
  80399. private _thickness;
  80400. /** Gets or sets border thickness */
  80401. get thickness(): number;
  80402. set thickness(value: number);
  80403. /**
  80404. * Creates a new Ellipse
  80405. * @param name defines the control name
  80406. */
  80407. constructor(name?: string | undefined);
  80408. protected _getTypeName(): string;
  80409. protected _localDraw(context: CanvasRenderingContext2D): void;
  80410. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80411. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80412. }
  80413. }
  80414. declare module BABYLON.GUI {
  80415. /**
  80416. * Class used to create a password control
  80417. */
  80418. export class InputPassword extends InputText {
  80419. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80420. }
  80421. }
  80422. declare module BABYLON.GUI {
  80423. /** Class used to render 2D lines */
  80424. export class Line extends Control {
  80425. name?: string | undefined;
  80426. private _lineWidth;
  80427. private _x1;
  80428. private _y1;
  80429. private _x2;
  80430. private _y2;
  80431. private _dash;
  80432. private _connectedControl;
  80433. private _connectedControlDirtyObserver;
  80434. /** Gets or sets the dash pattern */
  80435. get dash(): Array<number>;
  80436. set dash(value: Array<number>);
  80437. /** Gets or sets the control connected with the line end */
  80438. get connectedControl(): Control;
  80439. set connectedControl(value: Control);
  80440. /** Gets or sets start coordinates on X axis */
  80441. get x1(): string | number;
  80442. set x1(value: string | number);
  80443. /** Gets or sets start coordinates on Y axis */
  80444. get y1(): string | number;
  80445. set y1(value: string | number);
  80446. /** Gets or sets end coordinates on X axis */
  80447. get x2(): string | number;
  80448. set x2(value: string | number);
  80449. /** Gets or sets end coordinates on Y axis */
  80450. get y2(): string | number;
  80451. set y2(value: string | number);
  80452. /** Gets or sets line width */
  80453. get lineWidth(): number;
  80454. set lineWidth(value: number);
  80455. /** Gets or sets horizontal alignment */
  80456. set horizontalAlignment(value: number);
  80457. /** Gets or sets vertical alignment */
  80458. set verticalAlignment(value: number);
  80459. private get _effectiveX2();
  80460. private get _effectiveY2();
  80461. /**
  80462. * Creates a new Line
  80463. * @param name defines the control name
  80464. */
  80465. constructor(name?: string | undefined);
  80466. protected _getTypeName(): string;
  80467. _draw(context: CanvasRenderingContext2D): void;
  80468. _measure(): void;
  80469. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80470. /**
  80471. * Move one end of the line given 3D cartesian coordinates.
  80472. * @param position Targeted world position
  80473. * @param scene BABYLON.Scene
  80474. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80475. */
  80476. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80477. /**
  80478. * Move one end of the line to a position in screen absolute space.
  80479. * @param projectedPosition Position in screen absolute space (X, Y)
  80480. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80481. */
  80482. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80483. }
  80484. }
  80485. declare module BABYLON.GUI {
  80486. /**
  80487. * Class used to store a point for a MultiLine object.
  80488. * The point can be pure 2D coordinates, a mesh or a control
  80489. */
  80490. export class MultiLinePoint {
  80491. private _multiLine;
  80492. private _x;
  80493. private _y;
  80494. private _control;
  80495. private _mesh;
  80496. private _controlObserver;
  80497. private _meshObserver;
  80498. /** @hidden */
  80499. _point: BABYLON.Vector3;
  80500. /**
  80501. * Creates a new MultiLinePoint
  80502. * @param multiLine defines the source MultiLine object
  80503. */
  80504. constructor(multiLine: MultiLine);
  80505. /** Gets or sets x coordinate */
  80506. get x(): string | number;
  80507. set x(value: string | number);
  80508. /** Gets or sets y coordinate */
  80509. get y(): string | number;
  80510. set y(value: string | number);
  80511. /** Gets or sets the control associated with this point */
  80512. get control(): BABYLON.Nullable<Control>;
  80513. set control(value: BABYLON.Nullable<Control>);
  80514. /** Gets or sets the mesh associated with this point */
  80515. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80516. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80517. /** Resets links */
  80518. resetLinks(): void;
  80519. /**
  80520. * Gets a translation vector with Z component
  80521. * @returns the translation vector
  80522. */
  80523. translate(): BABYLON.Vector3;
  80524. private _translatePoint;
  80525. /** Release associated resources */
  80526. dispose(): void;
  80527. }
  80528. }
  80529. declare module BABYLON.GUI {
  80530. /**
  80531. * Class used to create multi line control
  80532. */
  80533. export class MultiLine extends Control {
  80534. name?: string | undefined;
  80535. private _lineWidth;
  80536. private _dash;
  80537. private _points;
  80538. private _minX;
  80539. private _minY;
  80540. private _maxX;
  80541. private _maxY;
  80542. /**
  80543. * Creates a new MultiLine
  80544. * @param name defines the control name
  80545. */
  80546. constructor(name?: string | undefined);
  80547. /** Gets or sets dash pattern */
  80548. get dash(): Array<number>;
  80549. set dash(value: Array<number>);
  80550. /**
  80551. * Gets point stored at specified index
  80552. * @param index defines the index to look for
  80553. * @returns the requested point if found
  80554. */
  80555. getAt(index: number): MultiLinePoint;
  80556. /** Function called when a point is updated */
  80557. onPointUpdate: () => void;
  80558. /**
  80559. * Adds new points to the point collection
  80560. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80561. * @returns the list of created MultiLinePoint
  80562. */
  80563. add(...items: (AbstractMesh | Control | {
  80564. x: string | number;
  80565. y: string | number;
  80566. })[]): MultiLinePoint[];
  80567. /**
  80568. * Adds a new point to the point collection
  80569. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80570. * @returns the created MultiLinePoint
  80571. */
  80572. push(item?: (AbstractMesh | Control | {
  80573. x: string | number;
  80574. y: string | number;
  80575. })): MultiLinePoint;
  80576. /**
  80577. * Remove a specific value or point from the active point collection
  80578. * @param value defines the value or point to remove
  80579. */
  80580. remove(value: number | MultiLinePoint): void;
  80581. /**
  80582. * Resets this object to initial state (no point)
  80583. */
  80584. reset(): void;
  80585. /**
  80586. * Resets all links
  80587. */
  80588. resetLinks(): void;
  80589. /** Gets or sets line width */
  80590. get lineWidth(): number;
  80591. set lineWidth(value: number);
  80592. set horizontalAlignment(value: number);
  80593. set verticalAlignment(value: number);
  80594. protected _getTypeName(): string;
  80595. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80596. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80597. _measure(): void;
  80598. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80599. dispose(): void;
  80600. }
  80601. }
  80602. declare module BABYLON.GUI {
  80603. /**
  80604. * Class used to create radio button controls
  80605. */
  80606. export class RadioButton extends Control {
  80607. name?: string | undefined;
  80608. private _isChecked;
  80609. private _background;
  80610. private _checkSizeRatio;
  80611. private _thickness;
  80612. /** Gets or sets border thickness */
  80613. get thickness(): number;
  80614. set thickness(value: number);
  80615. /** Gets or sets group name */
  80616. group: string;
  80617. /** BABYLON.Observable raised when isChecked is changed */
  80618. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80619. /** Gets or sets a value indicating the ratio between overall size and check size */
  80620. get checkSizeRatio(): number;
  80621. set checkSizeRatio(value: number);
  80622. /** Gets or sets background color */
  80623. get background(): string;
  80624. set background(value: string);
  80625. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80626. get isChecked(): boolean;
  80627. set isChecked(value: boolean);
  80628. /**
  80629. * Creates a new RadioButton
  80630. * @param name defines the control name
  80631. */
  80632. constructor(name?: string | undefined);
  80633. protected _getTypeName(): string;
  80634. _draw(context: CanvasRenderingContext2D): void;
  80635. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80636. /**
  80637. * Utility function to easily create a radio button with a header
  80638. * @param title defines the label to use for the header
  80639. * @param group defines the group to use for the radio button
  80640. * @param isChecked defines the initial state of the radio button
  80641. * @param onValueChanged defines the callback to call when value changes
  80642. * @returns a StackPanel containing the radio button and a textBlock
  80643. */
  80644. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80645. }
  80646. }
  80647. declare module BABYLON.GUI {
  80648. /**
  80649. * Class used to create slider controls
  80650. */
  80651. export class BaseSlider extends Control {
  80652. name?: string | undefined;
  80653. protected _thumbWidth: ValueAndUnit;
  80654. private _minimum;
  80655. private _maximum;
  80656. private _value;
  80657. private _isVertical;
  80658. protected _barOffset: ValueAndUnit;
  80659. private _isThumbClamped;
  80660. protected _displayThumb: boolean;
  80661. private _step;
  80662. private _lastPointerDownID;
  80663. protected _effectiveBarOffset: number;
  80664. protected _renderLeft: number;
  80665. protected _renderTop: number;
  80666. protected _renderWidth: number;
  80667. protected _renderHeight: number;
  80668. protected _backgroundBoxLength: number;
  80669. protected _backgroundBoxThickness: number;
  80670. protected _effectiveThumbThickness: number;
  80671. /** BABYLON.Observable raised when the sldier value changes */
  80672. onValueChangedObservable: BABYLON.Observable<number>;
  80673. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80674. get displayThumb(): boolean;
  80675. set displayThumb(value: boolean);
  80676. /** Gets or sets a step to apply to values (0 by default) */
  80677. get step(): number;
  80678. set step(value: number);
  80679. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80680. get barOffset(): string | number;
  80681. /** Gets main bar offset in pixels*/
  80682. get barOffsetInPixels(): number;
  80683. set barOffset(value: string | number);
  80684. /** Gets or sets thumb width */
  80685. get thumbWidth(): string | number;
  80686. /** Gets thumb width in pixels */
  80687. get thumbWidthInPixels(): number;
  80688. set thumbWidth(value: string | number);
  80689. /** Gets or sets minimum value */
  80690. get minimum(): number;
  80691. set minimum(value: number);
  80692. /** Gets or sets maximum value */
  80693. get maximum(): number;
  80694. set maximum(value: number);
  80695. /** Gets or sets current value */
  80696. get value(): number;
  80697. set value(value: number);
  80698. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80699. get isVertical(): boolean;
  80700. set isVertical(value: boolean);
  80701. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80702. get isThumbClamped(): boolean;
  80703. set isThumbClamped(value: boolean);
  80704. /**
  80705. * Creates a new BaseSlider
  80706. * @param name defines the control name
  80707. */
  80708. constructor(name?: string | undefined);
  80709. protected _getTypeName(): string;
  80710. protected _getThumbPosition(): number;
  80711. protected _getThumbThickness(type: string): number;
  80712. protected _prepareRenderingData(type: string): void;
  80713. private _pointerIsDown;
  80714. /** @hidden */
  80715. protected _updateValueFromPointer(x: number, y: number): void;
  80716. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80717. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80718. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80719. _onCanvasBlur(): void;
  80720. }
  80721. }
  80722. declare module BABYLON.GUI {
  80723. /**
  80724. * Class used to create slider controls
  80725. */
  80726. export class Slider extends BaseSlider {
  80727. name?: string | undefined;
  80728. private _background;
  80729. private _borderColor;
  80730. private _thumbColor;
  80731. private _isThumbCircle;
  80732. protected _displayValueBar: boolean;
  80733. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80734. get displayValueBar(): boolean;
  80735. set displayValueBar(value: boolean);
  80736. /** Gets or sets border color */
  80737. get borderColor(): string;
  80738. set borderColor(value: string);
  80739. /** Gets or sets background color */
  80740. get background(): string;
  80741. set background(value: string);
  80742. /** Gets or sets thumb's color */
  80743. get thumbColor(): string;
  80744. set thumbColor(value: string);
  80745. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80746. get isThumbCircle(): boolean;
  80747. set isThumbCircle(value: boolean);
  80748. /**
  80749. * Creates a new Slider
  80750. * @param name defines the control name
  80751. */
  80752. constructor(name?: string | undefined);
  80753. protected _getTypeName(): string;
  80754. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80755. }
  80756. }
  80757. declare module BABYLON.GUI {
  80758. /** Class used to create a RadioGroup
  80759. * which contains groups of radio buttons
  80760. */
  80761. export class SelectorGroup {
  80762. /** name of SelectorGroup */
  80763. name: string;
  80764. private _groupPanel;
  80765. private _selectors;
  80766. private _groupHeader;
  80767. /**
  80768. * Creates a new SelectorGroup
  80769. * @param name of group, used as a group heading
  80770. */
  80771. constructor(
  80772. /** name of SelectorGroup */
  80773. name: string);
  80774. /** Gets the groupPanel of the SelectorGroup */
  80775. get groupPanel(): StackPanel;
  80776. /** Gets the selectors array */
  80777. get selectors(): StackPanel[];
  80778. /** Gets and sets the group header */
  80779. get header(): string;
  80780. set header(label: string);
  80781. /** @hidden */
  80782. private _addGroupHeader;
  80783. /** @hidden*/
  80784. _getSelector(selectorNb: number): StackPanel | undefined;
  80785. /** Removes the selector at the given position
  80786. * @param selectorNb the position of the selector within the group
  80787. */
  80788. removeSelector(selectorNb: number): void;
  80789. }
  80790. /** Class used to create a CheckboxGroup
  80791. * which contains groups of checkbox buttons
  80792. */
  80793. export class CheckboxGroup extends SelectorGroup {
  80794. /** Adds a checkbox as a control
  80795. * @param text is the label for the selector
  80796. * @param func is the function called when the Selector is checked
  80797. * @param checked is true when Selector is checked
  80798. */
  80799. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80800. /** @hidden */
  80801. _setSelectorLabel(selectorNb: number, label: string): void;
  80802. /** @hidden */
  80803. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80804. /** @hidden */
  80805. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80806. /** @hidden */
  80807. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80808. }
  80809. /** Class used to create a RadioGroup
  80810. * which contains groups of radio buttons
  80811. */
  80812. export class RadioGroup extends SelectorGroup {
  80813. private _selectNb;
  80814. /** Adds a radio button as a control
  80815. * @param label is the label for the selector
  80816. * @param func is the function called when the Selector is checked
  80817. * @param checked is true when Selector is checked
  80818. */
  80819. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80820. /** @hidden */
  80821. _setSelectorLabel(selectorNb: number, label: string): void;
  80822. /** @hidden */
  80823. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80824. /** @hidden */
  80825. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80826. /** @hidden */
  80827. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80828. }
  80829. /** Class used to create a SliderGroup
  80830. * which contains groups of slider buttons
  80831. */
  80832. export class SliderGroup extends SelectorGroup {
  80833. /**
  80834. * Adds a slider to the SelectorGroup
  80835. * @param label is the label for the SliderBar
  80836. * @param func is the function called when the Slider moves
  80837. * @param unit is a string describing the units used, eg degrees or metres
  80838. * @param min is the minimum value for the Slider
  80839. * @param max is the maximum value for the Slider
  80840. * @param value is the start value for the Slider between min and max
  80841. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80842. */
  80843. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80844. /** @hidden */
  80845. _setSelectorLabel(selectorNb: number, label: string): void;
  80846. /** @hidden */
  80847. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80848. /** @hidden */
  80849. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80850. /** @hidden */
  80851. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80852. }
  80853. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80854. * @see https://doc.babylonjs.com/how_to/selector
  80855. */
  80856. export class SelectionPanel extends Rectangle {
  80857. /** name of SelectionPanel */
  80858. name: string;
  80859. /** an array of SelectionGroups */
  80860. groups: SelectorGroup[];
  80861. private _panel;
  80862. private _buttonColor;
  80863. private _buttonBackground;
  80864. private _headerColor;
  80865. private _barColor;
  80866. private _barHeight;
  80867. private _spacerHeight;
  80868. private _labelColor;
  80869. private _groups;
  80870. private _bars;
  80871. /**
  80872. * Creates a new SelectionPanel
  80873. * @param name of SelectionPanel
  80874. * @param groups is an array of SelectionGroups
  80875. */
  80876. constructor(
  80877. /** name of SelectionPanel */
  80878. name: string,
  80879. /** an array of SelectionGroups */
  80880. groups?: SelectorGroup[]);
  80881. protected _getTypeName(): string;
  80882. /** Gets the (stack) panel of the SelectionPanel */
  80883. get panel(): StackPanel;
  80884. /** Gets or sets the headerColor */
  80885. get headerColor(): string;
  80886. set headerColor(color: string);
  80887. private _setHeaderColor;
  80888. /** Gets or sets the button color */
  80889. get buttonColor(): string;
  80890. set buttonColor(color: string);
  80891. private _setbuttonColor;
  80892. /** Gets or sets the label color */
  80893. get labelColor(): string;
  80894. set labelColor(color: string);
  80895. private _setLabelColor;
  80896. /** Gets or sets the button background */
  80897. get buttonBackground(): string;
  80898. set buttonBackground(color: string);
  80899. private _setButtonBackground;
  80900. /** Gets or sets the color of separator bar */
  80901. get barColor(): string;
  80902. set barColor(color: string);
  80903. private _setBarColor;
  80904. /** Gets or sets the height of separator bar */
  80905. get barHeight(): string;
  80906. set barHeight(value: string);
  80907. private _setBarHeight;
  80908. /** Gets or sets the height of spacers*/
  80909. get spacerHeight(): string;
  80910. set spacerHeight(value: string);
  80911. private _setSpacerHeight;
  80912. /** Adds a bar between groups */
  80913. private _addSpacer;
  80914. /** Add a group to the selection panel
  80915. * @param group is the selector group to add
  80916. */
  80917. addGroup(group: SelectorGroup): void;
  80918. /** Remove the group from the given position
  80919. * @param groupNb is the position of the group in the list
  80920. */
  80921. removeGroup(groupNb: number): void;
  80922. /** Change a group header label
  80923. * @param label is the new group header label
  80924. * @param groupNb is the number of the group to relabel
  80925. * */
  80926. setHeaderName(label: string, groupNb: number): void;
  80927. /** Change selector label to the one given
  80928. * @param label is the new selector label
  80929. * @param groupNb is the number of the groupcontaining the selector
  80930. * @param selectorNb is the number of the selector within a group to relabel
  80931. * */
  80932. relabel(label: string, groupNb: number, selectorNb: number): void;
  80933. /** For a given group position remove the selector at the given position
  80934. * @param groupNb is the number of the group to remove the selector from
  80935. * @param selectorNb is the number of the selector within the group
  80936. */
  80937. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80938. /** For a given group position of correct type add a checkbox button
  80939. * @param groupNb is the number of the group to remove the selector from
  80940. * @param label is the label for the selector
  80941. * @param func is the function called when the Selector is checked
  80942. * @param checked is true when Selector is checked
  80943. */
  80944. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80945. /** For a given group position of correct type add a radio button
  80946. * @param groupNb is the number of the group to remove the selector from
  80947. * @param label is the label for the selector
  80948. * @param func is the function called when the Selector is checked
  80949. * @param checked is true when Selector is checked
  80950. */
  80951. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80952. /**
  80953. * For a given slider group add a slider
  80954. * @param groupNb is the number of the group to add the slider to
  80955. * @param label is the label for the Slider
  80956. * @param func is the function called when the Slider moves
  80957. * @param unit is a string describing the units used, eg degrees or metres
  80958. * @param min is the minimum value for the Slider
  80959. * @param max is the maximum value for the Slider
  80960. * @param value is the start value for the Slider between min and max
  80961. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80962. */
  80963. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80964. }
  80965. }
  80966. declare module BABYLON.GUI {
  80967. /**
  80968. * Class used to hold a the container for ScrollViewer
  80969. * @hidden
  80970. */
  80971. export class _ScrollViewerWindow extends Container {
  80972. parentClientWidth: number;
  80973. parentClientHeight: number;
  80974. private _freezeControls;
  80975. private _parentMeasure;
  80976. private _oldLeft;
  80977. private _oldTop;
  80978. get freezeControls(): boolean;
  80979. set freezeControls(value: boolean);
  80980. private _bucketWidth;
  80981. private _bucketHeight;
  80982. private _buckets;
  80983. private _bucketLen;
  80984. get bucketWidth(): number;
  80985. get bucketHeight(): number;
  80986. setBucketSizes(width: number, height: number): void;
  80987. private _useBuckets;
  80988. private _makeBuckets;
  80989. private _dispatchInBuckets;
  80990. private _updateMeasures;
  80991. private _updateChildrenMeasures;
  80992. private _restoreMeasures;
  80993. /**
  80994. * Creates a new ScrollViewerWindow
  80995. * @param name of ScrollViewerWindow
  80996. */
  80997. constructor(name?: string);
  80998. protected _getTypeName(): string;
  80999. /** @hidden */
  81000. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81001. /** @hidden */
  81002. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  81003. private _scrollChildren;
  81004. private _scrollChildrenWithBuckets;
  81005. /** @hidden */
  81006. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  81007. protected _postMeasure(): void;
  81008. }
  81009. }
  81010. declare module BABYLON.GUI {
  81011. /**
  81012. * Class used to create slider controls
  81013. */
  81014. export class ScrollBar extends BaseSlider {
  81015. name?: string | undefined;
  81016. private _background;
  81017. private _borderColor;
  81018. private _tempMeasure;
  81019. /** Gets or sets border color */
  81020. get borderColor(): string;
  81021. set borderColor(value: string);
  81022. /** Gets or sets background color */
  81023. get background(): string;
  81024. set background(value: string);
  81025. /**
  81026. * Creates a new Slider
  81027. * @param name defines the control name
  81028. */
  81029. constructor(name?: string | undefined);
  81030. protected _getTypeName(): string;
  81031. protected _getThumbThickness(): number;
  81032. _draw(context: CanvasRenderingContext2D): void;
  81033. private _first;
  81034. private _originX;
  81035. private _originY;
  81036. /** @hidden */
  81037. protected _updateValueFromPointer(x: number, y: number): void;
  81038. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81039. }
  81040. }
  81041. declare module BABYLON.GUI {
  81042. /**
  81043. * Class used to create slider controls
  81044. */
  81045. export class ImageScrollBar extends BaseSlider {
  81046. name?: string | undefined;
  81047. private _backgroundBaseImage;
  81048. private _backgroundImage;
  81049. private _thumbImage;
  81050. private _thumbBaseImage;
  81051. private _thumbLength;
  81052. private _thumbHeight;
  81053. private _barImageHeight;
  81054. private _tempMeasure;
  81055. /** Number of 90° rotation to apply on the images when in vertical mode */
  81056. num90RotationInVerticalMode: number;
  81057. /**
  81058. * Gets or sets the image used to render the background for horizontal bar
  81059. */
  81060. get backgroundImage(): Image;
  81061. set backgroundImage(value: Image);
  81062. /**
  81063. * Gets or sets the image used to render the thumb
  81064. */
  81065. get thumbImage(): Image;
  81066. set thumbImage(value: Image);
  81067. /**
  81068. * Gets or sets the length of the thumb
  81069. */
  81070. get thumbLength(): number;
  81071. set thumbLength(value: number);
  81072. /**
  81073. * Gets or sets the height of the thumb
  81074. */
  81075. get thumbHeight(): number;
  81076. set thumbHeight(value: number);
  81077. /**
  81078. * Gets or sets the height of the bar image
  81079. */
  81080. get barImageHeight(): number;
  81081. set barImageHeight(value: number);
  81082. /**
  81083. * Creates a new ImageScrollBar
  81084. * @param name defines the control name
  81085. */
  81086. constructor(name?: string | undefined);
  81087. protected _getTypeName(): string;
  81088. protected _getThumbThickness(): number;
  81089. _draw(context: CanvasRenderingContext2D): void;
  81090. private _first;
  81091. private _originX;
  81092. private _originY;
  81093. /** @hidden */
  81094. protected _updateValueFromPointer(x: number, y: number): void;
  81095. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81096. }
  81097. }
  81098. declare module BABYLON.GUI {
  81099. /**
  81100. * Class used to hold a viewer window and sliders in a grid
  81101. */
  81102. export class ScrollViewer extends Rectangle {
  81103. private _grid;
  81104. private _horizontalBarSpace;
  81105. private _verticalBarSpace;
  81106. private _dragSpace;
  81107. private _horizontalBar;
  81108. private _verticalBar;
  81109. private _barColor;
  81110. private _barBackground;
  81111. private _barImage;
  81112. private _horizontalBarImage;
  81113. private _verticalBarImage;
  81114. private _barBackgroundImage;
  81115. private _horizontalBarBackgroundImage;
  81116. private _verticalBarBackgroundImage;
  81117. private _barSize;
  81118. private _window;
  81119. private _pointerIsOver;
  81120. private _wheelPrecision;
  81121. private _onWheelObserver;
  81122. private _clientWidth;
  81123. private _clientHeight;
  81124. private _useImageBar;
  81125. private _thumbLength;
  81126. private _thumbHeight;
  81127. private _barImageHeight;
  81128. private _horizontalBarImageHeight;
  81129. private _verticalBarImageHeight;
  81130. private _oldWindowContentsWidth;
  81131. private _oldWindowContentsHeight;
  81132. /**
  81133. * Gets the horizontal scrollbar
  81134. */
  81135. get horizontalBar(): ScrollBar | ImageScrollBar;
  81136. /**
  81137. * Gets the vertical scrollbar
  81138. */
  81139. get verticalBar(): ScrollBar | ImageScrollBar;
  81140. /**
  81141. * Adds a new control to the current container
  81142. * @param control defines the control to add
  81143. * @returns the current container
  81144. */
  81145. addControl(control: BABYLON.Nullable<Control>): Container;
  81146. /**
  81147. * Removes a control from the current container
  81148. * @param control defines the control to remove
  81149. * @returns the current container
  81150. */
  81151. removeControl(control: Control): Container;
  81152. /** Gets the list of children */
  81153. get children(): Control[];
  81154. _flagDescendantsAsMatrixDirty(): void;
  81155. /**
  81156. * Freezes or unfreezes the controls in the window.
  81157. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81158. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81159. */
  81160. get freezeControls(): boolean;
  81161. set freezeControls(value: boolean);
  81162. /** Gets the bucket width */
  81163. get bucketWidth(): number;
  81164. /** Gets the bucket height */
  81165. get bucketHeight(): number;
  81166. /**
  81167. * Sets the bucket sizes.
  81168. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81169. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81170. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81171. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81172. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81173. * used), that's why it is not enabled by default.
  81174. * @param width width of the bucket
  81175. * @param height height of the bucket
  81176. */
  81177. setBucketSizes(width: number, height: number): void;
  81178. private _forceHorizontalBar;
  81179. private _forceVerticalBar;
  81180. /**
  81181. * Forces the horizontal scroll bar to be displayed
  81182. */
  81183. get forceHorizontalBar(): boolean;
  81184. set forceHorizontalBar(value: boolean);
  81185. /**
  81186. * Forces the vertical scroll bar to be displayed
  81187. */
  81188. get forceVerticalBar(): boolean;
  81189. set forceVerticalBar(value: boolean);
  81190. /**
  81191. * Creates a new ScrollViewer
  81192. * @param name of ScrollViewer
  81193. */
  81194. constructor(name?: string, isImageBased?: boolean);
  81195. /** Reset the scroll viewer window to initial size */
  81196. resetWindow(): void;
  81197. protected _getTypeName(): string;
  81198. private _buildClientSizes;
  81199. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81200. protected _postMeasure(): void;
  81201. /**
  81202. * Gets or sets the mouse wheel precision
  81203. * from 0 to 1 with a default value of 0.05
  81204. * */
  81205. get wheelPrecision(): number;
  81206. set wheelPrecision(value: number);
  81207. /** Gets or sets the scroll bar container background color */
  81208. get scrollBackground(): string;
  81209. set scrollBackground(color: string);
  81210. /** Gets or sets the bar color */
  81211. get barColor(): string;
  81212. set barColor(color: string);
  81213. /** Gets or sets the bar image */
  81214. get thumbImage(): Image;
  81215. set thumbImage(value: Image);
  81216. /** Gets or sets the horizontal bar image */
  81217. get horizontalThumbImage(): Image;
  81218. set horizontalThumbImage(value: Image);
  81219. /** Gets or sets the vertical bar image */
  81220. get verticalThumbImage(): Image;
  81221. set verticalThumbImage(value: Image);
  81222. /** Gets or sets the size of the bar */
  81223. get barSize(): number;
  81224. set barSize(value: number);
  81225. /** Gets or sets the length of the thumb */
  81226. get thumbLength(): number;
  81227. set thumbLength(value: number);
  81228. /** Gets or sets the height of the thumb */
  81229. get thumbHeight(): number;
  81230. set thumbHeight(value: number);
  81231. /** Gets or sets the height of the bar image */
  81232. get barImageHeight(): number;
  81233. set barImageHeight(value: number);
  81234. /** Gets or sets the height of the horizontal bar image */
  81235. get horizontalBarImageHeight(): number;
  81236. set horizontalBarImageHeight(value: number);
  81237. /** Gets or sets the height of the vertical bar image */
  81238. get verticalBarImageHeight(): number;
  81239. set verticalBarImageHeight(value: number);
  81240. /** Gets or sets the bar background */
  81241. get barBackground(): string;
  81242. set barBackground(color: string);
  81243. /** Gets or sets the bar background image */
  81244. get barImage(): Image;
  81245. set barImage(value: Image);
  81246. /** Gets or sets the horizontal bar background image */
  81247. get horizontalBarImage(): Image;
  81248. set horizontalBarImage(value: Image);
  81249. /** Gets or sets the vertical bar background image */
  81250. get verticalBarImage(): Image;
  81251. set verticalBarImage(value: Image);
  81252. private _setWindowPosition;
  81253. /** @hidden */
  81254. private _updateScroller;
  81255. _link(host: AdvancedDynamicTexture): void;
  81256. /** @hidden */
  81257. private _addBar;
  81258. /** @hidden */
  81259. private _attachWheel;
  81260. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81261. /** Releases associated resources */
  81262. dispose(): void;
  81263. }
  81264. }
  81265. declare module BABYLON.GUI {
  81266. /** Class used to render a grid */
  81267. export class DisplayGrid extends Control {
  81268. name?: string | undefined;
  81269. private _cellWidth;
  81270. private _cellHeight;
  81271. private _minorLineTickness;
  81272. private _minorLineColor;
  81273. private _majorLineTickness;
  81274. private _majorLineColor;
  81275. private _majorLineFrequency;
  81276. private _background;
  81277. private _displayMajorLines;
  81278. private _displayMinorLines;
  81279. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81280. get displayMinorLines(): boolean;
  81281. set displayMinorLines(value: boolean);
  81282. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81283. get displayMajorLines(): boolean;
  81284. set displayMajorLines(value: boolean);
  81285. /** Gets or sets background color (Black by default) */
  81286. get background(): string;
  81287. set background(value: string);
  81288. /** Gets or sets the width of each cell (20 by default) */
  81289. get cellWidth(): number;
  81290. set cellWidth(value: number);
  81291. /** Gets or sets the height of each cell (20 by default) */
  81292. get cellHeight(): number;
  81293. set cellHeight(value: number);
  81294. /** Gets or sets the tickness of minor lines (1 by default) */
  81295. get minorLineTickness(): number;
  81296. set minorLineTickness(value: number);
  81297. /** Gets or sets the color of minor lines (DarkGray by default) */
  81298. get minorLineColor(): string;
  81299. set minorLineColor(value: string);
  81300. /** Gets or sets the tickness of major lines (2 by default) */
  81301. get majorLineTickness(): number;
  81302. set majorLineTickness(value: number);
  81303. /** Gets or sets the color of major lines (White by default) */
  81304. get majorLineColor(): string;
  81305. set majorLineColor(value: string);
  81306. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81307. get majorLineFrequency(): number;
  81308. set majorLineFrequency(value: number);
  81309. /**
  81310. * Creates a new GridDisplayRectangle
  81311. * @param name defines the control name
  81312. */
  81313. constructor(name?: string | undefined);
  81314. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81315. protected _getTypeName(): string;
  81316. }
  81317. }
  81318. declare module BABYLON.GUI {
  81319. /**
  81320. * Class used to create slider controls based on images
  81321. */
  81322. export class ImageBasedSlider extends BaseSlider {
  81323. name?: string | undefined;
  81324. private _backgroundImage;
  81325. private _thumbImage;
  81326. private _valueBarImage;
  81327. private _tempMeasure;
  81328. get displayThumb(): boolean;
  81329. set displayThumb(value: boolean);
  81330. /**
  81331. * Gets or sets the image used to render the background
  81332. */
  81333. get backgroundImage(): Image;
  81334. set backgroundImage(value: Image);
  81335. /**
  81336. * Gets or sets the image used to render the value bar
  81337. */
  81338. get valueBarImage(): Image;
  81339. set valueBarImage(value: Image);
  81340. /**
  81341. * Gets or sets the image used to render the thumb
  81342. */
  81343. get thumbImage(): Image;
  81344. set thumbImage(value: Image);
  81345. /**
  81346. * Creates a new ImageBasedSlider
  81347. * @param name defines the control name
  81348. */
  81349. constructor(name?: string | undefined);
  81350. protected _getTypeName(): string;
  81351. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81352. }
  81353. }
  81354. declare module BABYLON.GUI {
  81355. /**
  81356. * Forcing an export so that this code will execute
  81357. * @hidden
  81358. */
  81359. const name = "Statics";
  81360. }
  81361. declare module BABYLON.GUI {
  81362. /**
  81363. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81364. */
  81365. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81366. /**
  81367. * Define the instrumented AdvancedDynamicTexture.
  81368. */
  81369. texture: AdvancedDynamicTexture;
  81370. private _captureRenderTime;
  81371. private _renderTime;
  81372. private _captureLayoutTime;
  81373. private _layoutTime;
  81374. private _onBeginRenderObserver;
  81375. private _onEndRenderObserver;
  81376. private _onBeginLayoutObserver;
  81377. private _onEndLayoutObserver;
  81378. /**
  81379. * Gets the perf counter used to capture render time
  81380. */
  81381. get renderTimeCounter(): BABYLON.PerfCounter;
  81382. /**
  81383. * Gets the perf counter used to capture layout time
  81384. */
  81385. get layoutTimeCounter(): BABYLON.PerfCounter;
  81386. /**
  81387. * Enable or disable the render time capture
  81388. */
  81389. get captureRenderTime(): boolean;
  81390. set captureRenderTime(value: boolean);
  81391. /**
  81392. * Enable or disable the layout time capture
  81393. */
  81394. get captureLayoutTime(): boolean;
  81395. set captureLayoutTime(value: boolean);
  81396. /**
  81397. * Instantiates a new advanced dynamic texture instrumentation.
  81398. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81399. * @param texture Defines the AdvancedDynamicTexture to instrument
  81400. */
  81401. constructor(
  81402. /**
  81403. * Define the instrumented AdvancedDynamicTexture.
  81404. */
  81405. texture: AdvancedDynamicTexture);
  81406. /**
  81407. * Dispose and release associated resources.
  81408. */
  81409. dispose(): void;
  81410. }
  81411. }
  81412. declare module BABYLON.GUI {
  81413. /**
  81414. * Class used to load GUI via XML.
  81415. */
  81416. export class XmlLoader {
  81417. private _nodes;
  81418. private _nodeTypes;
  81419. private _isLoaded;
  81420. private _objectAttributes;
  81421. private _parentClass;
  81422. /**
  81423. * Create a new xml loader
  81424. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81425. */
  81426. constructor(parentClass?: null);
  81427. private _getChainElement;
  81428. private _getClassAttribute;
  81429. private _createGuiElement;
  81430. private _parseGrid;
  81431. private _parseElement;
  81432. private _prepareSourceElement;
  81433. private _parseElementsFromSource;
  81434. private _parseXml;
  81435. /**
  81436. * Gets if the loading has finished.
  81437. * @returns whether the loading has finished or not
  81438. */
  81439. isLoaded(): boolean;
  81440. /**
  81441. * Gets a loaded node / control by id.
  81442. * @param id the Controls id set in the xml
  81443. * @returns element of type Control
  81444. */
  81445. getNodeById(id: string): any;
  81446. /**
  81447. * Gets all loaded nodes / controls
  81448. * @returns Array of controls
  81449. */
  81450. getNodes(): any;
  81451. /**
  81452. * Initiates the xml layout loading
  81453. * @param xmlFile defines the xml layout to load
  81454. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81455. * @param callback defines the callback called on layout load.
  81456. */
  81457. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81458. }
  81459. }
  81460. declare module BABYLON.GUI {
  81461. /**
  81462. * Class used to create containers for controls
  81463. */
  81464. export class Container3D extends Control3D {
  81465. private _blockLayout;
  81466. /**
  81467. * Gets the list of child controls
  81468. */
  81469. protected _children: Control3D[];
  81470. /**
  81471. * Gets the list of child controls
  81472. */
  81473. get children(): Array<Control3D>;
  81474. /**
  81475. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81476. * This is helpful to optimize layout operation when adding multiple children in a row
  81477. */
  81478. get blockLayout(): boolean;
  81479. set blockLayout(value: boolean);
  81480. /**
  81481. * Creates a new container
  81482. * @param name defines the container name
  81483. */
  81484. constructor(name?: string);
  81485. /**
  81486. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81487. * @returns the current container
  81488. */
  81489. updateLayout(): Container3D;
  81490. /**
  81491. * Gets a boolean indicating if the given control is in the children of this control
  81492. * @param control defines the control to check
  81493. * @returns true if the control is in the child list
  81494. */
  81495. containsControl(control: Control3D): boolean;
  81496. /**
  81497. * Adds a control to the children of this control
  81498. * @param control defines the control to add
  81499. * @returns the current container
  81500. */
  81501. addControl(control: Control3D): Container3D;
  81502. /**
  81503. * This function will be called everytime a new control is added
  81504. */
  81505. protected _arrangeChildren(): void;
  81506. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81507. /**
  81508. * Removes a control from the children of this control
  81509. * @param control defines the control to remove
  81510. * @returns the current container
  81511. */
  81512. removeControl(control: Control3D): Container3D;
  81513. protected _getTypeName(): string;
  81514. /**
  81515. * Releases all associated resources
  81516. */
  81517. dispose(): void;
  81518. /** Control rotation will remain unchanged */
  81519. static readonly UNSET_ORIENTATION: number;
  81520. /** Control will rotate to make it look at sphere central axis */
  81521. static readonly FACEORIGIN_ORIENTATION: number;
  81522. /** Control will rotate to make it look back at sphere central axis */
  81523. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81524. /** Control will rotate to look at z axis (0, 0, 1) */
  81525. static readonly FACEFORWARD_ORIENTATION: number;
  81526. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81527. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81528. }
  81529. }
  81530. declare module BABYLON.GUI {
  81531. /**
  81532. * Class used to manage 3D user interface
  81533. * @see https://doc.babylonjs.com/how_to/gui3d
  81534. */
  81535. export class GUI3DManager implements BABYLON.IDisposable {
  81536. private _scene;
  81537. private _sceneDisposeObserver;
  81538. private _utilityLayer;
  81539. private _rootContainer;
  81540. private _pointerObserver;
  81541. private _pointerOutObserver;
  81542. /** @hidden */
  81543. _lastPickedControl: Control3D;
  81544. /** @hidden */
  81545. _lastControlOver: {
  81546. [pointerId: number]: Control3D;
  81547. };
  81548. /** @hidden */
  81549. _lastControlDown: {
  81550. [pointerId: number]: Control3D;
  81551. };
  81552. /**
  81553. * BABYLON.Observable raised when the point picked by the pointer events changed
  81554. */
  81555. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81556. /** @hidden */
  81557. _sharedMaterials: {
  81558. [key: string]: BABYLON.Material;
  81559. };
  81560. /** Gets the hosting scene */
  81561. get scene(): BABYLON.Scene;
  81562. /** Gets associated utility layer */
  81563. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81564. /**
  81565. * Creates a new GUI3DManager
  81566. * @param scene
  81567. */
  81568. constructor(scene?: BABYLON.Scene);
  81569. private _handlePointerOut;
  81570. private _doPicking;
  81571. /**
  81572. * Gets the root container
  81573. */
  81574. get rootContainer(): Container3D;
  81575. /**
  81576. * Gets a boolean indicating if the given control is in the root child list
  81577. * @param control defines the control to check
  81578. * @returns true if the control is in the root child list
  81579. */
  81580. containsControl(control: Control3D): boolean;
  81581. /**
  81582. * Adds a control to the root child list
  81583. * @param control defines the control to add
  81584. * @returns the current manager
  81585. */
  81586. addControl(control: Control3D): GUI3DManager;
  81587. /**
  81588. * Removes a control from the root child list
  81589. * @param control defines the control to remove
  81590. * @returns the current container
  81591. */
  81592. removeControl(control: Control3D): GUI3DManager;
  81593. /**
  81594. * Releases all associated resources
  81595. */
  81596. dispose(): void;
  81597. }
  81598. }
  81599. declare module BABYLON.GUI {
  81600. /**
  81601. * Class used to transport BABYLON.Vector3 information for pointer events
  81602. */
  81603. export class Vector3WithInfo extends BABYLON.Vector3 {
  81604. /** defines the current mouse button index */
  81605. buttonIndex: number;
  81606. /**
  81607. * Creates a new Vector3WithInfo
  81608. * @param source defines the vector3 data to transport
  81609. * @param buttonIndex defines the current mouse button index
  81610. */
  81611. constructor(source: BABYLON.Vector3,
  81612. /** defines the current mouse button index */
  81613. buttonIndex?: number);
  81614. }
  81615. }
  81616. declare module BABYLON.GUI {
  81617. /**
  81618. * Class used as base class for controls
  81619. */
  81620. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81621. /** Defines the control name */
  81622. name?: string | undefined;
  81623. /** @hidden */
  81624. _host: GUI3DManager;
  81625. private _node;
  81626. private _downCount;
  81627. private _enterCount;
  81628. private _downPointerIds;
  81629. private _isVisible;
  81630. /** Gets or sets the control position in world space */
  81631. get position(): BABYLON.Vector3;
  81632. set position(value: BABYLON.Vector3);
  81633. /** Gets or sets the control scaling in world space */
  81634. get scaling(): BABYLON.Vector3;
  81635. set scaling(value: BABYLON.Vector3);
  81636. /** Callback used to start pointer enter animation */
  81637. pointerEnterAnimation: () => void;
  81638. /** Callback used to start pointer out animation */
  81639. pointerOutAnimation: () => void;
  81640. /** Callback used to start pointer down animation */
  81641. pointerDownAnimation: () => void;
  81642. /** Callback used to start pointer up animation */
  81643. pointerUpAnimation: () => void;
  81644. /**
  81645. * An event triggered when the pointer move over the control
  81646. */
  81647. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81648. /**
  81649. * An event triggered when the pointer move out of the control
  81650. */
  81651. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81652. /**
  81653. * An event triggered when the pointer taps the control
  81654. */
  81655. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81656. /**
  81657. * An event triggered when pointer is up
  81658. */
  81659. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81660. /**
  81661. * An event triggered when a control is clicked on (with a mouse)
  81662. */
  81663. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81664. /**
  81665. * An event triggered when pointer enters the control
  81666. */
  81667. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81668. /**
  81669. * Gets or sets the parent container
  81670. */
  81671. parent: BABYLON.Nullable<Container3D>;
  81672. private _behaviors;
  81673. /**
  81674. * Gets the list of attached behaviors
  81675. * @see https://doc.babylonjs.com/features/behaviour
  81676. */
  81677. get behaviors(): BABYLON.Behavior<Control3D>[];
  81678. /**
  81679. * Attach a behavior to the control
  81680. * @see https://doc.babylonjs.com/features/behaviour
  81681. * @param behavior defines the behavior to attach
  81682. * @returns the current control
  81683. */
  81684. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81685. /**
  81686. * Remove an attached behavior
  81687. * @see https://doc.babylonjs.com/features/behaviour
  81688. * @param behavior defines the behavior to attach
  81689. * @returns the current control
  81690. */
  81691. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81692. /**
  81693. * Gets an attached behavior by name
  81694. * @param name defines the name of the behavior to look for
  81695. * @see https://doc.babylonjs.com/features/behaviour
  81696. * @returns null if behavior was not found else the requested behavior
  81697. */
  81698. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81699. /** Gets or sets a boolean indicating if the control is visible */
  81700. get isVisible(): boolean;
  81701. set isVisible(value: boolean);
  81702. /**
  81703. * Creates a new control
  81704. * @param name defines the control name
  81705. */
  81706. constructor(
  81707. /** Defines the control name */
  81708. name?: string | undefined);
  81709. /**
  81710. * Gets a string representing the class name
  81711. */
  81712. get typeName(): string;
  81713. /**
  81714. * Get the current class name of the control.
  81715. * @returns current class name
  81716. */
  81717. getClassName(): string;
  81718. protected _getTypeName(): string;
  81719. /**
  81720. * Gets the transform node used by this control
  81721. */
  81722. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81723. /**
  81724. * Gets the mesh used to render this control
  81725. */
  81726. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81727. /**
  81728. * Link the control as child of the given node
  81729. * @param node defines the node to link to. Use null to unlink the control
  81730. * @returns the current control
  81731. */
  81732. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81733. /** @hidden **/
  81734. _prepareNode(scene: BABYLON.Scene): void;
  81735. /**
  81736. * Node creation.
  81737. * Can be overriden by children
  81738. * @param scene defines the scene where the node must be attached
  81739. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81740. */
  81741. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81742. /**
  81743. * Affect a material to the given mesh
  81744. * @param mesh defines the mesh which will represent the control
  81745. */
  81746. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81747. /** @hidden */
  81748. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81749. /** @hidden */
  81750. _onPointerEnter(target: Control3D): boolean;
  81751. /** @hidden */
  81752. _onPointerOut(target: Control3D): void;
  81753. /** @hidden */
  81754. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81755. /** @hidden */
  81756. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81757. /** @hidden */
  81758. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81759. /** @hidden */
  81760. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81761. /** @hidden */
  81762. _disposeNode(): void;
  81763. /**
  81764. * Releases all associated resources
  81765. */
  81766. dispose(): void;
  81767. }
  81768. }
  81769. declare module BABYLON.GUI {
  81770. /**
  81771. * Class used as a root to all buttons
  81772. */
  81773. export class AbstractButton3D extends Control3D {
  81774. /**
  81775. * Creates a new button
  81776. * @param name defines the control name
  81777. */
  81778. constructor(name?: string);
  81779. protected _getTypeName(): string;
  81780. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81781. }
  81782. }
  81783. declare module BABYLON.GUI {
  81784. /**
  81785. * Class used to create a button in 3D
  81786. */
  81787. export class Button3D extends AbstractButton3D {
  81788. /** @hidden */
  81789. protected _currentMaterial: BABYLON.Material;
  81790. private _facadeTexture;
  81791. private _content;
  81792. private _contentResolution;
  81793. private _contentScaleRatio;
  81794. /**
  81795. * Gets or sets the texture resolution used to render content (512 by default)
  81796. */
  81797. get contentResolution(): BABYLON.int;
  81798. set contentResolution(value: BABYLON.int);
  81799. /**
  81800. * Gets or sets the texture scale ratio used to render content (2 by default)
  81801. */
  81802. get contentScaleRatio(): number;
  81803. set contentScaleRatio(value: number);
  81804. protected _disposeFacadeTexture(): void;
  81805. protected _resetContent(): void;
  81806. /**
  81807. * Creates a new button
  81808. * @param name defines the control name
  81809. */
  81810. constructor(name?: string);
  81811. /**
  81812. * Gets or sets the GUI 2D content used to display the button's facade
  81813. */
  81814. get content(): Control;
  81815. set content(value: Control);
  81816. /**
  81817. * Apply the facade texture (created from the content property).
  81818. * This function can be overloaded by child classes
  81819. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81820. */
  81821. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81822. protected _getTypeName(): string;
  81823. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81824. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81825. /**
  81826. * Releases all associated resources
  81827. */
  81828. dispose(): void;
  81829. }
  81830. }
  81831. declare module BABYLON.GUI {
  81832. /**
  81833. * Abstract class used to create a container panel deployed on the surface of a volume
  81834. */
  81835. export abstract class VolumeBasedPanel extends Container3D {
  81836. private _columns;
  81837. private _rows;
  81838. private _rowThenColum;
  81839. private _orientation;
  81840. protected _cellWidth: number;
  81841. protected _cellHeight: number;
  81842. /**
  81843. * Gets or sets the distance between elements
  81844. */
  81845. margin: number;
  81846. /**
  81847. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81848. * | Value | Type | Description |
  81849. * | ----- | ----------------------------------- | ----------- |
  81850. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81851. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81852. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81853. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81854. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81855. */
  81856. get orientation(): number;
  81857. set orientation(value: number);
  81858. /**
  81859. * Gets or sets the number of columns requested (10 by default).
  81860. * The panel will automatically compute the number of rows based on number of child controls.
  81861. */
  81862. get columns(): BABYLON.int;
  81863. set columns(value: BABYLON.int);
  81864. /**
  81865. * Gets or sets a the number of rows requested.
  81866. * The panel will automatically compute the number of columns based on number of child controls.
  81867. */
  81868. get rows(): BABYLON.int;
  81869. set rows(value: BABYLON.int);
  81870. /**
  81871. * Creates new VolumeBasedPanel
  81872. */
  81873. constructor();
  81874. protected _arrangeChildren(): void;
  81875. /** Child classes must implement this function to provide correct control positioning */
  81876. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81877. /** Child classes can implement this function to provide additional processing */
  81878. protected _finalProcessing(): void;
  81879. }
  81880. }
  81881. declare module BABYLON.GUI {
  81882. /**
  81883. * Class used to create a container panel deployed on the surface of a cylinder
  81884. */
  81885. export class CylinderPanel extends VolumeBasedPanel {
  81886. private _radius;
  81887. /**
  81888. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81889. */
  81890. get radius(): BABYLON.float;
  81891. set radius(value: BABYLON.float);
  81892. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81893. private _cylindricalMapping;
  81894. }
  81895. }
  81896. declare module BABYLON.GUI {
  81897. /** @hidden */
  81898. export var fluentVertexShader: {
  81899. name: string;
  81900. shader: string;
  81901. };
  81902. }
  81903. declare module BABYLON.GUI {
  81904. /** @hidden */
  81905. export var fluentPixelShader: {
  81906. name: string;
  81907. shader: string;
  81908. };
  81909. }
  81910. declare module BABYLON.GUI {
  81911. /** @hidden */
  81912. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81913. INNERGLOW: boolean;
  81914. BORDER: boolean;
  81915. HOVERLIGHT: boolean;
  81916. TEXTURE: boolean;
  81917. constructor();
  81918. }
  81919. /**
  81920. * Class used to render controls with fluent desgin
  81921. */
  81922. export class FluentMaterial extends BABYLON.PushMaterial {
  81923. /**
  81924. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81925. */
  81926. innerGlowColorIntensity: number;
  81927. /**
  81928. * Gets or sets the inner glow color (white by default)
  81929. */
  81930. innerGlowColor: BABYLON.Color3;
  81931. /**
  81932. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81933. */
  81934. albedoColor: BABYLON.Color3;
  81935. /**
  81936. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81937. */
  81938. renderBorders: boolean;
  81939. /**
  81940. * Gets or sets border width (default is 0.5)
  81941. */
  81942. borderWidth: number;
  81943. /**
  81944. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81945. */
  81946. edgeSmoothingValue: number;
  81947. /**
  81948. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81949. */
  81950. borderMinValue: number;
  81951. /**
  81952. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81953. */
  81954. renderHoverLight: boolean;
  81955. /**
  81956. * Gets or sets the radius used to render the hover light (default is 1.0)
  81957. */
  81958. hoverRadius: number;
  81959. /**
  81960. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81961. */
  81962. hoverColor: BABYLON.Color4;
  81963. /**
  81964. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81965. */
  81966. hoverPosition: BABYLON.Vector3;
  81967. private _albedoTexture;
  81968. /** Gets or sets the texture to use for albedo color */
  81969. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81970. /**
  81971. * Creates a new Fluent material
  81972. * @param name defines the name of the material
  81973. * @param scene defines the hosting scene
  81974. */
  81975. constructor(name: string, scene: BABYLON.Scene);
  81976. needAlphaBlending(): boolean;
  81977. needAlphaTesting(): boolean;
  81978. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81979. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81980. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81981. getActiveTextures(): BABYLON.BaseTexture[];
  81982. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81983. dispose(forceDisposeEffect?: boolean): void;
  81984. clone(name: string): FluentMaterial;
  81985. serialize(): any;
  81986. getClassName(): string;
  81987. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81988. }
  81989. }
  81990. declare module BABYLON.GUI {
  81991. /**
  81992. * Class used to create a holographic button in 3D
  81993. */
  81994. export class HolographicButton extends Button3D {
  81995. private _backPlate;
  81996. private _textPlate;
  81997. private _frontPlate;
  81998. private _text;
  81999. private _imageUrl;
  82000. private _shareMaterials;
  82001. private _frontMaterial;
  82002. private _backMaterial;
  82003. private _plateMaterial;
  82004. private _pickedPointObserver;
  82005. private _tooltipFade;
  82006. private _tooltipTextBlock;
  82007. private _tooltipTexture;
  82008. private _tooltipMesh;
  82009. private _tooltipHoverObserver;
  82010. private _tooltipOutObserver;
  82011. private _disposeTooltip;
  82012. /**
  82013. * Rendering ground id of all the mesh in the button
  82014. */
  82015. set renderingGroupId(id: number);
  82016. get renderingGroupId(): number;
  82017. /**
  82018. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  82019. */
  82020. set tooltipText(text: BABYLON.Nullable<string>);
  82021. get tooltipText(): BABYLON.Nullable<string>;
  82022. /**
  82023. * Gets or sets text for the button
  82024. */
  82025. get text(): string;
  82026. set text(value: string);
  82027. /**
  82028. * Gets or sets the image url for the button
  82029. */
  82030. get imageUrl(): string;
  82031. set imageUrl(value: string);
  82032. /**
  82033. * Gets the back material used by this button
  82034. */
  82035. get backMaterial(): FluentMaterial;
  82036. /**
  82037. * Gets the front material used by this button
  82038. */
  82039. get frontMaterial(): FluentMaterial;
  82040. /**
  82041. * Gets the plate material used by this button
  82042. */
  82043. get plateMaterial(): BABYLON.StandardMaterial;
  82044. /**
  82045. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  82046. */
  82047. get shareMaterials(): boolean;
  82048. /**
  82049. * Creates a new button
  82050. * @param name defines the control name
  82051. */
  82052. constructor(name?: string, shareMaterials?: boolean);
  82053. protected _getTypeName(): string;
  82054. private _rebuildContent;
  82055. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82056. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82057. private _createBackMaterial;
  82058. private _createFrontMaterial;
  82059. private _createPlateMaterial;
  82060. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82061. /**
  82062. * Releases all associated resources
  82063. */
  82064. dispose(): void;
  82065. }
  82066. }
  82067. declare module BABYLON.GUI {
  82068. /**
  82069. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82070. */
  82071. export class MeshButton3D extends Button3D {
  82072. /** @hidden */
  82073. protected _currentMesh: BABYLON.Mesh;
  82074. /**
  82075. * Creates a new 3D button based on a mesh
  82076. * @param mesh mesh to become a 3D button
  82077. * @param name defines the control name
  82078. */
  82079. constructor(mesh: BABYLON.Mesh, name?: string);
  82080. protected _getTypeName(): string;
  82081. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82082. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82083. }
  82084. }
  82085. declare module BABYLON.GUI {
  82086. /**
  82087. * Class used to create a container panel deployed on the surface of a plane
  82088. */
  82089. export class PlanePanel extends VolumeBasedPanel {
  82090. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82091. }
  82092. }
  82093. declare module BABYLON.GUI {
  82094. /**
  82095. * Class used to create a container panel where items get randomized planar mapping
  82096. */
  82097. export class ScatterPanel extends VolumeBasedPanel {
  82098. private _iteration;
  82099. /**
  82100. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82101. */
  82102. get iteration(): BABYLON.float;
  82103. set iteration(value: BABYLON.float);
  82104. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82105. private _scatterMapping;
  82106. protected _finalProcessing(): void;
  82107. }
  82108. }
  82109. declare module BABYLON.GUI {
  82110. /**
  82111. * Class used to create a container panel deployed on the surface of a sphere
  82112. */
  82113. export class SpherePanel extends VolumeBasedPanel {
  82114. private _radius;
  82115. /**
  82116. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82117. */
  82118. get radius(): BABYLON.float;
  82119. set radius(value: BABYLON.float);
  82120. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82121. private _sphericalMapping;
  82122. }
  82123. }
  82124. declare module BABYLON.GUI {
  82125. /**
  82126. * Class used to create a stack panel in 3D on XY plane
  82127. */
  82128. export class StackPanel3D extends Container3D {
  82129. private _isVertical;
  82130. /**
  82131. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82132. */
  82133. get isVertical(): boolean;
  82134. set isVertical(value: boolean);
  82135. /**
  82136. * Gets or sets the distance between elements
  82137. */
  82138. margin: number;
  82139. /**
  82140. * Creates new StackPanel
  82141. * @param isVertical
  82142. */
  82143. constructor(isVertical?: boolean);
  82144. protected _arrangeChildren(): void;
  82145. }
  82146. }
  82147. declare module BABYLON {
  82148. /**
  82149. * Configuration for glTF validation
  82150. */
  82151. export interface IGLTFValidationConfiguration {
  82152. /**
  82153. * The url of the glTF validator.
  82154. */
  82155. url: string;
  82156. }
  82157. /**
  82158. * glTF validation
  82159. */
  82160. export class GLTFValidation {
  82161. /**
  82162. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82163. */
  82164. static Configuration: IGLTFValidationConfiguration;
  82165. private static _LoadScriptPromise;
  82166. /**
  82167. * Validate a glTF asset using the glTF-Validator.
  82168. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82169. * @param rootUrl The root url for the glTF
  82170. * @param fileName The file name for the glTF
  82171. * @param getExternalResource The callback to get external resources for the glTF validator
  82172. * @returns A promise that resolves with the glTF validation results once complete
  82173. */
  82174. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82175. }
  82176. }
  82177. declare module BABYLON {
  82178. /**
  82179. * Mode that determines the coordinate system to use.
  82180. */
  82181. export enum GLTFLoaderCoordinateSystemMode {
  82182. /**
  82183. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82184. */
  82185. AUTO = 0,
  82186. /**
  82187. * Sets the useRightHandedSystem flag on the scene.
  82188. */
  82189. FORCE_RIGHT_HANDED = 1
  82190. }
  82191. /**
  82192. * Mode that determines what animations will start.
  82193. */
  82194. export enum GLTFLoaderAnimationStartMode {
  82195. /**
  82196. * No animation will start.
  82197. */
  82198. NONE = 0,
  82199. /**
  82200. * The first animation will start.
  82201. */
  82202. FIRST = 1,
  82203. /**
  82204. * All animations will start.
  82205. */
  82206. ALL = 2
  82207. }
  82208. /**
  82209. * Interface that contains the data for the glTF asset.
  82210. */
  82211. export interface IGLTFLoaderData {
  82212. /**
  82213. * The object that represents the glTF JSON.
  82214. */
  82215. json: Object;
  82216. /**
  82217. * The BIN chunk of a binary glTF.
  82218. */
  82219. bin: Nullable<IDataBuffer>;
  82220. }
  82221. /**
  82222. * Interface for extending the loader.
  82223. */
  82224. export interface IGLTFLoaderExtension {
  82225. /**
  82226. * The name of this extension.
  82227. */
  82228. readonly name: string;
  82229. /**
  82230. * Defines whether this extension is enabled.
  82231. */
  82232. enabled: boolean;
  82233. /**
  82234. * Defines the order of this extension.
  82235. * The loader sorts the extensions using these values when loading.
  82236. */
  82237. order?: number;
  82238. }
  82239. /**
  82240. * Loader state.
  82241. */
  82242. export enum GLTFLoaderState {
  82243. /**
  82244. * The asset is loading.
  82245. */
  82246. LOADING = 0,
  82247. /**
  82248. * The asset is ready for rendering.
  82249. */
  82250. READY = 1,
  82251. /**
  82252. * The asset is completely loaded.
  82253. */
  82254. COMPLETE = 2
  82255. }
  82256. /** @hidden */
  82257. export interface IGLTFLoader extends IDisposable {
  82258. readonly state: Nullable<GLTFLoaderState>;
  82259. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82260. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82261. }
  82262. /**
  82263. * File loader for loading glTF files into a scene.
  82264. */
  82265. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82266. /** @hidden */
  82267. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82268. /** @hidden */
  82269. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82270. /**
  82271. * Raised when the asset has been parsed
  82272. */
  82273. onParsedObservable: Observable<IGLTFLoaderData>;
  82274. private _onParsedObserver;
  82275. /**
  82276. * Raised when the asset has been parsed
  82277. */
  82278. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82279. /**
  82280. * 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.
  82281. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82282. * Defaults to true.
  82283. * @hidden
  82284. */
  82285. static IncrementalLoading: boolean;
  82286. /**
  82287. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82288. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82289. * @hidden
  82290. */
  82291. static HomogeneousCoordinates: boolean;
  82292. /**
  82293. * The coordinate system mode. Defaults to AUTO.
  82294. */
  82295. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82296. /**
  82297. * The animation start mode. Defaults to FIRST.
  82298. */
  82299. animationStartMode: GLTFLoaderAnimationStartMode;
  82300. /**
  82301. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82302. */
  82303. compileMaterials: boolean;
  82304. /**
  82305. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82306. */
  82307. useClipPlane: boolean;
  82308. /**
  82309. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82310. */
  82311. compileShadowGenerators: boolean;
  82312. /**
  82313. * Defines if the Alpha blended materials are only applied as coverage.
  82314. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82315. * If true, no extra effects are applied to transparent pixels.
  82316. */
  82317. transparencyAsCoverage: boolean;
  82318. /**
  82319. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82320. * Enabling will disable offline support and glTF validator.
  82321. * Defaults to false.
  82322. */
  82323. useRangeRequests: boolean;
  82324. /**
  82325. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82326. */
  82327. createInstances: boolean;
  82328. /**
  82329. * 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.
  82330. */
  82331. alwaysComputeBoundingBox: boolean;
  82332. /**
  82333. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82334. */
  82335. loadAllMaterials: boolean;
  82336. /**
  82337. * Function called before loading a url referenced by the asset.
  82338. */
  82339. preprocessUrlAsync: (url: string) => Promise<string>;
  82340. /**
  82341. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82342. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82343. */
  82344. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82345. private _onMeshLoadedObserver;
  82346. /**
  82347. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82348. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  82349. */
  82350. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82351. /**
  82352. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82353. */
  82354. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82355. private _onTextureLoadedObserver;
  82356. /**
  82357. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82358. */
  82359. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82360. /**
  82361. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82362. */
  82363. readonly onMaterialLoadedObservable: Observable<Material>;
  82364. private _onMaterialLoadedObserver;
  82365. /**
  82366. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82367. */
  82368. set onMaterialLoaded(callback: (material: Material) => void);
  82369. /**
  82370. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82371. */
  82372. readonly onCameraLoadedObservable: Observable<Camera>;
  82373. private _onCameraLoadedObserver;
  82374. /**
  82375. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82376. */
  82377. set onCameraLoaded(callback: (camera: Camera) => void);
  82378. /**
  82379. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82380. * For assets with LODs, raised when all of the LODs are complete.
  82381. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82382. */
  82383. readonly onCompleteObservable: Observable<void>;
  82384. private _onCompleteObserver;
  82385. /**
  82386. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82387. * For assets with LODs, raised when all of the LODs are complete.
  82388. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82389. */
  82390. set onComplete(callback: () => void);
  82391. /**
  82392. * Observable raised when an error occurs.
  82393. */
  82394. readonly onErrorObservable: Observable<any>;
  82395. private _onErrorObserver;
  82396. /**
  82397. * Callback raised when an error occurs.
  82398. */
  82399. set onError(callback: (reason: any) => void);
  82400. /**
  82401. * Observable raised after the loader is disposed.
  82402. */
  82403. readonly onDisposeObservable: Observable<void>;
  82404. private _onDisposeObserver;
  82405. /**
  82406. * Callback raised after the loader is disposed.
  82407. */
  82408. set onDispose(callback: () => void);
  82409. /**
  82410. * Observable raised after a loader extension is created.
  82411. * Set additional options for a loader extension in this event.
  82412. */
  82413. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82414. private _onExtensionLoadedObserver;
  82415. /**
  82416. * Callback raised after a loader extension is created.
  82417. */
  82418. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82419. /**
  82420. * Defines if the loader logging is enabled.
  82421. */
  82422. get loggingEnabled(): boolean;
  82423. set loggingEnabled(value: boolean);
  82424. /**
  82425. * Defines if the loader should capture performance counters.
  82426. */
  82427. get capturePerformanceCounters(): boolean;
  82428. set capturePerformanceCounters(value: boolean);
  82429. /**
  82430. * Defines if the loader should validate the asset.
  82431. */
  82432. validate: boolean;
  82433. /**
  82434. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82435. */
  82436. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82437. private _onValidatedObserver;
  82438. /**
  82439. * Callback raised after a loader extension is created.
  82440. */
  82441. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82442. private _loader;
  82443. private _progressCallback?;
  82444. private _requests;
  82445. private static magicBase64Encoded;
  82446. /**
  82447. * Name of the loader ("gltf")
  82448. */
  82449. name: string;
  82450. /** @hidden */
  82451. extensions: ISceneLoaderPluginExtensions;
  82452. /**
  82453. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82454. */
  82455. dispose(): void;
  82456. /** @hidden */
  82457. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82458. /** @hidden */
  82459. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82460. /** @hidden */
  82461. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82462. /** @hidden */
  82463. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82464. /** @hidden */
  82465. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82466. /** @hidden */
  82467. canDirectLoad(data: string): boolean;
  82468. /** @hidden */
  82469. directLoad(scene: Scene, data: string): Promise<any>;
  82470. /**
  82471. * The callback that allows custom handling of the root url based on the response url.
  82472. * @param rootUrl the original root url
  82473. * @param responseURL the response url if available
  82474. * @returns the new root url
  82475. */
  82476. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82477. /** @hidden */
  82478. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82479. /**
  82480. * The loader state or null if the loader is not active.
  82481. */
  82482. get loaderState(): Nullable<GLTFLoaderState>;
  82483. /**
  82484. * Returns a promise that resolves when the asset is completely loaded.
  82485. * @returns a promise that resolves when the asset is completely loaded.
  82486. */
  82487. whenCompleteAsync(): Promise<void>;
  82488. /** @hidden */
  82489. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82490. /** @hidden */
  82491. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82492. private _onProgress;
  82493. private _validate;
  82494. private _getLoader;
  82495. private _parseJson;
  82496. private _unpackBinaryAsync;
  82497. private _unpackBinaryV1Async;
  82498. private _unpackBinaryV2Async;
  82499. private static _parseVersion;
  82500. private static _compareVersion;
  82501. private static readonly _logSpaces;
  82502. private _logIndentLevel;
  82503. private _loggingEnabled;
  82504. /** @hidden */
  82505. _log: (message: string) => void;
  82506. /** @hidden */
  82507. _logOpen(message: string): void;
  82508. /** @hidden */
  82509. _logClose(): void;
  82510. private _logEnabled;
  82511. private _logDisabled;
  82512. private _capturePerformanceCounters;
  82513. /** @hidden */
  82514. _startPerformanceCounter: (counterName: string) => void;
  82515. /** @hidden */
  82516. _endPerformanceCounter: (counterName: string) => void;
  82517. private _startPerformanceCounterEnabled;
  82518. private _startPerformanceCounterDisabled;
  82519. private _endPerformanceCounterEnabled;
  82520. private _endPerformanceCounterDisabled;
  82521. }
  82522. }
  82523. declare module BABYLON.GLTF1 {
  82524. /**
  82525. * Enums
  82526. * @hidden
  82527. */
  82528. export enum EComponentType {
  82529. BYTE = 5120,
  82530. UNSIGNED_BYTE = 5121,
  82531. SHORT = 5122,
  82532. UNSIGNED_SHORT = 5123,
  82533. FLOAT = 5126
  82534. }
  82535. /** @hidden */
  82536. export enum EShaderType {
  82537. FRAGMENT = 35632,
  82538. VERTEX = 35633
  82539. }
  82540. /** @hidden */
  82541. export enum EParameterType {
  82542. BYTE = 5120,
  82543. UNSIGNED_BYTE = 5121,
  82544. SHORT = 5122,
  82545. UNSIGNED_SHORT = 5123,
  82546. INT = 5124,
  82547. UNSIGNED_INT = 5125,
  82548. FLOAT = 5126,
  82549. FLOAT_VEC2 = 35664,
  82550. FLOAT_VEC3 = 35665,
  82551. FLOAT_VEC4 = 35666,
  82552. INT_VEC2 = 35667,
  82553. INT_VEC3 = 35668,
  82554. INT_VEC4 = 35669,
  82555. BOOL = 35670,
  82556. BOOL_VEC2 = 35671,
  82557. BOOL_VEC3 = 35672,
  82558. BOOL_VEC4 = 35673,
  82559. FLOAT_MAT2 = 35674,
  82560. FLOAT_MAT3 = 35675,
  82561. FLOAT_MAT4 = 35676,
  82562. SAMPLER_2D = 35678
  82563. }
  82564. /** @hidden */
  82565. export enum ETextureWrapMode {
  82566. CLAMP_TO_EDGE = 33071,
  82567. MIRRORED_REPEAT = 33648,
  82568. REPEAT = 10497
  82569. }
  82570. /** @hidden */
  82571. export enum ETextureFilterType {
  82572. NEAREST = 9728,
  82573. LINEAR = 9728,
  82574. NEAREST_MIPMAP_NEAREST = 9984,
  82575. LINEAR_MIPMAP_NEAREST = 9985,
  82576. NEAREST_MIPMAP_LINEAR = 9986,
  82577. LINEAR_MIPMAP_LINEAR = 9987
  82578. }
  82579. /** @hidden */
  82580. export enum ETextureFormat {
  82581. ALPHA = 6406,
  82582. RGB = 6407,
  82583. RGBA = 6408,
  82584. LUMINANCE = 6409,
  82585. LUMINANCE_ALPHA = 6410
  82586. }
  82587. /** @hidden */
  82588. export enum ECullingType {
  82589. FRONT = 1028,
  82590. BACK = 1029,
  82591. FRONT_AND_BACK = 1032
  82592. }
  82593. /** @hidden */
  82594. export enum EBlendingFunction {
  82595. ZERO = 0,
  82596. ONE = 1,
  82597. SRC_COLOR = 768,
  82598. ONE_MINUS_SRC_COLOR = 769,
  82599. DST_COLOR = 774,
  82600. ONE_MINUS_DST_COLOR = 775,
  82601. SRC_ALPHA = 770,
  82602. ONE_MINUS_SRC_ALPHA = 771,
  82603. DST_ALPHA = 772,
  82604. ONE_MINUS_DST_ALPHA = 773,
  82605. CONSTANT_COLOR = 32769,
  82606. ONE_MINUS_CONSTANT_COLOR = 32770,
  82607. CONSTANT_ALPHA = 32771,
  82608. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82609. SRC_ALPHA_SATURATE = 776
  82610. }
  82611. /** @hidden */
  82612. export interface IGLTFProperty {
  82613. extensions?: {
  82614. [key: string]: any;
  82615. };
  82616. extras?: Object;
  82617. }
  82618. /** @hidden */
  82619. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82620. name?: string;
  82621. }
  82622. /** @hidden */
  82623. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82624. bufferView: string;
  82625. byteOffset: number;
  82626. byteStride: number;
  82627. count: number;
  82628. type: string;
  82629. componentType: EComponentType;
  82630. max?: number[];
  82631. min?: number[];
  82632. name?: string;
  82633. }
  82634. /** @hidden */
  82635. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82636. buffer: string;
  82637. byteOffset: number;
  82638. byteLength: number;
  82639. byteStride: number;
  82640. target?: number;
  82641. }
  82642. /** @hidden */
  82643. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82644. uri: string;
  82645. byteLength?: number;
  82646. type?: string;
  82647. }
  82648. /** @hidden */
  82649. export interface IGLTFShader extends IGLTFChildRootProperty {
  82650. uri: string;
  82651. type: EShaderType;
  82652. }
  82653. /** @hidden */
  82654. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82655. attributes: string[];
  82656. fragmentShader: string;
  82657. vertexShader: string;
  82658. }
  82659. /** @hidden */
  82660. export interface IGLTFTechniqueParameter {
  82661. type: number;
  82662. count?: number;
  82663. semantic?: string;
  82664. node?: string;
  82665. value?: number | boolean | string | Array<any>;
  82666. source?: string;
  82667. babylonValue?: any;
  82668. }
  82669. /** @hidden */
  82670. export interface IGLTFTechniqueCommonProfile {
  82671. lightingModel: string;
  82672. texcoordBindings: Object;
  82673. parameters?: Array<any>;
  82674. }
  82675. /** @hidden */
  82676. export interface IGLTFTechniqueStatesFunctions {
  82677. blendColor?: number[];
  82678. blendEquationSeparate?: number[];
  82679. blendFuncSeparate?: number[];
  82680. colorMask: boolean[];
  82681. cullFace: number[];
  82682. }
  82683. /** @hidden */
  82684. export interface IGLTFTechniqueStates {
  82685. enable: number[];
  82686. functions: IGLTFTechniqueStatesFunctions;
  82687. }
  82688. /** @hidden */
  82689. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82690. parameters: {
  82691. [key: string]: IGLTFTechniqueParameter;
  82692. };
  82693. program: string;
  82694. attributes: {
  82695. [key: string]: string;
  82696. };
  82697. uniforms: {
  82698. [key: string]: string;
  82699. };
  82700. states: IGLTFTechniqueStates;
  82701. }
  82702. /** @hidden */
  82703. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82704. technique?: string;
  82705. values: string[];
  82706. }
  82707. /** @hidden */
  82708. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82709. attributes: {
  82710. [key: string]: string;
  82711. };
  82712. indices: string;
  82713. material: string;
  82714. mode?: number;
  82715. }
  82716. /** @hidden */
  82717. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82718. primitives: IGLTFMeshPrimitive[];
  82719. }
  82720. /** @hidden */
  82721. export interface IGLTFImage extends IGLTFChildRootProperty {
  82722. uri: string;
  82723. }
  82724. /** @hidden */
  82725. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82726. magFilter?: number;
  82727. minFilter?: number;
  82728. wrapS?: number;
  82729. wrapT?: number;
  82730. }
  82731. /** @hidden */
  82732. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82733. sampler: string;
  82734. source: string;
  82735. format?: ETextureFormat;
  82736. internalFormat?: ETextureFormat;
  82737. target?: number;
  82738. type?: number;
  82739. babylonTexture?: Texture;
  82740. }
  82741. /** @hidden */
  82742. export interface IGLTFAmbienLight {
  82743. color?: number[];
  82744. }
  82745. /** @hidden */
  82746. export interface IGLTFDirectionalLight {
  82747. color?: number[];
  82748. }
  82749. /** @hidden */
  82750. export interface IGLTFPointLight {
  82751. color?: number[];
  82752. constantAttenuation?: number;
  82753. linearAttenuation?: number;
  82754. quadraticAttenuation?: number;
  82755. }
  82756. /** @hidden */
  82757. export interface IGLTFSpotLight {
  82758. color?: number[];
  82759. constantAttenuation?: number;
  82760. fallOfAngle?: number;
  82761. fallOffExponent?: number;
  82762. linearAttenuation?: number;
  82763. quadraticAttenuation?: number;
  82764. }
  82765. /** @hidden */
  82766. export interface IGLTFLight extends IGLTFChildRootProperty {
  82767. type: string;
  82768. }
  82769. /** @hidden */
  82770. export interface IGLTFCameraOrthographic {
  82771. xmag: number;
  82772. ymag: number;
  82773. zfar: number;
  82774. znear: number;
  82775. }
  82776. /** @hidden */
  82777. export interface IGLTFCameraPerspective {
  82778. aspectRatio: number;
  82779. yfov: number;
  82780. zfar: number;
  82781. znear: number;
  82782. }
  82783. /** @hidden */
  82784. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82785. type: string;
  82786. }
  82787. /** @hidden */
  82788. export interface IGLTFAnimationChannelTarget {
  82789. id: string;
  82790. path: string;
  82791. }
  82792. /** @hidden */
  82793. export interface IGLTFAnimationChannel {
  82794. sampler: string;
  82795. target: IGLTFAnimationChannelTarget;
  82796. }
  82797. /** @hidden */
  82798. export interface IGLTFAnimationSampler {
  82799. input: string;
  82800. output: string;
  82801. interpolation?: string;
  82802. }
  82803. /** @hidden */
  82804. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82805. channels?: IGLTFAnimationChannel[];
  82806. parameters?: {
  82807. [key: string]: string;
  82808. };
  82809. samplers?: {
  82810. [key: string]: IGLTFAnimationSampler;
  82811. };
  82812. }
  82813. /** @hidden */
  82814. export interface IGLTFNodeInstanceSkin {
  82815. skeletons: string[];
  82816. skin: string;
  82817. meshes: string[];
  82818. }
  82819. /** @hidden */
  82820. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82821. bindShapeMatrix: number[];
  82822. inverseBindMatrices: string;
  82823. jointNames: string[];
  82824. babylonSkeleton?: Skeleton;
  82825. }
  82826. /** @hidden */
  82827. export interface IGLTFNode extends IGLTFChildRootProperty {
  82828. camera?: string;
  82829. children: string[];
  82830. skin?: string;
  82831. jointName?: string;
  82832. light?: string;
  82833. matrix: number[];
  82834. mesh?: string;
  82835. meshes?: string[];
  82836. rotation?: number[];
  82837. scale?: number[];
  82838. translation?: number[];
  82839. babylonNode?: Node;
  82840. }
  82841. /** @hidden */
  82842. export interface IGLTFScene extends IGLTFChildRootProperty {
  82843. nodes: string[];
  82844. }
  82845. /** @hidden */
  82846. export interface IGLTFRuntime {
  82847. extensions: {
  82848. [key: string]: any;
  82849. };
  82850. accessors: {
  82851. [key: string]: IGLTFAccessor;
  82852. };
  82853. buffers: {
  82854. [key: string]: IGLTFBuffer;
  82855. };
  82856. bufferViews: {
  82857. [key: string]: IGLTFBufferView;
  82858. };
  82859. meshes: {
  82860. [key: string]: IGLTFMesh;
  82861. };
  82862. lights: {
  82863. [key: string]: IGLTFLight;
  82864. };
  82865. cameras: {
  82866. [key: string]: IGLTFCamera;
  82867. };
  82868. nodes: {
  82869. [key: string]: IGLTFNode;
  82870. };
  82871. images: {
  82872. [key: string]: IGLTFImage;
  82873. };
  82874. textures: {
  82875. [key: string]: IGLTFTexture;
  82876. };
  82877. shaders: {
  82878. [key: string]: IGLTFShader;
  82879. };
  82880. programs: {
  82881. [key: string]: IGLTFProgram;
  82882. };
  82883. samplers: {
  82884. [key: string]: IGLTFSampler;
  82885. };
  82886. techniques: {
  82887. [key: string]: IGLTFTechnique;
  82888. };
  82889. materials: {
  82890. [key: string]: IGLTFMaterial;
  82891. };
  82892. animations: {
  82893. [key: string]: IGLTFAnimation;
  82894. };
  82895. skins: {
  82896. [key: string]: IGLTFSkins;
  82897. };
  82898. currentScene?: Object;
  82899. scenes: {
  82900. [key: string]: IGLTFScene;
  82901. };
  82902. extensionsUsed: string[];
  82903. extensionsRequired?: string[];
  82904. buffersCount: number;
  82905. shaderscount: number;
  82906. scene: Scene;
  82907. rootUrl: string;
  82908. loadedBufferCount: number;
  82909. loadedBufferViews: {
  82910. [name: string]: ArrayBufferView;
  82911. };
  82912. loadedShaderCount: number;
  82913. importOnlyMeshes: boolean;
  82914. importMeshesNames?: string[];
  82915. dummyNodes: Node[];
  82916. forAssetContainer: boolean;
  82917. }
  82918. /** @hidden */
  82919. export interface INodeToRoot {
  82920. bone: Bone;
  82921. node: IGLTFNode;
  82922. id: string;
  82923. }
  82924. /** @hidden */
  82925. export interface IJointNode {
  82926. node: IGLTFNode;
  82927. id: string;
  82928. }
  82929. }
  82930. declare module BABYLON.GLTF1 {
  82931. /**
  82932. * Utils functions for GLTF
  82933. * @hidden
  82934. */
  82935. export class GLTFUtils {
  82936. /**
  82937. * Sets the given "parameter" matrix
  82938. * @param scene: the Scene object
  82939. * @param source: the source node where to pick the matrix
  82940. * @param parameter: the GLTF technique parameter
  82941. * @param uniformName: the name of the shader's uniform
  82942. * @param shaderMaterial: the shader material
  82943. */
  82944. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82945. /**
  82946. * Sets the given "parameter" matrix
  82947. * @param shaderMaterial: the shader material
  82948. * @param uniform: the name of the shader's uniform
  82949. * @param value: the value of the uniform
  82950. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82951. */
  82952. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82953. /**
  82954. * Returns the wrap mode of the texture
  82955. * @param mode: the mode value
  82956. */
  82957. static GetWrapMode(mode: number): number;
  82958. /**
  82959. * Returns the byte stride giving an accessor
  82960. * @param accessor: the GLTF accessor objet
  82961. */
  82962. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82963. /**
  82964. * Returns the texture filter mode giving a mode value
  82965. * @param mode: the filter mode value
  82966. */
  82967. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82968. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82969. /**
  82970. * Returns a buffer from its accessor
  82971. * @param gltfRuntime: the GLTF runtime
  82972. * @param accessor: the GLTF accessor
  82973. */
  82974. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82975. /**
  82976. * Decodes a buffer view into a string
  82977. * @param view: the buffer view
  82978. */
  82979. static DecodeBufferToText(view: ArrayBufferView): string;
  82980. /**
  82981. * Returns the default material of gltf. Related to
  82982. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82983. * @param scene: the Babylon.js scene
  82984. */
  82985. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82986. private static _DefaultMaterial;
  82987. }
  82988. }
  82989. declare module BABYLON.GLTF1 {
  82990. /**
  82991. * Implementation of the base glTF spec
  82992. * @hidden
  82993. */
  82994. export class GLTFLoaderBase {
  82995. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82996. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82997. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82998. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82999. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  83000. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83001. }
  83002. /**
  83003. * glTF V1 Loader
  83004. * @hidden
  83005. */
  83006. export class GLTFLoader implements IGLTFLoader {
  83007. static Extensions: {
  83008. [name: string]: GLTFLoaderExtension;
  83009. };
  83010. static RegisterExtension(extension: GLTFLoaderExtension): void;
  83011. state: Nullable<GLTFLoaderState>;
  83012. dispose(): void;
  83013. private _importMeshAsync;
  83014. /**
  83015. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  83016. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83017. * @param scene the scene the meshes should be added to
  83018. * @param forAssetContainer defines if the entities must be stored in the scene
  83019. * @param data gltf data containing information of the meshes in a loaded file
  83020. * @param rootUrl root url to load from
  83021. * @param onProgress event that fires when loading progress has occured
  83022. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83023. */
  83024. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  83025. private _loadAsync;
  83026. /**
  83027. * Imports all objects from a loaded gltf file and adds them to the scene
  83028. * @param scene the scene the objects should be added to
  83029. * @param data gltf data containing information of the meshes in a loaded file
  83030. * @param rootUrl root url to load from
  83031. * @param onProgress event that fires when loading progress has occured
  83032. * @returns a promise which completes when objects have been loaded to the scene
  83033. */
  83034. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  83035. private _loadShadersAsync;
  83036. private _loadBuffersAsync;
  83037. private _createNodes;
  83038. }
  83039. /** @hidden */
  83040. export abstract class GLTFLoaderExtension {
  83041. private _name;
  83042. constructor(name: string);
  83043. get name(): string;
  83044. /**
  83045. * Defines an override for loading the runtime
  83046. * Return true to stop further extensions from loading the runtime
  83047. */
  83048. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  83049. /**
  83050. * Defines an onverride for creating gltf runtime
  83051. * Return true to stop further extensions from creating the runtime
  83052. */
  83053. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83054. /**
  83055. * Defines an override for loading buffers
  83056. * Return true to stop further extensions from loading this buffer
  83057. */
  83058. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83059. /**
  83060. * Defines an override for loading texture buffers
  83061. * Return true to stop further extensions from loading this texture data
  83062. */
  83063. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83064. /**
  83065. * Defines an override for creating textures
  83066. * Return true to stop further extensions from loading this texture
  83067. */
  83068. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83069. /**
  83070. * Defines an override for loading shader strings
  83071. * Return true to stop further extensions from loading this shader data
  83072. */
  83073. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83074. /**
  83075. * Defines an override for loading materials
  83076. * Return true to stop further extensions from loading this material
  83077. */
  83078. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83079. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83080. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83081. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83082. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83083. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83084. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83085. private static LoadTextureBufferAsync;
  83086. private static CreateTextureAsync;
  83087. private static ApplyExtensions;
  83088. }
  83089. }
  83090. declare module BABYLON.GLTF1 {
  83091. /** @hidden */
  83092. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83093. private _bin;
  83094. constructor();
  83095. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83096. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83097. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83098. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83099. }
  83100. }
  83101. declare module BABYLON.GLTF1 {
  83102. /** @hidden */
  83103. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83104. constructor();
  83105. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83106. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83107. private _loadTexture;
  83108. }
  83109. }
  83110. declare module BABYLON.GLTF2.Loader {
  83111. /**
  83112. * Loader interface with an index field.
  83113. */
  83114. export interface IArrayItem {
  83115. /**
  83116. * The index of this item in the array.
  83117. */
  83118. index: number;
  83119. }
  83120. /**
  83121. * Loader interface with additional members.
  83122. */
  83123. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83124. /** @hidden */
  83125. _data?: Promise<ArrayBufferView>;
  83126. /** @hidden */
  83127. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83128. }
  83129. /**
  83130. * Loader interface with additional members.
  83131. */
  83132. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83133. }
  83134. /** @hidden */
  83135. export interface _IAnimationSamplerData {
  83136. input: Float32Array;
  83137. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83138. output: Float32Array;
  83139. }
  83140. /**
  83141. * Loader interface with additional members.
  83142. */
  83143. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83144. /** @hidden */
  83145. _data?: Promise<_IAnimationSamplerData>;
  83146. }
  83147. /**
  83148. * Loader interface with additional members.
  83149. */
  83150. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83151. channels: IAnimationChannel[];
  83152. samplers: IAnimationSampler[];
  83153. /** @hidden */
  83154. _babylonAnimationGroup?: AnimationGroup;
  83155. }
  83156. /**
  83157. * Loader interface with additional members.
  83158. */
  83159. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83160. /** @hidden */
  83161. _data?: Promise<ArrayBufferView>;
  83162. }
  83163. /**
  83164. * Loader interface with additional members.
  83165. */
  83166. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83167. /** @hidden */
  83168. _data?: Promise<ArrayBufferView>;
  83169. /** @hidden */
  83170. _babylonBuffer?: Promise<Buffer>;
  83171. }
  83172. /**
  83173. * Loader interface with additional members.
  83174. */
  83175. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83176. }
  83177. /**
  83178. * Loader interface with additional members.
  83179. */
  83180. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83181. /** @hidden */
  83182. _data?: Promise<ArrayBufferView>;
  83183. }
  83184. /**
  83185. * Loader interface with additional members.
  83186. */
  83187. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83188. }
  83189. /**
  83190. * Loader interface with additional members.
  83191. */
  83192. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83193. }
  83194. /**
  83195. * Loader interface with additional members.
  83196. */
  83197. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83198. baseColorTexture?: ITextureInfo;
  83199. metallicRoughnessTexture?: ITextureInfo;
  83200. }
  83201. /**
  83202. * Loader interface with additional members.
  83203. */
  83204. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83205. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83206. normalTexture?: IMaterialNormalTextureInfo;
  83207. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83208. emissiveTexture?: ITextureInfo;
  83209. /** @hidden */
  83210. _data?: {
  83211. [babylonDrawMode: number]: {
  83212. babylonMaterial: Material;
  83213. babylonMeshes: AbstractMesh[];
  83214. promise: Promise<void>;
  83215. };
  83216. };
  83217. }
  83218. /**
  83219. * Loader interface with additional members.
  83220. */
  83221. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83222. primitives: IMeshPrimitive[];
  83223. }
  83224. /**
  83225. * Loader interface with additional members.
  83226. */
  83227. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83228. /** @hidden */
  83229. _instanceData?: {
  83230. babylonSourceMesh: Mesh;
  83231. promise: Promise<any>;
  83232. };
  83233. }
  83234. /**
  83235. * Loader interface with additional members.
  83236. */
  83237. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83238. /**
  83239. * The parent glTF node.
  83240. */
  83241. parent?: INode;
  83242. /** @hidden */
  83243. _babylonTransformNode?: TransformNode;
  83244. /** @hidden */
  83245. _primitiveBabylonMeshes?: AbstractMesh[];
  83246. /** @hidden */
  83247. _babylonBones?: Bone[];
  83248. /** @hidden */
  83249. _numMorphTargets?: number;
  83250. }
  83251. /** @hidden */
  83252. export interface _ISamplerData {
  83253. noMipMaps: boolean;
  83254. samplingMode: number;
  83255. wrapU: number;
  83256. wrapV: number;
  83257. }
  83258. /**
  83259. * Loader interface with additional members.
  83260. */
  83261. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83262. /** @hidden */
  83263. _data?: _ISamplerData;
  83264. }
  83265. /**
  83266. * Loader interface with additional members.
  83267. */
  83268. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83269. }
  83270. /**
  83271. * Loader interface with additional members.
  83272. */
  83273. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83274. /** @hidden */
  83275. _data?: {
  83276. babylonSkeleton: Skeleton;
  83277. promise: Promise<void>;
  83278. };
  83279. }
  83280. /**
  83281. * Loader interface with additional members.
  83282. */
  83283. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83284. /** @hidden */
  83285. _textureInfo: ITextureInfo;
  83286. }
  83287. /**
  83288. * Loader interface with additional members.
  83289. */
  83290. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83291. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83292. nonColorData?: boolean;
  83293. }
  83294. /**
  83295. * Loader interface with additional members.
  83296. */
  83297. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83298. accessors?: IAccessor[];
  83299. animations?: IAnimation[];
  83300. buffers?: IBuffer[];
  83301. bufferViews?: IBufferView[];
  83302. cameras?: ICamera[];
  83303. images?: IImage[];
  83304. materials?: IMaterial[];
  83305. meshes?: IMesh[];
  83306. nodes?: INode[];
  83307. samplers?: ISampler[];
  83308. scenes?: IScene[];
  83309. skins?: ISkin[];
  83310. textures?: ITexture[];
  83311. }
  83312. }
  83313. declare module BABYLON.GLTF2 {
  83314. /**
  83315. * Interface for a glTF loader extension.
  83316. */
  83317. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83318. /**
  83319. * Called after the loader state changes to LOADING.
  83320. */
  83321. onLoading?(): void;
  83322. /**
  83323. * Called after the loader state changes to READY.
  83324. */
  83325. onReady?(): void;
  83326. /**
  83327. * Define this method to modify the default behavior when loading scenes.
  83328. * @param context The context when loading the asset
  83329. * @param scene The glTF scene property
  83330. * @returns A promise that resolves when the load is complete or null if not handled
  83331. */
  83332. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83333. /**
  83334. * Define this method to modify the default behavior when loading nodes.
  83335. * @param context The context when loading the asset
  83336. * @param node The glTF node property
  83337. * @param assign A function called synchronously after parsing the glTF properties
  83338. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83339. */
  83340. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83341. /**
  83342. * Define this method to modify the default behavior when loading cameras.
  83343. * @param context The context when loading the asset
  83344. * @param camera The glTF camera property
  83345. * @param assign A function called synchronously after parsing the glTF properties
  83346. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83347. */
  83348. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83349. /**
  83350. * @hidden
  83351. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83352. * @param context The context when loading the asset
  83353. * @param primitive The glTF mesh primitive property
  83354. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83355. */
  83356. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83357. /**
  83358. * @hidden
  83359. * Define this method to modify the default behavior when loading data for mesh primitives.
  83360. * @param context The context when loading the asset
  83361. * @param name The mesh name when loading the asset
  83362. * @param node The glTF node when loading the asset
  83363. * @param mesh The glTF mesh when loading the asset
  83364. * @param primitive The glTF mesh primitive property
  83365. * @param assign A function called synchronously after parsing the glTF properties
  83366. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83367. */
  83368. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83369. /**
  83370. * @hidden
  83371. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83372. * @param context The context when loading the asset
  83373. * @param material The glTF material property
  83374. * @param assign A function called synchronously after parsing the glTF properties
  83375. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83376. */
  83377. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83378. /**
  83379. * Define this method to modify the default behavior when creating materials.
  83380. * @param context The context when loading the asset
  83381. * @param material The glTF material property
  83382. * @param babylonDrawMode The draw mode for the Babylon material
  83383. * @returns The Babylon material or null if not handled
  83384. */
  83385. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83386. /**
  83387. * Define this method to modify the default behavior when loading material properties.
  83388. * @param context The context when loading the asset
  83389. * @param material The glTF material property
  83390. * @param babylonMaterial The Babylon material
  83391. * @returns A promise that resolves when the load is complete or null if not handled
  83392. */
  83393. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83394. /**
  83395. * Define this method to modify the default behavior when loading texture infos.
  83396. * @param context The context when loading the asset
  83397. * @param textureInfo The glTF texture info property
  83398. * @param assign A function called synchronously after parsing the glTF properties
  83399. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83400. */
  83401. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83402. /**
  83403. * @hidden
  83404. * Define this method to modify the default behavior when loading textures.
  83405. * @param context The context when loading the asset
  83406. * @param texture The glTF texture property
  83407. * @param assign A function called synchronously after parsing the glTF properties
  83408. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83409. */
  83410. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83411. /**
  83412. * Define this method to modify the default behavior when loading animations.
  83413. * @param context The context when loading the asset
  83414. * @param animation The glTF animation property
  83415. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83416. */
  83417. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83418. /**
  83419. * @hidden
  83420. * Define this method to modify the default behavior when loading skins.
  83421. * @param context The context when loading the asset
  83422. * @param node The glTF node property
  83423. * @param skin The glTF skin property
  83424. * @returns A promise that resolves when the load is complete or null if not handled
  83425. */
  83426. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83427. /**
  83428. * @hidden
  83429. * Define this method to modify the default behavior when loading uris.
  83430. * @param context The context when loading the asset
  83431. * @param property The glTF property associated with the uri
  83432. * @param uri The uri to load
  83433. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83434. */
  83435. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83436. /**
  83437. * Define this method to modify the default behavior when loading buffer views.
  83438. * @param context The context when loading the asset
  83439. * @param bufferView The glTF buffer view property
  83440. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83441. */
  83442. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83443. /**
  83444. * Define this method to modify the default behavior when loading buffers.
  83445. * @param context The context when loading the asset
  83446. * @param buffer The glTF buffer property
  83447. * @param byteOffset The byte offset to load
  83448. * @param byteLength The byte length to load
  83449. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83450. */
  83451. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83452. }
  83453. }
  83454. declare module BABYLON.GLTF2 {
  83455. /**
  83456. * Helper class for working with arrays when loading the glTF asset
  83457. */
  83458. export class ArrayItem {
  83459. /**
  83460. * Gets an item from the given array.
  83461. * @param context The context when loading the asset
  83462. * @param array The array to get the item from
  83463. * @param index The index to the array
  83464. * @returns The array item
  83465. */
  83466. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83467. /**
  83468. * Assign an `index` field to each item of the given array.
  83469. * @param array The array of items
  83470. */
  83471. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83472. }
  83473. /**
  83474. * The glTF 2.0 loader
  83475. */
  83476. export class GLTFLoader implements IGLTFLoader {
  83477. /** @hidden */
  83478. _completePromises: Promise<any>[];
  83479. /** @hidden */
  83480. _forAssetContainer: boolean;
  83481. /** Storage */
  83482. _babylonLights: Light[];
  83483. /** @hidden */
  83484. _disableInstancedMesh: number;
  83485. private _disposed;
  83486. private _parent;
  83487. private _state;
  83488. private _extensions;
  83489. private _rootUrl;
  83490. private _fileName;
  83491. private _uniqueRootUrl;
  83492. private _gltf;
  83493. private _bin;
  83494. private _babylonScene;
  83495. private _rootBabylonMesh;
  83496. private _defaultBabylonMaterialData;
  83497. private static _RegisteredExtensions;
  83498. /**
  83499. * The default glTF sampler.
  83500. */
  83501. static readonly DefaultSampler: ISampler;
  83502. /**
  83503. * Registers a loader extension.
  83504. * @param name The name of the loader extension.
  83505. * @param factory The factory function that creates the loader extension.
  83506. */
  83507. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83508. /**
  83509. * Unregisters a loader extension.
  83510. * @param name The name of the loader extension.
  83511. * @returns A boolean indicating whether the extension has been unregistered
  83512. */
  83513. static UnregisterExtension(name: string): boolean;
  83514. /**
  83515. * The loader state.
  83516. */
  83517. get state(): Nullable<GLTFLoaderState>;
  83518. /**
  83519. * The object that represents the glTF JSON.
  83520. */
  83521. get gltf(): IGLTF;
  83522. /**
  83523. * The BIN chunk of a binary glTF.
  83524. */
  83525. get bin(): Nullable<IDataBuffer>;
  83526. /**
  83527. * The parent file loader.
  83528. */
  83529. get parent(): GLTFFileLoader;
  83530. /**
  83531. * The Babylon scene when loading the asset.
  83532. */
  83533. get babylonScene(): Scene;
  83534. /**
  83535. * The root Babylon mesh when loading the asset.
  83536. */
  83537. get rootBabylonMesh(): Mesh;
  83538. /** @hidden */
  83539. constructor(parent: GLTFFileLoader);
  83540. /** @hidden */
  83541. dispose(): void;
  83542. /** @hidden */
  83543. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83544. /** @hidden */
  83545. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83546. private _loadAsync;
  83547. private _loadData;
  83548. private _setupData;
  83549. private _loadExtensions;
  83550. private _checkExtensions;
  83551. private _setState;
  83552. private _createRootNode;
  83553. /**
  83554. * Loads a glTF scene.
  83555. * @param context The context when loading the asset
  83556. * @param scene The glTF scene property
  83557. * @returns A promise that resolves when the load is complete
  83558. */
  83559. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83560. private _forEachPrimitive;
  83561. private _getGeometries;
  83562. private _getMeshes;
  83563. private _getTransformNodes;
  83564. private _getSkeletons;
  83565. private _getAnimationGroups;
  83566. private _startAnimations;
  83567. /**
  83568. * Loads a glTF node.
  83569. * @param context The context when loading the asset
  83570. * @param node The glTF node property
  83571. * @param assign A function called synchronously after parsing the glTF properties
  83572. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83573. */
  83574. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83575. private _loadMeshAsync;
  83576. /**
  83577. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83578. * @param context The context when loading the asset
  83579. * @param name The mesh name when loading the asset
  83580. * @param node The glTF node when loading the asset
  83581. * @param mesh The glTF mesh when loading the asset
  83582. * @param primitive The glTF mesh primitive property
  83583. * @param assign A function called synchronously after parsing the glTF properties
  83584. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83585. */
  83586. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83587. private _loadVertexDataAsync;
  83588. private _createMorphTargets;
  83589. private _loadMorphTargetsAsync;
  83590. private _loadMorphTargetVertexDataAsync;
  83591. private static _LoadTransform;
  83592. private _loadSkinAsync;
  83593. private _loadBones;
  83594. private _loadBone;
  83595. private _loadSkinInverseBindMatricesDataAsync;
  83596. private _updateBoneMatrices;
  83597. private _getNodeMatrix;
  83598. /**
  83599. * Loads a glTF camera.
  83600. * @param context The context when loading the asset
  83601. * @param camera The glTF camera property
  83602. * @param assign A function called synchronously after parsing the glTF properties
  83603. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83604. */
  83605. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83606. private _loadAnimationsAsync;
  83607. /**
  83608. * Loads a glTF animation.
  83609. * @param context The context when loading the asset
  83610. * @param animation The glTF animation property
  83611. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83612. */
  83613. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83614. /**
  83615. * @hidden Loads a glTF animation channel.
  83616. * @param context The context when loading the asset
  83617. * @param animationContext The context of the animation when loading the asset
  83618. * @param animation The glTF animation property
  83619. * @param channel The glTF animation channel property
  83620. * @param babylonAnimationGroup The babylon animation group property
  83621. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83622. * @returns A void promise when the channel load is complete
  83623. */
  83624. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83625. private _loadAnimationSamplerAsync;
  83626. private _loadBufferAsync;
  83627. /**
  83628. * Loads a glTF buffer view.
  83629. * @param context The context when loading the asset
  83630. * @param bufferView The glTF buffer view property
  83631. * @returns A promise that resolves with the loaded data when the load is complete
  83632. */
  83633. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83634. private _loadAccessorAsync;
  83635. /** @hidden */
  83636. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83637. private _loadIndicesAccessorAsync;
  83638. private _loadVertexBufferViewAsync;
  83639. private _loadVertexAccessorAsync;
  83640. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83641. /** @hidden */
  83642. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83643. private _createDefaultMaterial;
  83644. /**
  83645. * Creates a Babylon material from a glTF material.
  83646. * @param context The context when loading the asset
  83647. * @param material The glTF material property
  83648. * @param babylonDrawMode The draw mode for the Babylon material
  83649. * @returns The Babylon material
  83650. */
  83651. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83652. /**
  83653. * Loads properties from a glTF material into a Babylon material.
  83654. * @param context The context when loading the asset
  83655. * @param material The glTF material property
  83656. * @param babylonMaterial The Babylon material
  83657. * @returns A promise that resolves when the load is complete
  83658. */
  83659. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83660. /**
  83661. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83662. * @param context The context when loading the asset
  83663. * @param material The glTF material property
  83664. * @param babylonMaterial The Babylon material
  83665. * @returns A promise that resolves when the load is complete
  83666. */
  83667. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83668. /**
  83669. * Loads the alpha properties from a glTF material into a Babylon material.
  83670. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83671. * @param context The context when loading the asset
  83672. * @param material The glTF material property
  83673. * @param babylonMaterial The Babylon material
  83674. */
  83675. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83676. /**
  83677. * Loads a glTF texture info.
  83678. * @param context The context when loading the asset
  83679. * @param textureInfo The glTF texture info property
  83680. * @param assign A function called synchronously after parsing the glTF properties
  83681. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83682. */
  83683. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83684. /** @hidden */
  83685. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83686. /** @hidden */
  83687. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83688. private _loadSampler;
  83689. /**
  83690. * Loads a glTF image.
  83691. * @param context The context when loading the asset
  83692. * @param image The glTF image property
  83693. * @returns A promise that resolves with the loaded data when the load is complete
  83694. */
  83695. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83696. /**
  83697. * Loads a glTF uri.
  83698. * @param context The context when loading the asset
  83699. * @param property The glTF property associated with the uri
  83700. * @param uri The base64 or relative uri
  83701. * @returns A promise that resolves with the loaded data when the load is complete
  83702. */
  83703. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83704. /**
  83705. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83706. * @param babylonObject the Babylon object with metadata
  83707. * @param pointer the JSON pointer
  83708. */
  83709. static AddPointerMetadata(babylonObject: {
  83710. metadata: any;
  83711. }, pointer: string): void;
  83712. private static _GetTextureWrapMode;
  83713. private static _GetTextureSamplingMode;
  83714. private static _GetTypedArrayConstructor;
  83715. private static _GetTypedArray;
  83716. private static _GetNumComponents;
  83717. private static _ValidateUri;
  83718. /** @hidden */
  83719. static _GetDrawMode(context: string, mode: number | undefined): number;
  83720. private _compileMaterialsAsync;
  83721. private _compileShadowGeneratorsAsync;
  83722. private _forEachExtensions;
  83723. private _applyExtensions;
  83724. private _extensionsOnLoading;
  83725. private _extensionsOnReady;
  83726. private _extensionsLoadSceneAsync;
  83727. private _extensionsLoadNodeAsync;
  83728. private _extensionsLoadCameraAsync;
  83729. private _extensionsLoadVertexDataAsync;
  83730. private _extensionsLoadMeshPrimitiveAsync;
  83731. private _extensionsLoadMaterialAsync;
  83732. private _extensionsCreateMaterial;
  83733. private _extensionsLoadMaterialPropertiesAsync;
  83734. private _extensionsLoadTextureInfoAsync;
  83735. private _extensionsLoadTextureAsync;
  83736. private _extensionsLoadAnimationAsync;
  83737. private _extensionsLoadSkinAsync;
  83738. private _extensionsLoadUriAsync;
  83739. private _extensionsLoadBufferViewAsync;
  83740. private _extensionsLoadBufferAsync;
  83741. /**
  83742. * Helper method called by a loader extension to load an glTF extension.
  83743. * @param context The context when loading the asset
  83744. * @param property The glTF property to load the extension from
  83745. * @param extensionName The name of the extension to load
  83746. * @param actionAsync The action to run
  83747. * @returns The promise returned by actionAsync or null if the extension does not exist
  83748. */
  83749. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83750. /**
  83751. * Helper method called by a loader extension to load a glTF extra.
  83752. * @param context The context when loading the asset
  83753. * @param property The glTF property to load the extra from
  83754. * @param extensionName The name of the extension to load
  83755. * @param actionAsync The action to run
  83756. * @returns The promise returned by actionAsync or null if the extra does not exist
  83757. */
  83758. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83759. /**
  83760. * Checks for presence of an extension.
  83761. * @param name The name of the extension to check
  83762. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83763. */
  83764. isExtensionUsed(name: string): boolean;
  83765. /**
  83766. * Increments the indentation level and logs a message.
  83767. * @param message The message to log
  83768. */
  83769. logOpen(message: string): void;
  83770. /**
  83771. * Decrements the indentation level.
  83772. */
  83773. logClose(): void;
  83774. /**
  83775. * Logs a message
  83776. * @param message The message to log
  83777. */
  83778. log(message: string): void;
  83779. /**
  83780. * Starts a performance counter.
  83781. * @param counterName The name of the performance counter
  83782. */
  83783. startPerformanceCounter(counterName: string): void;
  83784. /**
  83785. * Ends a performance counter.
  83786. * @param counterName The name of the performance counter
  83787. */
  83788. endPerformanceCounter(counterName: string): void;
  83789. }
  83790. }
  83791. declare module BABYLON.GLTF2.Loader.Extensions {
  83792. /** @hidden */
  83793. interface IEXTLightsImageBased_LightImageBased {
  83794. _babylonTexture?: BaseTexture;
  83795. _loaded?: Promise<void>;
  83796. }
  83797. /**
  83798. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83799. */
  83800. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83801. /**
  83802. * The name of this extension.
  83803. */
  83804. readonly name: string;
  83805. /**
  83806. * Defines whether this extension is enabled.
  83807. */
  83808. enabled: boolean;
  83809. private _loader;
  83810. private _lights?;
  83811. /** @hidden */
  83812. constructor(loader: GLTFLoader);
  83813. /** @hidden */
  83814. dispose(): void;
  83815. /** @hidden */
  83816. onLoading(): void;
  83817. /** @hidden */
  83818. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83819. private _loadLightAsync;
  83820. }
  83821. }
  83822. declare module BABYLON.GLTF2.Loader.Extensions {
  83823. /**
  83824. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83825. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83826. * !!! Experimental Extension Subject to Changes !!!
  83827. */
  83828. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83829. /**
  83830. * The name of this extension.
  83831. */
  83832. readonly name: string;
  83833. /**
  83834. * Defines whether this extension is enabled.
  83835. */
  83836. enabled: boolean;
  83837. private _loader;
  83838. /** @hidden */
  83839. constructor(loader: GLTFLoader);
  83840. /** @hidden */
  83841. dispose(): void;
  83842. /** @hidden */
  83843. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83844. }
  83845. }
  83846. declare module BABYLON.GLTF2.Loader.Extensions {
  83847. /**
  83848. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83849. */
  83850. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83851. /** The name of this extension. */
  83852. readonly name: string;
  83853. /** Defines whether this extension is enabled. */
  83854. enabled: boolean;
  83855. private _loader;
  83856. /** @hidden */
  83857. constructor(loader: GLTFLoader);
  83858. /** @hidden */
  83859. dispose(): void;
  83860. /** @hidden */
  83861. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83862. }
  83863. }
  83864. declare module BABYLON.GLTF2.Loader.Extensions {
  83865. /**
  83866. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83867. */
  83868. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83869. /**
  83870. * The name of this extension.
  83871. */
  83872. readonly name: string;
  83873. /**
  83874. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83875. */
  83876. dracoCompression?: DracoCompression;
  83877. /**
  83878. * Defines whether this extension is enabled.
  83879. */
  83880. enabled: boolean;
  83881. private _loader;
  83882. /** @hidden */
  83883. constructor(loader: GLTFLoader);
  83884. /** @hidden */
  83885. dispose(): void;
  83886. /** @hidden */
  83887. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83888. }
  83889. }
  83890. declare module BABYLON.GLTF2.Loader.Extensions {
  83891. /**
  83892. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83893. */
  83894. export class KHR_lights implements IGLTFLoaderExtension {
  83895. /**
  83896. * The name of this extension.
  83897. */
  83898. readonly name: string;
  83899. /**
  83900. * Defines whether this extension is enabled.
  83901. */
  83902. enabled: boolean;
  83903. private _loader;
  83904. private _lights?;
  83905. /** @hidden */
  83906. constructor(loader: GLTFLoader);
  83907. /** @hidden */
  83908. dispose(): void;
  83909. /** @hidden */
  83910. onLoading(): void;
  83911. /** @hidden */
  83912. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83913. }
  83914. }
  83915. declare module BABYLON.GLTF2.Loader.Extensions {
  83916. /**
  83917. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83918. */
  83919. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83920. /**
  83921. * The name of this extension.
  83922. */
  83923. readonly name: string;
  83924. /**
  83925. * Defines whether this extension is enabled.
  83926. */
  83927. enabled: boolean;
  83928. /**
  83929. * Defines a number that determines the order the extensions are applied.
  83930. */
  83931. order: number;
  83932. private _loader;
  83933. /** @hidden */
  83934. constructor(loader: GLTFLoader);
  83935. /** @hidden */
  83936. dispose(): void;
  83937. /** @hidden */
  83938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83939. private _loadSpecularGlossinessPropertiesAsync;
  83940. }
  83941. }
  83942. declare module BABYLON.GLTF2.Loader.Extensions {
  83943. /**
  83944. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83945. */
  83946. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83947. /**
  83948. * The name of this extension.
  83949. */
  83950. readonly name: string;
  83951. /**
  83952. * Defines whether this extension is enabled.
  83953. */
  83954. enabled: boolean;
  83955. /**
  83956. * Defines a number that determines the order the extensions are applied.
  83957. */
  83958. order: number;
  83959. private _loader;
  83960. /** @hidden */
  83961. constructor(loader: GLTFLoader);
  83962. /** @hidden */
  83963. dispose(): void;
  83964. /** @hidden */
  83965. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83966. private _loadUnlitPropertiesAsync;
  83967. }
  83968. }
  83969. declare module BABYLON.GLTF2.Loader.Extensions {
  83970. /**
  83971. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83972. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83973. */
  83974. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83975. /**
  83976. * The name of this extension.
  83977. */
  83978. readonly name: string;
  83979. /**
  83980. * Defines whether this extension is enabled.
  83981. */
  83982. enabled: boolean;
  83983. /**
  83984. * Defines a number that determines the order the extensions are applied.
  83985. */
  83986. order: number;
  83987. private _loader;
  83988. /** @hidden */
  83989. constructor(loader: GLTFLoader);
  83990. /** @hidden */
  83991. dispose(): void;
  83992. /** @hidden */
  83993. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83994. private _loadClearCoatPropertiesAsync;
  83995. }
  83996. }
  83997. declare module BABYLON.GLTF2.Loader.Extensions {
  83998. /**
  83999. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  84000. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  84001. * !!! Experimental Extension Subject to Changes !!!
  84002. */
  84003. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  84004. /**
  84005. * The name of this extension.
  84006. */
  84007. readonly name: string;
  84008. /**
  84009. * Defines whether this extension is enabled.
  84010. */
  84011. enabled: boolean;
  84012. /**
  84013. * Defines a number that determines the order the extensions are applied.
  84014. */
  84015. order: number;
  84016. private _loader;
  84017. /** @hidden */
  84018. constructor(loader: GLTFLoader);
  84019. /** @hidden */
  84020. dispose(): void;
  84021. /** @hidden */
  84022. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84023. private _loadSheenPropertiesAsync;
  84024. }
  84025. }
  84026. declare module BABYLON.GLTF2.Loader.Extensions {
  84027. /**
  84028. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  84029. * !!! Experimental Extension Subject to Changes !!!
  84030. */
  84031. export class KHR_materials_specular implements IGLTFLoaderExtension {
  84032. /**
  84033. * The name of this extension.
  84034. */
  84035. readonly name: string;
  84036. /**
  84037. * Defines whether this extension is enabled.
  84038. */
  84039. enabled: boolean;
  84040. /**
  84041. * Defines a number that determines the order the extensions are applied.
  84042. */
  84043. order: number;
  84044. private _loader;
  84045. /** @hidden */
  84046. constructor(loader: GLTFLoader);
  84047. /** @hidden */
  84048. dispose(): void;
  84049. /** @hidden */
  84050. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84051. private _loadSpecularPropertiesAsync;
  84052. }
  84053. }
  84054. declare module BABYLON.GLTF2.Loader.Extensions {
  84055. /**
  84056. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84057. * !!! Experimental Extension Subject to Changes !!!
  84058. */
  84059. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84060. /**
  84061. * Default ior Value from the spec.
  84062. */
  84063. private static readonly _DEFAULT_IOR;
  84064. /**
  84065. * The name of this extension.
  84066. */
  84067. readonly name: string;
  84068. /**
  84069. * Defines whether this extension is enabled.
  84070. */
  84071. enabled: boolean;
  84072. /**
  84073. * Defines a number that determines the order the extensions are applied.
  84074. */
  84075. order: number;
  84076. private _loader;
  84077. /** @hidden */
  84078. constructor(loader: GLTFLoader);
  84079. /** @hidden */
  84080. dispose(): void;
  84081. /** @hidden */
  84082. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84083. private _loadIorPropertiesAsync;
  84084. }
  84085. }
  84086. declare module BABYLON.GLTF2.Loader.Extensions {
  84087. /**
  84088. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  84089. * !!! Experimental Extension Subject to Changes !!!
  84090. */
  84091. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84092. /**
  84093. * The name of this extension.
  84094. */
  84095. readonly name: string;
  84096. /**
  84097. * Defines whether this extension is enabled.
  84098. */
  84099. enabled: boolean;
  84100. private _loader;
  84101. private _variants?;
  84102. /** @hidden */
  84103. constructor(loader: GLTFLoader);
  84104. /** @hidden */
  84105. dispose(): void;
  84106. /**
  84107. * Gets the list of available variant names for this asset.
  84108. * @param rootMesh The glTF root mesh
  84109. * @returns the list of all the variant names for this model
  84110. */
  84111. static GetAvailableVariants(rootMesh: Mesh): string[];
  84112. /**
  84113. * Gets the list of available variant names for this asset.
  84114. * @param rootMesh The glTF root mesh
  84115. * @returns the list of all the variant names for this model
  84116. */
  84117. getAvailableVariants(rootMesh: Mesh): string[];
  84118. /**
  84119. * Select a variant given a variant name or a list of variant names.
  84120. * @param rootMesh The glTF root mesh
  84121. * @param variantName The variant name(s) to select.
  84122. */
  84123. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84124. /**
  84125. * Select a variant given a variant name or a list of variant names.
  84126. * @param rootMesh The glTF root mesh
  84127. * @param variantName The variant name(s) to select.
  84128. */
  84129. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84130. /**
  84131. * Reset back to the original before selecting a variant.
  84132. * @param rootMesh The glTF root mesh
  84133. */
  84134. static Reset(rootMesh: Mesh): void;
  84135. /**
  84136. * Reset back to the original before selecting a variant.
  84137. * @param rootMesh The glTF root mesh
  84138. */
  84139. reset(rootMesh: Mesh): void;
  84140. /**
  84141. * Gets the last selected variant name(s) or null if original.
  84142. * @param rootMesh The glTF root mesh
  84143. * @returns The selected variant name(s).
  84144. */
  84145. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84146. /**
  84147. * Gets the last selected variant name(s) or null if original.
  84148. * @param rootMesh The glTF root mesh
  84149. * @returns The selected variant name(s).
  84150. */
  84151. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84152. private static _GetExtensionMetadata;
  84153. /** @hidden */
  84154. onLoading(): void;
  84155. /** @hidden */
  84156. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84157. }
  84158. }
  84159. declare module BABYLON.GLTF2.Loader.Extensions {
  84160. /**
  84161. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84162. * !!! Experimental Extension Subject to Changes !!!
  84163. */
  84164. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84165. /**
  84166. * The name of this extension.
  84167. */
  84168. readonly name: string;
  84169. /**
  84170. * Defines whether this extension is enabled.
  84171. */
  84172. enabled: boolean;
  84173. /**
  84174. * Defines a number that determines the order the extensions are applied.
  84175. */
  84176. order: number;
  84177. private _loader;
  84178. /** @hidden */
  84179. constructor(loader: GLTFLoader);
  84180. /** @hidden */
  84181. dispose(): void;
  84182. /** @hidden */
  84183. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84184. private _loadTransparentPropertiesAsync;
  84185. }
  84186. }
  84187. declare module BABYLON.GLTF2.Loader.Extensions {
  84188. /**
  84189. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84190. * !!! Experimental Extension Subject to Changes !!!
  84191. */
  84192. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84193. /**
  84194. * The name of this extension.
  84195. */
  84196. readonly name: string;
  84197. /**
  84198. * Defines whether this extension is enabled.
  84199. */
  84200. enabled: boolean;
  84201. /**
  84202. * Defines a number that determines the order the extensions are applied.
  84203. */
  84204. order: number;
  84205. private _loader;
  84206. /** @hidden */
  84207. constructor(loader: GLTFLoader);
  84208. /** @hidden */
  84209. dispose(): void;
  84210. /** @hidden */
  84211. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84212. private _loadTranslucentPropertiesAsync;
  84213. }
  84214. }
  84215. declare module BABYLON.GLTF2.Loader.Extensions {
  84216. /**
  84217. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84218. */
  84219. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84220. /**
  84221. * The name of this extension.
  84222. */
  84223. readonly name: string;
  84224. /**
  84225. * Defines whether this extension is enabled.
  84226. */
  84227. enabled: boolean;
  84228. /** @hidden */
  84229. constructor(loader: GLTFLoader);
  84230. /** @hidden */
  84231. dispose(): void;
  84232. }
  84233. }
  84234. declare module BABYLON.GLTF2.Loader.Extensions {
  84235. /**
  84236. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84237. * !!! Experimental Extension Subject to Changes !!!
  84238. */
  84239. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84240. /** The name of this extension. */
  84241. readonly name: string;
  84242. /** Defines whether this extension is enabled. */
  84243. enabled: boolean;
  84244. private _loader;
  84245. /** @hidden */
  84246. constructor(loader: GLTFLoader);
  84247. /** @hidden */
  84248. dispose(): void;
  84249. /** @hidden */
  84250. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84251. }
  84252. }
  84253. declare module BABYLON.GLTF2.Loader.Extensions {
  84254. /**
  84255. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84256. */
  84257. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84258. /**
  84259. * The name of this extension.
  84260. */
  84261. readonly name: string;
  84262. /**
  84263. * Defines whether this extension is enabled.
  84264. */
  84265. enabled: boolean;
  84266. private _loader;
  84267. /** @hidden */
  84268. constructor(loader: GLTFLoader);
  84269. /** @hidden */
  84270. dispose(): void;
  84271. /** @hidden */
  84272. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84273. }
  84274. }
  84275. declare module BABYLON.GLTF2.Loader.Extensions {
  84276. /**
  84277. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84278. */
  84279. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84280. /**
  84281. * The name of this extension.
  84282. */
  84283. readonly name: string;
  84284. /**
  84285. * Defines whether this extension is enabled.
  84286. */
  84287. enabled: boolean;
  84288. private _loader;
  84289. private _clips;
  84290. private _emitters;
  84291. /** @hidden */
  84292. constructor(loader: GLTFLoader);
  84293. /** @hidden */
  84294. dispose(): void;
  84295. /** @hidden */
  84296. onLoading(): void;
  84297. /** @hidden */
  84298. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84299. /** @hidden */
  84300. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84301. /** @hidden */
  84302. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84303. private _loadClipAsync;
  84304. private _loadEmitterAsync;
  84305. private _getEventAction;
  84306. private _loadAnimationEventAsync;
  84307. }
  84308. }
  84309. declare module BABYLON.GLTF2.Loader.Extensions {
  84310. /**
  84311. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84312. */
  84313. export class MSFT_lod implements IGLTFLoaderExtension {
  84314. /**
  84315. * The name of this extension.
  84316. */
  84317. readonly name: string;
  84318. /**
  84319. * Defines whether this extension is enabled.
  84320. */
  84321. enabled: boolean;
  84322. /**
  84323. * Defines a number that determines the order the extensions are applied.
  84324. */
  84325. order: number;
  84326. /**
  84327. * Maximum number of LODs to load, starting from the lowest LOD.
  84328. */
  84329. maxLODsToLoad: number;
  84330. /**
  84331. * Observable raised when all node LODs of one level are loaded.
  84332. * The event data is the index of the loaded LOD starting from zero.
  84333. * Dispose the loader to cancel the loading of the next level of LODs.
  84334. */
  84335. onNodeLODsLoadedObservable: Observable<number>;
  84336. /**
  84337. * Observable raised when all material LODs of one level are loaded.
  84338. * The event data is the index of the loaded LOD starting from zero.
  84339. * Dispose the loader to cancel the loading of the next level of LODs.
  84340. */
  84341. onMaterialLODsLoadedObservable: Observable<number>;
  84342. private _loader;
  84343. private _bufferLODs;
  84344. private _nodeIndexLOD;
  84345. private _nodeSignalLODs;
  84346. private _nodePromiseLODs;
  84347. private _nodeBufferLODs;
  84348. private _materialIndexLOD;
  84349. private _materialSignalLODs;
  84350. private _materialPromiseLODs;
  84351. private _materialBufferLODs;
  84352. /** @hidden */
  84353. constructor(loader: GLTFLoader);
  84354. /** @hidden */
  84355. dispose(): void;
  84356. /** @hidden */
  84357. onReady(): void;
  84358. /** @hidden */
  84359. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84360. /** @hidden */
  84361. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84362. /** @hidden */
  84363. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84364. /** @hidden */
  84365. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84366. /** @hidden */
  84367. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84368. private _loadBufferLOD;
  84369. /**
  84370. * Gets an array of LOD properties from lowest to highest.
  84371. */
  84372. private _getLODs;
  84373. private _disposeTransformNode;
  84374. private _disposeMaterials;
  84375. }
  84376. }
  84377. declare module BABYLON.GLTF2.Loader.Extensions {
  84378. /** @hidden */
  84379. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84380. readonly name: string;
  84381. enabled: boolean;
  84382. private _loader;
  84383. constructor(loader: GLTFLoader);
  84384. dispose(): void;
  84385. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84386. }
  84387. }
  84388. declare module BABYLON.GLTF2.Loader.Extensions {
  84389. /** @hidden */
  84390. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84391. readonly name: string;
  84392. enabled: boolean;
  84393. private _loader;
  84394. constructor(loader: GLTFLoader);
  84395. dispose(): void;
  84396. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84397. }
  84398. }
  84399. declare module BABYLON.GLTF2.Loader.Extensions {
  84400. /**
  84401. * Store glTF extras (if present) in BJS objects' metadata
  84402. */
  84403. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84404. /**
  84405. * The name of this extension.
  84406. */
  84407. readonly name: string;
  84408. /**
  84409. * Defines whether this extension is enabled.
  84410. */
  84411. enabled: boolean;
  84412. private _loader;
  84413. private _assignExtras;
  84414. /** @hidden */
  84415. constructor(loader: GLTFLoader);
  84416. /** @hidden */
  84417. dispose(): void;
  84418. /** @hidden */
  84419. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84420. /** @hidden */
  84421. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84422. /** @hidden */
  84423. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84424. }
  84425. }
  84426. declare module BABYLON {
  84427. /**
  84428. * Class reading and parsing the MTL file bundled with the obj file.
  84429. */
  84430. export class MTLFileLoader {
  84431. /**
  84432. * Invert Y-Axis of referenced textures on load
  84433. */
  84434. static INVERT_TEXTURE_Y: boolean;
  84435. /**
  84436. * All material loaded from the mtl will be set here
  84437. */
  84438. materials: StandardMaterial[];
  84439. /**
  84440. * This function will read the mtl file and create each material described inside
  84441. * This function could be improve by adding :
  84442. * -some component missing (Ni, Tf...)
  84443. * -including the specific options available
  84444. *
  84445. * @param scene defines the scene the material will be created in
  84446. * @param data defines the mtl data to parse
  84447. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84448. * @param forAssetContainer defines if the material should be registered in the scene
  84449. */
  84450. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84451. /**
  84452. * Gets the texture for the material.
  84453. *
  84454. * If the material is imported from input file,
  84455. * We sanitize the url to ensure it takes the textre from aside the material.
  84456. *
  84457. * @param rootUrl The root url to load from
  84458. * @param value The value stored in the mtl
  84459. * @return The Texture
  84460. */
  84461. private static _getTexture;
  84462. }
  84463. }
  84464. declare module BABYLON {
  84465. /**
  84466. * Options for loading OBJ/MTL files
  84467. */
  84468. type MeshLoadOptions = {
  84469. /**
  84470. * Defines if UVs are optimized by default during load.
  84471. */
  84472. OptimizeWithUV: boolean;
  84473. /**
  84474. * Defines custom scaling of UV coordinates of loaded meshes.
  84475. */
  84476. UVScaling: Vector2;
  84477. /**
  84478. * Invert model on y-axis (does a model scaling inversion)
  84479. */
  84480. InvertY: boolean;
  84481. /**
  84482. * Invert Y-Axis of referenced textures on load
  84483. */
  84484. InvertTextureY: boolean;
  84485. /**
  84486. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84487. */
  84488. ImportVertexColors: boolean;
  84489. /**
  84490. * Compute the normals for the model, even if normals are present in the file.
  84491. */
  84492. ComputeNormals: boolean;
  84493. /**
  84494. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84495. */
  84496. SkipMaterials: boolean;
  84497. /**
  84498. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84499. */
  84500. MaterialLoadingFailsSilently: boolean;
  84501. };
  84502. /**
  84503. * OBJ file type loader.
  84504. * This is a babylon scene loader plugin.
  84505. */
  84506. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84507. /**
  84508. * Defines if UVs are optimized by default during load.
  84509. */
  84510. static OPTIMIZE_WITH_UV: boolean;
  84511. /**
  84512. * Invert model on y-axis (does a model scaling inversion)
  84513. */
  84514. static INVERT_Y: boolean;
  84515. /**
  84516. * Invert Y-Axis of referenced textures on load
  84517. */
  84518. static get INVERT_TEXTURE_Y(): boolean;
  84519. static set INVERT_TEXTURE_Y(value: boolean);
  84520. /**
  84521. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84522. */
  84523. static IMPORT_VERTEX_COLORS: boolean;
  84524. /**
  84525. * Compute the normals for the model, even if normals are present in the file.
  84526. */
  84527. static COMPUTE_NORMALS: boolean;
  84528. /**
  84529. * Defines custom scaling of UV coordinates of loaded meshes.
  84530. */
  84531. static UV_SCALING: Vector2;
  84532. /**
  84533. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84534. */
  84535. static SKIP_MATERIALS: boolean;
  84536. /**
  84537. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84538. *
  84539. * Defaults to true for backwards compatibility.
  84540. */
  84541. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84542. /**
  84543. * Defines the name of the plugin.
  84544. */
  84545. name: string;
  84546. /**
  84547. * Defines the extension the plugin is able to load.
  84548. */
  84549. extensions: string;
  84550. /** @hidden */
  84551. obj: RegExp;
  84552. /** @hidden */
  84553. group: RegExp;
  84554. /** @hidden */
  84555. mtllib: RegExp;
  84556. /** @hidden */
  84557. usemtl: RegExp;
  84558. /** @hidden */
  84559. smooth: RegExp;
  84560. /** @hidden */
  84561. vertexPattern: RegExp;
  84562. /** @hidden */
  84563. normalPattern: RegExp;
  84564. /** @hidden */
  84565. uvPattern: RegExp;
  84566. /** @hidden */
  84567. facePattern1: RegExp;
  84568. /** @hidden */
  84569. facePattern2: RegExp;
  84570. /** @hidden */
  84571. facePattern3: RegExp;
  84572. /** @hidden */
  84573. facePattern4: RegExp;
  84574. /** @hidden */
  84575. facePattern5: RegExp;
  84576. private _forAssetContainer;
  84577. private _meshLoadOptions;
  84578. /**
  84579. * Creates loader for .OBJ files
  84580. *
  84581. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84582. */
  84583. constructor(meshLoadOptions?: MeshLoadOptions);
  84584. private static get currentMeshLoadOptions();
  84585. /**
  84586. * Calls synchronously the MTL file attached to this obj.
  84587. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84588. * Without this function materials are not displayed in the first frame (but displayed after).
  84589. * In consequence it is impossible to get material information in your HTML file
  84590. *
  84591. * @param url The URL of the MTL file
  84592. * @param rootUrl
  84593. * @param onSuccess Callback function to be called when the MTL file is loaded
  84594. * @private
  84595. */
  84596. private _loadMTL;
  84597. /**
  84598. * Instantiates a OBJ file loader plugin.
  84599. * @returns the created plugin
  84600. */
  84601. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84602. /**
  84603. * If the data string can be loaded directly.
  84604. *
  84605. * @param data string containing the file data
  84606. * @returns if the data can be loaded directly
  84607. */
  84608. canDirectLoad(data: string): boolean;
  84609. /**
  84610. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84611. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84612. * @param scene the scene the meshes should be added to
  84613. * @param data the OBJ data to load
  84614. * @param rootUrl root url to load from
  84615. * @param onProgress event that fires when loading progress has occured
  84616. * @param fileName Defines the name of the file to load
  84617. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84618. */
  84619. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84620. /**
  84621. * Imports all objects from the loaded OBJ data and adds them to the scene
  84622. * @param scene the scene the objects should be added to
  84623. * @param data the OBJ data to load
  84624. * @param rootUrl root url to load from
  84625. * @param onProgress event that fires when loading progress has occured
  84626. * @param fileName Defines the name of the file to load
  84627. * @returns a promise which completes when objects have been loaded to the scene
  84628. */
  84629. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84630. /**
  84631. * Load into an asset container.
  84632. * @param scene The scene to load into
  84633. * @param data The data to import
  84634. * @param rootUrl The root url for scene and resources
  84635. * @param onProgress The callback when the load progresses
  84636. * @param fileName Defines the name of the file to load
  84637. * @returns The loaded asset container
  84638. */
  84639. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84640. /**
  84641. * Read the OBJ file and create an Array of meshes.
  84642. * Each mesh contains all information given by the OBJ and the MTL file.
  84643. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84644. *
  84645. * @param meshesNames
  84646. * @param scene Scene The scene where are displayed the data
  84647. * @param data String The content of the obj file
  84648. * @param rootUrl String The path to the folder
  84649. * @returns Array<AbstractMesh>
  84650. * @private
  84651. */
  84652. private _parseSolid;
  84653. }
  84654. }
  84655. declare module BABYLON {
  84656. /**
  84657. * STL file type loader.
  84658. * This is a babylon scene loader plugin.
  84659. */
  84660. export class STLFileLoader implements ISceneLoaderPlugin {
  84661. /** @hidden */
  84662. solidPattern: RegExp;
  84663. /** @hidden */
  84664. facetsPattern: RegExp;
  84665. /** @hidden */
  84666. normalPattern: RegExp;
  84667. /** @hidden */
  84668. vertexPattern: RegExp;
  84669. /**
  84670. * Defines the name of the plugin.
  84671. */
  84672. name: string;
  84673. /**
  84674. * Defines the extensions the stl loader is able to load.
  84675. * force data to come in as an ArrayBuffer
  84676. * we'll convert to string if it looks like it's an ASCII .stl
  84677. */
  84678. extensions: ISceneLoaderPluginExtensions;
  84679. /**
  84680. * Import meshes into a scene.
  84681. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84682. * @param scene The scene to import into
  84683. * @param data The data to import
  84684. * @param rootUrl The root url for scene and resources
  84685. * @param meshes The meshes array to import into
  84686. * @param particleSystems The particle systems array to import into
  84687. * @param skeletons The skeletons array to import into
  84688. * @param onError The callback when import fails
  84689. * @returns True if successful or false otherwise
  84690. */
  84691. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84692. /**
  84693. * Load into a scene.
  84694. * @param scene The scene to load into
  84695. * @param data The data to import
  84696. * @param rootUrl The root url for scene and resources
  84697. * @param onError The callback when import fails
  84698. * @returns true if successful or false otherwise
  84699. */
  84700. load(scene: Scene, data: any, rootUrl: string): boolean;
  84701. /**
  84702. * Load into an asset container.
  84703. * @param scene The scene to load into
  84704. * @param data The data to import
  84705. * @param rootUrl The root url for scene and resources
  84706. * @param onError The callback when import fails
  84707. * @returns The loaded asset container
  84708. */
  84709. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84710. private _isBinary;
  84711. private _parseBinary;
  84712. private _parseASCII;
  84713. }
  84714. }
  84715. declare module BABYLON {
  84716. /**
  84717. * Class for generating OBJ data from a Babylon scene.
  84718. */
  84719. export class OBJExport {
  84720. /**
  84721. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84722. * @param mesh defines the list of meshes to serialize
  84723. * @param materials defines if materials should be exported
  84724. * @param matlibname defines the name of the associated mtl file
  84725. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84726. * @returns the OBJ content
  84727. */
  84728. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84729. /**
  84730. * Exports the material(s) of a mesh in .MTL file format (text)
  84731. * @param mesh defines the mesh to extract the material from
  84732. * @returns the mtl content
  84733. */
  84734. static MTL(mesh: Mesh): string;
  84735. }
  84736. }
  84737. declare module BABYLON {
  84738. /** @hidden */
  84739. export var __IGLTFExporterExtension: number;
  84740. /**
  84741. * Interface for extending the exporter
  84742. * @hidden
  84743. */
  84744. export interface IGLTFExporterExtension {
  84745. /**
  84746. * The name of this extension
  84747. */
  84748. readonly name: string;
  84749. /**
  84750. * Defines whether this extension is enabled
  84751. */
  84752. enabled: boolean;
  84753. /**
  84754. * Defines whether this extension is required
  84755. */
  84756. required: boolean;
  84757. }
  84758. }
  84759. declare module BABYLON.GLTF2.Exporter {
  84760. /** @hidden */
  84761. export var __IGLTFExporterExtensionV2: number;
  84762. /**
  84763. * Interface for a glTF exporter extension
  84764. * @hidden
  84765. */
  84766. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84767. /**
  84768. * Define this method to modify the default behavior before exporting a texture
  84769. * @param context The context when loading the asset
  84770. * @param babylonTexture The Babylon.js texture
  84771. * @param mimeType The mime-type of the generated image
  84772. * @returns A promise that resolves with the exported texture
  84773. */
  84774. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84775. /**
  84776. * Define this method to get notified when a texture info is created
  84777. * @param context The context when loading the asset
  84778. * @param textureInfo The glTF texture info
  84779. * @param babylonTexture The Babylon.js texture
  84780. */
  84781. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84782. /**
  84783. * Define this method to modify the default behavior when exporting texture info
  84784. * @param context The context when loading the asset
  84785. * @param meshPrimitive glTF mesh primitive
  84786. * @param babylonSubMesh Babylon submesh
  84787. * @param binaryWriter glTF serializer binary writer instance
  84788. * @returns nullable IMeshPrimitive promise
  84789. */
  84790. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84791. /**
  84792. * Define this method to modify the default behavior when exporting a node
  84793. * @param context The context when exporting the node
  84794. * @param node glTF node
  84795. * @param babylonNode BabylonJS node
  84796. * @returns nullable INode promise
  84797. */
  84798. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84799. [key: number]: number;
  84800. }): Promise<Nullable<INode>>;
  84801. /**
  84802. * Define this method to modify the default behavior when exporting a material
  84803. * @param material glTF material
  84804. * @param babylonMaterial BabylonJS material
  84805. * @returns nullable IMaterial promise
  84806. */
  84807. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84808. /**
  84809. * Define this method to return additional textures to export from a material
  84810. * @param material glTF material
  84811. * @param babylonMaterial BabylonJS material
  84812. * @returns List of textures
  84813. */
  84814. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84815. /** Gets a boolean indicating that this extension was used */
  84816. wasUsed: boolean;
  84817. /** Gets a boolean indicating that this extension is required for the file to work */
  84818. required: boolean;
  84819. /**
  84820. * Called after the exporter state changes to EXPORTING
  84821. */
  84822. onExporting?(): void;
  84823. }
  84824. }
  84825. declare module BABYLON.GLTF2.Exporter {
  84826. /**
  84827. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84828. * @hidden
  84829. */
  84830. export class _GLTFMaterialExporter {
  84831. /**
  84832. * Represents the dielectric specular values for R, G and B
  84833. */
  84834. private static readonly _DielectricSpecular;
  84835. /**
  84836. * Allows the maximum specular power to be defined for material calculations
  84837. */
  84838. private static readonly _MaxSpecularPower;
  84839. /**
  84840. * Mapping to store textures
  84841. */
  84842. private _textureMap;
  84843. /**
  84844. * Numeric tolerance value
  84845. */
  84846. private static readonly _Epsilon;
  84847. /**
  84848. * Reference to the glTF Exporter
  84849. */
  84850. private _exporter;
  84851. constructor(exporter: _Exporter);
  84852. /**
  84853. * Specifies if two colors are approximately equal in value
  84854. * @param color1 first color to compare to
  84855. * @param color2 second color to compare to
  84856. * @param epsilon threshold value
  84857. */
  84858. private static FuzzyEquals;
  84859. /**
  84860. * Gets the materials from a Babylon scene and converts them to glTF materials
  84861. * @param scene babylonjs scene
  84862. * @param mimeType texture mime type
  84863. * @param images array of images
  84864. * @param textures array of textures
  84865. * @param materials array of materials
  84866. * @param imageData mapping of texture names to base64 textures
  84867. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84868. */
  84869. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84870. /**
  84871. * Makes a copy of the glTF material without the texture parameters
  84872. * @param originalMaterial original glTF material
  84873. * @returns glTF material without texture parameters
  84874. */
  84875. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84876. /**
  84877. * Specifies if the material has any texture parameters present
  84878. * @param material glTF Material
  84879. * @returns boolean specifying if texture parameters are present
  84880. */
  84881. _hasTexturesPresent(material: IMaterial): boolean;
  84882. /**
  84883. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84884. * @param babylonStandardMaterial
  84885. * @returns glTF Metallic Roughness Material representation
  84886. */
  84887. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84888. /**
  84889. * Computes the metallic factor
  84890. * @param diffuse diffused value
  84891. * @param specular specular value
  84892. * @param oneMinusSpecularStrength one minus the specular strength
  84893. * @returns metallic value
  84894. */
  84895. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84896. /**
  84897. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84898. * @param glTFMaterial glTF material
  84899. * @param babylonMaterial Babylon material
  84900. */
  84901. private static _SetAlphaMode;
  84902. /**
  84903. * Converts a Babylon Standard Material to a glTF Material
  84904. * @param babylonStandardMaterial BJS Standard Material
  84905. * @param mimeType mime type to use for the textures
  84906. * @param images array of glTF image interfaces
  84907. * @param textures array of glTF texture interfaces
  84908. * @param materials array of glTF material interfaces
  84909. * @param imageData map of image file name to data
  84910. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84911. */
  84912. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84913. private _finishMaterial;
  84914. /**
  84915. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84916. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84917. * @param mimeType mime type to use for the textures
  84918. * @param images array of glTF image interfaces
  84919. * @param textures array of glTF texture interfaces
  84920. * @param materials array of glTF material interfaces
  84921. * @param imageData map of image file name to data
  84922. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84923. */
  84924. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84925. /**
  84926. * Converts an image typed array buffer to a base64 image
  84927. * @param buffer typed array buffer
  84928. * @param width width of the image
  84929. * @param height height of the image
  84930. * @param mimeType mimetype of the image
  84931. * @returns base64 image string
  84932. */
  84933. private _createBase64FromCanvasAsync;
  84934. /**
  84935. * Generates a white texture based on the specified width and height
  84936. * @param width width of the texture in pixels
  84937. * @param height height of the texture in pixels
  84938. * @param scene babylonjs scene
  84939. * @returns white texture
  84940. */
  84941. private _createWhiteTexture;
  84942. /**
  84943. * 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
  84944. * @param texture1 first texture to resize
  84945. * @param texture2 second texture to resize
  84946. * @param scene babylonjs scene
  84947. * @returns resized textures or null
  84948. */
  84949. private _resizeTexturesToSameDimensions;
  84950. /**
  84951. * Converts an array of pixels to a Float32Array
  84952. * Throws an error if the pixel format is not supported
  84953. * @param pixels - array buffer containing pixel values
  84954. * @returns Float32 of pixels
  84955. */
  84956. private _convertPixelArrayToFloat32;
  84957. /**
  84958. * Convert Specular Glossiness Textures to Metallic Roughness
  84959. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84960. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84961. * @param diffuseTexture texture used to store diffuse information
  84962. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84963. * @param factors specular glossiness material factors
  84964. * @param mimeType the mime type to use for the texture
  84965. * @returns pbr metallic roughness interface or null
  84966. */
  84967. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84968. /**
  84969. * Converts specular glossiness material properties to metallic roughness
  84970. * @param specularGlossiness interface with specular glossiness material properties
  84971. * @returns interface with metallic roughness material properties
  84972. */
  84973. private _convertSpecularGlossinessToMetallicRoughness;
  84974. /**
  84975. * Calculates the surface reflectance, independent of lighting conditions
  84976. * @param color Color source to calculate brightness from
  84977. * @returns number representing the perceived brightness, or zero if color is undefined
  84978. */
  84979. private _getPerceivedBrightness;
  84980. /**
  84981. * Returns the maximum color component value
  84982. * @param color
  84983. * @returns maximum color component value, or zero if color is null or undefined
  84984. */
  84985. private _getMaxComponent;
  84986. /**
  84987. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84988. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84989. * @param mimeType mime type to use for the textures
  84990. * @param images array of glTF image interfaces
  84991. * @param textures array of glTF texture interfaces
  84992. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84993. * @param imageData map of image file name to data
  84994. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84995. * @returns glTF PBR Metallic Roughness factors
  84996. */
  84997. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84998. private _getGLTFTextureSampler;
  84999. private _getGLTFTextureWrapMode;
  85000. private _getGLTFTextureWrapModesSampler;
  85001. /**
  85002. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  85003. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85004. * @param mimeType mime type to use for the textures
  85005. * @param images array of glTF image interfaces
  85006. * @param textures array of glTF texture interfaces
  85007. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85008. * @param imageData map of image file name to data
  85009. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85010. * @returns glTF PBR Metallic Roughness factors
  85011. */
  85012. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  85013. /**
  85014. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85015. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85016. * @param mimeType mime type to use for the textures
  85017. * @param images array of glTF image interfaces
  85018. * @param textures array of glTF texture interfaces
  85019. * @param materials array of glTF material interfaces
  85020. * @param imageData map of image file name to data
  85021. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85022. */
  85023. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85024. private setMetallicRoughnessPbrMaterial;
  85025. private getPixelsFromTexture;
  85026. /**
  85027. * Extracts a texture from a Babylon texture into file data and glTF data
  85028. * @param babylonTexture Babylon texture to extract
  85029. * @param mimeType Mime Type of the babylonTexture
  85030. * @return glTF texture info, or null if the texture format is not supported
  85031. */
  85032. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85033. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85034. /**
  85035. * Builds a texture from base64 string
  85036. * @param base64Texture base64 texture string
  85037. * @param baseTextureName Name to use for the texture
  85038. * @param mimeType image mime type for the texture
  85039. * @param images array of images
  85040. * @param textures array of textures
  85041. * @param imageData map of image data
  85042. * @returns glTF texture info, or null if the texture format is not supported
  85043. */
  85044. private _getTextureInfoFromBase64;
  85045. }
  85046. }
  85047. declare module BABYLON {
  85048. /**
  85049. * Class for holding and downloading glTF file data
  85050. */
  85051. export class GLTFData {
  85052. /**
  85053. * Object which contains the file name as the key and its data as the value
  85054. */
  85055. glTFFiles: {
  85056. [fileName: string]: string | Blob;
  85057. };
  85058. /**
  85059. * Initializes the glTF file object
  85060. */
  85061. constructor();
  85062. /**
  85063. * Downloads the glTF data as files based on their names and data
  85064. */
  85065. downloadFiles(): void;
  85066. }
  85067. }
  85068. declare module BABYLON {
  85069. /**
  85070. * Holds a collection of exporter options and parameters
  85071. */
  85072. export interface IExportOptions {
  85073. /**
  85074. * Function which indicates whether a babylon node should be exported or not
  85075. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85076. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85077. */
  85078. shouldExportNode?(node: Node): boolean;
  85079. /**
  85080. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85081. * @param metadata source metadata to read from
  85082. * @returns the data to store to glTF node extras
  85083. */
  85084. metadataSelector?(metadata: any): any;
  85085. /**
  85086. * The sample rate to bake animation curves
  85087. */
  85088. animationSampleRate?: number;
  85089. /**
  85090. * Begin serialization without waiting for the scene to be ready
  85091. */
  85092. exportWithoutWaitingForScene?: boolean;
  85093. /**
  85094. * Indicates if coordinate system swapping root nodes should be included in export
  85095. */
  85096. includeCoordinateSystemConversionNodes?: boolean;
  85097. }
  85098. /**
  85099. * Class for generating glTF data from a Babylon scene.
  85100. */
  85101. export class GLTF2Export {
  85102. /**
  85103. * Exports the geometry of the scene to .gltf file format asynchronously
  85104. * @param scene Babylon scene with scene hierarchy information
  85105. * @param filePrefix File prefix to use when generating the glTF file
  85106. * @param options Exporter options
  85107. * @returns Returns an object with a .gltf file and associates texture names
  85108. * as keys and their data and paths as values
  85109. */
  85110. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85111. private static _PreExportAsync;
  85112. private static _PostExportAsync;
  85113. /**
  85114. * Exports the geometry of the scene to .glb file format asychronously
  85115. * @param scene Babylon scene with scene hierarchy information
  85116. * @param filePrefix File prefix to use when generating glb file
  85117. * @param options Exporter options
  85118. * @returns Returns an object with a .glb filename as key and data as value
  85119. */
  85120. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85121. }
  85122. }
  85123. declare module BABYLON.GLTF2.Exporter {
  85124. /**
  85125. * @hidden
  85126. */
  85127. export class _GLTFUtilities {
  85128. /**
  85129. * Creates a buffer view based on the supplied arguments
  85130. * @param bufferIndex index value of the specified buffer
  85131. * @param byteOffset byte offset value
  85132. * @param byteLength byte length of the bufferView
  85133. * @param byteStride byte distance between conequential elements
  85134. * @param name name of the buffer view
  85135. * @returns bufferView for glTF
  85136. */
  85137. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85138. /**
  85139. * Creates an accessor based on the supplied arguments
  85140. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85141. * @param name The name of the accessor
  85142. * @param type The type of the accessor
  85143. * @param componentType The datatype of components in the attribute
  85144. * @param count The number of attributes referenced by this accessor
  85145. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85146. * @param min Minimum value of each component in this attribute
  85147. * @param max Maximum value of each component in this attribute
  85148. * @returns accessor for glTF
  85149. */
  85150. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85151. /**
  85152. * Calculates the minimum and maximum values of an array of position floats
  85153. * @param positions Positions array of a mesh
  85154. * @param vertexStart Starting vertex offset to calculate min and max values
  85155. * @param vertexCount Number of vertices to check for min and max values
  85156. * @returns min number array and max number array
  85157. */
  85158. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85159. min: number[];
  85160. max: number[];
  85161. };
  85162. /**
  85163. * Converts a new right-handed Vector3
  85164. * @param vector vector3 array
  85165. * @returns right-handed Vector3
  85166. */
  85167. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85168. /**
  85169. * Converts a Vector3 to right-handed
  85170. * @param vector Vector3 to convert to right-handed
  85171. */
  85172. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85173. /**
  85174. * Converts a three element number array to right-handed
  85175. * @param vector number array to convert to right-handed
  85176. */
  85177. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85178. /**
  85179. * Converts a new right-handed Vector3
  85180. * @param vector vector3 array
  85181. * @returns right-handed Vector3
  85182. */
  85183. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85184. /**
  85185. * Converts a Vector3 to right-handed
  85186. * @param vector Vector3 to convert to right-handed
  85187. */
  85188. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85189. /**
  85190. * Converts a three element number array to right-handed
  85191. * @param vector number array to convert to right-handed
  85192. */
  85193. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85194. /**
  85195. * Converts a Vector4 to right-handed
  85196. * @param vector Vector4 to convert to right-handed
  85197. */
  85198. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85199. /**
  85200. * Converts a Vector4 to right-handed
  85201. * @param vector Vector4 to convert to right-handed
  85202. */
  85203. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85204. /**
  85205. * Converts a Quaternion to right-handed
  85206. * @param quaternion Source quaternion to convert to right-handed
  85207. */
  85208. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85209. /**
  85210. * Converts a Quaternion to right-handed
  85211. * @param quaternion Source quaternion to convert to right-handed
  85212. */
  85213. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85214. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85215. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85216. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85217. }
  85218. }
  85219. declare module BABYLON.GLTF2.Exporter {
  85220. /**
  85221. * Converts Babylon Scene into glTF 2.0.
  85222. * @hidden
  85223. */
  85224. export class _Exporter {
  85225. /**
  85226. * Stores the glTF to export
  85227. */
  85228. _glTF: IGLTF;
  85229. /**
  85230. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85231. */
  85232. _bufferViews: IBufferView[];
  85233. /**
  85234. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85235. */
  85236. _accessors: IAccessor[];
  85237. /**
  85238. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85239. */
  85240. _nodes: INode[];
  85241. /**
  85242. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85243. */
  85244. private _scenes;
  85245. /**
  85246. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85247. */
  85248. private _meshes;
  85249. /**
  85250. * Stores all the generated material information, which represents the appearance of each primitive
  85251. */
  85252. _materials: IMaterial[];
  85253. _materialMap: {
  85254. [materialID: number]: number;
  85255. };
  85256. /**
  85257. * Stores all the generated texture information, which is referenced by glTF materials
  85258. */
  85259. _textures: ITexture[];
  85260. /**
  85261. * Stores all the generated image information, which is referenced by glTF textures
  85262. */
  85263. _images: IImage[];
  85264. /**
  85265. * Stores all the texture samplers
  85266. */
  85267. _samplers: ISampler[];
  85268. /**
  85269. * Stores all the generated glTF skins
  85270. */
  85271. _skins: ISkin[];
  85272. /**
  85273. * Stores all the generated animation samplers, which is referenced by glTF animations
  85274. */
  85275. /**
  85276. * Stores the animations for glTF models
  85277. */
  85278. private _animations;
  85279. /**
  85280. * Stores the total amount of bytes stored in the glTF buffer
  85281. */
  85282. private _totalByteLength;
  85283. /**
  85284. * Stores a reference to the Babylon scene containing the source geometry and material information
  85285. */
  85286. _babylonScene: Scene;
  85287. /**
  85288. * Stores a map of the image data, where the key is the file name and the value
  85289. * is the image data
  85290. */
  85291. _imageData: {
  85292. [fileName: string]: {
  85293. data: Uint8Array;
  85294. mimeType: ImageMimeType;
  85295. };
  85296. };
  85297. protected _orderedImageData: Array<{
  85298. data: Uint8Array;
  85299. mimeType: ImageMimeType;
  85300. }>;
  85301. /**
  85302. * Stores a map of the unique id of a node to its index in the node array
  85303. */
  85304. _nodeMap: {
  85305. [key: number]: number;
  85306. };
  85307. /**
  85308. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85309. */
  85310. _convertToRightHandedSystem: boolean;
  85311. /**
  85312. * Specifies if a Babylon node should be converted to right-handed on export
  85313. */
  85314. _convertToRightHandedSystemMap: {
  85315. [nodeId: number]: boolean;
  85316. };
  85317. _includeCoordinateSystemConversionNodes: boolean;
  85318. /**
  85319. * Baked animation sample rate
  85320. */
  85321. private _animationSampleRate;
  85322. private _options;
  85323. private _localEngine;
  85324. _glTFMaterialExporter: _GLTFMaterialExporter;
  85325. private _extensions;
  85326. private static _ExtensionNames;
  85327. private static _ExtensionFactories;
  85328. private _applyExtension;
  85329. private _applyExtensions;
  85330. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85331. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85332. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85333. [key: number]: number;
  85334. }): Promise<Nullable<INode>>;
  85335. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85336. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85337. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85338. private _forEachExtensions;
  85339. private _extensionsOnExporting;
  85340. /**
  85341. * Load glTF serializer extensions
  85342. */
  85343. private _loadExtensions;
  85344. /**
  85345. * Creates a glTF Exporter instance, which can accept optional exporter options
  85346. * @param babylonScene Babylon scene object
  85347. * @param options Options to modify the behavior of the exporter
  85348. */
  85349. constructor(babylonScene: Scene, options?: IExportOptions);
  85350. dispose(): void;
  85351. /**
  85352. * Registers a glTF exporter extension
  85353. * @param name Name of the extension to export
  85354. * @param factory The factory function that creates the exporter extension
  85355. */
  85356. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85357. /**
  85358. * Un-registers an exporter extension
  85359. * @param name The name fo the exporter extension
  85360. * @returns A boolean indicating whether the extension has been un-registered
  85361. */
  85362. static UnregisterExtension(name: string): boolean;
  85363. /**
  85364. * Lazy load a local engine
  85365. */
  85366. _getLocalEngine(): Engine;
  85367. private reorderIndicesBasedOnPrimitiveMode;
  85368. /**
  85369. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85370. * clock-wise during export to glTF
  85371. * @param submesh BabylonJS submesh
  85372. * @param primitiveMode Primitive mode of the mesh
  85373. * @param sideOrientation the winding order of the submesh
  85374. * @param vertexBufferKind The type of vertex attribute
  85375. * @param meshAttributeArray The vertex attribute data
  85376. * @param byteOffset The offset to the binary data
  85377. * @param binaryWriter The binary data for the glTF file
  85378. * @param convertToRightHandedSystem Converts the values to right-handed
  85379. */
  85380. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85381. /**
  85382. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85383. * clock-wise during export to glTF
  85384. * @param submesh BabylonJS submesh
  85385. * @param primitiveMode Primitive mode of the mesh
  85386. * @param sideOrientation the winding order of the submesh
  85387. * @param vertexBufferKind The type of vertex attribute
  85388. * @param meshAttributeArray The vertex attribute data
  85389. * @param byteOffset The offset to the binary data
  85390. * @param binaryWriter The binary data for the glTF file
  85391. * @param convertToRightHandedSystem Converts the values to right-handed
  85392. */
  85393. private reorderTriangleFillMode;
  85394. /**
  85395. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85396. * clock-wise during export to glTF
  85397. * @param submesh BabylonJS submesh
  85398. * @param primitiveMode Primitive mode of the mesh
  85399. * @param sideOrientation the winding order of the submesh
  85400. * @param vertexBufferKind The type of vertex attribute
  85401. * @param meshAttributeArray The vertex attribute data
  85402. * @param byteOffset The offset to the binary data
  85403. * @param binaryWriter The binary data for the glTF file
  85404. * @param convertToRightHandedSystem Converts the values to right-handed
  85405. */
  85406. private reorderTriangleStripDrawMode;
  85407. /**
  85408. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85409. * clock-wise during export to glTF
  85410. * @param submesh BabylonJS submesh
  85411. * @param primitiveMode Primitive mode of the mesh
  85412. * @param sideOrientation the winding order of the submesh
  85413. * @param vertexBufferKind The type of vertex attribute
  85414. * @param meshAttributeArray The vertex attribute data
  85415. * @param byteOffset The offset to the binary data
  85416. * @param binaryWriter The binary data for the glTF file
  85417. * @param convertToRightHandedSystem Converts the values to right-handed
  85418. */
  85419. private reorderTriangleFanMode;
  85420. /**
  85421. * Writes the vertex attribute data to binary
  85422. * @param vertices The vertices to write to the binary writer
  85423. * @param byteOffset The offset into the binary writer to overwrite binary data
  85424. * @param vertexAttributeKind The vertex attribute type
  85425. * @param meshAttributeArray The vertex attribute data
  85426. * @param binaryWriter The writer containing the binary data
  85427. * @param convertToRightHandedSystem Converts the values to right-handed
  85428. */
  85429. private writeVertexAttributeData;
  85430. /**
  85431. * Writes mesh attribute data to a data buffer
  85432. * Returns the bytelength of the data
  85433. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85434. * @param meshAttributeArray Array containing the attribute data
  85435. * @param byteStride Specifies the space between data
  85436. * @param binaryWriter The buffer to write the binary data to
  85437. * @param convertToRightHandedSystem Converts the values to right-handed
  85438. */
  85439. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85440. /**
  85441. * Writes mesh attribute data to a data buffer
  85442. * Returns the bytelength of the data
  85443. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85444. * @param meshAttributeArray Array containing the attribute data
  85445. * @param byteStride Specifies the space between data
  85446. * @param binaryWriter The buffer to write the binary data to
  85447. * @param convertToRightHandedSystem Converts the values to right-handed
  85448. */
  85449. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85450. /**
  85451. * Generates glTF json data
  85452. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85453. * @param glTFPrefix Text to use when prefixing a glTF file
  85454. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85455. * @returns json data as string
  85456. */
  85457. private generateJSON;
  85458. /**
  85459. * Generates data for .gltf and .bin files based on the glTF prefix string
  85460. * @param glTFPrefix Text to use when prefixing a glTF file
  85461. * @param dispose Dispose the exporter
  85462. * @returns GLTFData with glTF file data
  85463. */
  85464. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85465. /**
  85466. * Creates a binary buffer for glTF
  85467. * @returns array buffer for binary data
  85468. */
  85469. private _generateBinaryAsync;
  85470. /**
  85471. * Pads the number to a multiple of 4
  85472. * @param num number to pad
  85473. * @returns padded number
  85474. */
  85475. private _getPadding;
  85476. /**
  85477. * @hidden
  85478. */
  85479. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85480. /**
  85481. * Sets the TRS for each node
  85482. * @param node glTF Node for storing the transformation data
  85483. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85484. * @param convertToRightHandedSystem Converts the values to right-handed
  85485. */
  85486. private setNodeTransformation;
  85487. private getVertexBufferFromMesh;
  85488. /**
  85489. * Creates a bufferview based on the vertices type for the Babylon mesh
  85490. * @param kind Indicates the type of vertices data
  85491. * @param componentType Indicates the numerical type used to store the data
  85492. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85493. * @param binaryWriter The buffer to write the bufferview data to
  85494. * @param convertToRightHandedSystem Converts the values to right-handed
  85495. */
  85496. private createBufferViewKind;
  85497. /**
  85498. * Creates a bufferview based on the vertices type for the Babylon mesh
  85499. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85500. * @param babylonMorphTarget the morph target to be exported
  85501. * @param binaryWriter The buffer to write the bufferview data to
  85502. * @param convertToRightHandedSystem Converts the values to right-handed
  85503. */
  85504. private setMorphTargetAttributes;
  85505. /**
  85506. * The primitive mode of the Babylon mesh
  85507. * @param babylonMesh The BabylonJS mesh
  85508. */
  85509. private getMeshPrimitiveMode;
  85510. /**
  85511. * Sets the primitive mode of the glTF mesh primitive
  85512. * @param meshPrimitive glTF mesh primitive
  85513. * @param primitiveMode The primitive mode
  85514. */
  85515. private setPrimitiveMode;
  85516. /**
  85517. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85518. * @param meshPrimitive glTF mesh primitive
  85519. * @param attributeKind vertex attribute
  85520. * @returns boolean specifying if uv coordinates are present
  85521. */
  85522. private setAttributeKind;
  85523. /**
  85524. * Sets data for the primitive attributes of each submesh
  85525. * @param mesh glTF Mesh object to store the primitive attribute information
  85526. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85527. * @param binaryWriter Buffer to write the attribute data to
  85528. * @param convertToRightHandedSystem Converts the values to right-handed
  85529. */
  85530. private setPrimitiveAttributesAsync;
  85531. /**
  85532. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85533. * @param node The node to check
  85534. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85535. */
  85536. private isBabylonCoordinateSystemConvertingNode;
  85537. /**
  85538. * Creates a glTF scene based on the array of meshes
  85539. * Returns the the total byte offset
  85540. * @param babylonScene Babylon scene to get the mesh data from
  85541. * @param binaryWriter Buffer to write binary data to
  85542. */
  85543. private createSceneAsync;
  85544. /**
  85545. * Creates a mapping of Node unique id to node index and handles animations
  85546. * @param babylonScene Babylon Scene
  85547. * @param nodes Babylon transform nodes
  85548. * @param binaryWriter Buffer to write binary data to
  85549. * @returns Node mapping of unique id to index
  85550. */
  85551. private createNodeMapAndAnimationsAsync;
  85552. /**
  85553. * Creates a glTF node from a Babylon mesh
  85554. * @param babylonMesh Source Babylon mesh
  85555. * @param binaryWriter Buffer for storing geometry data
  85556. * @param convertToRightHandedSystem Converts the values to right-handed
  85557. * @param nodeMap Node mapping of unique id to glTF node index
  85558. * @returns glTF node
  85559. */
  85560. private createNodeAsync;
  85561. /**
  85562. * Creates a glTF skin from a Babylon skeleton
  85563. * @param babylonScene Babylon Scene
  85564. * @param nodes Babylon transform nodes
  85565. * @param binaryWriter Buffer to write binary data to
  85566. * @returns Node mapping of unique id to index
  85567. */
  85568. private createSkinsAsync;
  85569. }
  85570. /**
  85571. * @hidden
  85572. *
  85573. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85574. */
  85575. export class _BinaryWriter {
  85576. /**
  85577. * Array buffer which stores all binary data
  85578. */
  85579. private _arrayBuffer;
  85580. /**
  85581. * View of the array buffer
  85582. */
  85583. private _dataView;
  85584. /**
  85585. * byte offset of data in array buffer
  85586. */
  85587. private _byteOffset;
  85588. /**
  85589. * Initialize binary writer with an initial byte length
  85590. * @param byteLength Initial byte length of the array buffer
  85591. */
  85592. constructor(byteLength: number);
  85593. /**
  85594. * Resize the array buffer to the specified byte length
  85595. * @param byteLength
  85596. */
  85597. private resizeBuffer;
  85598. /**
  85599. * Get an array buffer with the length of the byte offset
  85600. * @returns ArrayBuffer resized to the byte offset
  85601. */
  85602. getArrayBuffer(): ArrayBuffer;
  85603. /**
  85604. * Get the byte offset of the array buffer
  85605. * @returns byte offset
  85606. */
  85607. getByteOffset(): number;
  85608. /**
  85609. * Stores an UInt8 in the array buffer
  85610. * @param entry
  85611. * @param byteOffset If defined, specifies where to set the value as an offset.
  85612. */
  85613. setUInt8(entry: number, byteOffset?: number): void;
  85614. /**
  85615. * Stores an UInt16 in the array buffer
  85616. * @param entry
  85617. * @param byteOffset If defined, specifies where to set the value as an offset.
  85618. */
  85619. setUInt16(entry: number, byteOffset?: number): void;
  85620. /**
  85621. * Gets an UInt32 in the array buffer
  85622. * @param entry
  85623. * @param byteOffset If defined, specifies where to set the value as an offset.
  85624. */
  85625. getUInt32(byteOffset: number): number;
  85626. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85627. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85628. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85629. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85630. /**
  85631. * Stores a Float32 in the array buffer
  85632. * @param entry
  85633. */
  85634. setFloat32(entry: number, byteOffset?: number): void;
  85635. /**
  85636. * Stores an UInt32 in the array buffer
  85637. * @param entry
  85638. * @param byteOffset If defined, specifies where to set the value as an offset.
  85639. */
  85640. setUInt32(entry: number, byteOffset?: number): void;
  85641. }
  85642. }
  85643. declare module BABYLON.GLTF2.Exporter {
  85644. /**
  85645. * @hidden
  85646. * Interface to store animation data.
  85647. */
  85648. export interface _IAnimationData {
  85649. /**
  85650. * Keyframe data.
  85651. */
  85652. inputs: number[];
  85653. /**
  85654. * Value data.
  85655. */
  85656. outputs: number[][];
  85657. /**
  85658. * Animation interpolation data.
  85659. */
  85660. samplerInterpolation: AnimationSamplerInterpolation;
  85661. /**
  85662. * Minimum keyframe value.
  85663. */
  85664. inputsMin: number;
  85665. /**
  85666. * Maximum keyframe value.
  85667. */
  85668. inputsMax: number;
  85669. }
  85670. /**
  85671. * @hidden
  85672. */
  85673. export interface _IAnimationInfo {
  85674. /**
  85675. * The target channel for the animation
  85676. */
  85677. animationChannelTargetPath: AnimationChannelTargetPath;
  85678. /**
  85679. * The glTF accessor type for the data.
  85680. */
  85681. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85682. /**
  85683. * Specifies if quaternions should be used.
  85684. */
  85685. useQuaternion: boolean;
  85686. }
  85687. /**
  85688. * @hidden
  85689. * Utility class for generating glTF animation data from BabylonJS.
  85690. */
  85691. export class _GLTFAnimation {
  85692. /**
  85693. * @ignore
  85694. *
  85695. * Creates glTF channel animation from BabylonJS animation.
  85696. * @param babylonTransformNode - BabylonJS mesh.
  85697. * @param animation - animation.
  85698. * @param animationChannelTargetPath - The target animation channel.
  85699. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85700. * @param useQuaternion - Specifies if quaternions are used.
  85701. * @returns nullable IAnimationData
  85702. */
  85703. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85704. private static _DeduceAnimationInfo;
  85705. /**
  85706. * @ignore
  85707. * Create node animations from the transform node animations
  85708. * @param babylonNode
  85709. * @param runtimeGLTFAnimation
  85710. * @param idleGLTFAnimations
  85711. * @param nodeMap
  85712. * @param nodes
  85713. * @param binaryWriter
  85714. * @param bufferViews
  85715. * @param accessors
  85716. * @param convertToRightHandedSystem
  85717. * @param animationSampleRate
  85718. */
  85719. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85720. [key: number]: number;
  85721. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85722. /**
  85723. * @ignore
  85724. * Create individual morph animations from the mesh's morph target animation tracks
  85725. * @param babylonNode
  85726. * @param runtimeGLTFAnimation
  85727. * @param idleGLTFAnimations
  85728. * @param nodeMap
  85729. * @param nodes
  85730. * @param binaryWriter
  85731. * @param bufferViews
  85732. * @param accessors
  85733. * @param convertToRightHandedSystem
  85734. * @param animationSampleRate
  85735. */
  85736. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85737. [key: number]: number;
  85738. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85739. /**
  85740. * @ignore
  85741. * Create node and morph animations from the animation groups
  85742. * @param babylonScene
  85743. * @param glTFAnimations
  85744. * @param nodeMap
  85745. * @param nodes
  85746. * @param binaryWriter
  85747. * @param bufferViews
  85748. * @param accessors
  85749. * @param convertToRightHandedSystemMap
  85750. * @param animationSampleRate
  85751. */
  85752. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85753. [key: number]: number;
  85754. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85755. [nodeId: number]: boolean;
  85756. }, animationSampleRate: number): void;
  85757. private static AddAnimation;
  85758. /**
  85759. * Create a baked animation
  85760. * @param babylonTransformNode BabylonJS mesh
  85761. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85762. * @param animationChannelTargetPath animation target channel
  85763. * @param minFrame minimum animation frame
  85764. * @param maxFrame maximum animation frame
  85765. * @param fps frames per second of the animation
  85766. * @param inputs input key frames of the animation
  85767. * @param outputs output key frame data of the animation
  85768. * @param convertToRightHandedSystem converts the values to right-handed
  85769. * @param useQuaternion specifies if quaternions should be used
  85770. */
  85771. private static _CreateBakedAnimation;
  85772. private static _ConvertFactorToVector3OrQuaternion;
  85773. private static _SetInterpolatedValue;
  85774. /**
  85775. * Creates linear animation from the animation key frames
  85776. * @param babylonTransformNode BabylonJS mesh
  85777. * @param animation BabylonJS animation
  85778. * @param animationChannelTargetPath The target animation channel
  85779. * @param frameDelta The difference between the last and first frame of the animation
  85780. * @param inputs Array to store the key frame times
  85781. * @param outputs Array to store the key frame data
  85782. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85783. * @param useQuaternion Specifies if quaternions are used in the animation
  85784. */
  85785. private static _CreateLinearOrStepAnimation;
  85786. /**
  85787. * Creates cubic spline animation from the animation key frames
  85788. * @param babylonTransformNode BabylonJS mesh
  85789. * @param animation BabylonJS animation
  85790. * @param animationChannelTargetPath The target animation channel
  85791. * @param frameDelta The difference between the last and first frame of the animation
  85792. * @param inputs Array to store the key frame times
  85793. * @param outputs Array to store the key frame data
  85794. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85795. * @param useQuaternion Specifies if quaternions are used in the animation
  85796. */
  85797. private static _CreateCubicSplineAnimation;
  85798. private static _GetBasePositionRotationOrScale;
  85799. /**
  85800. * Adds a key frame value
  85801. * @param keyFrame
  85802. * @param animation
  85803. * @param outputs
  85804. * @param animationChannelTargetPath
  85805. * @param basePositionRotationOrScale
  85806. * @param convertToRightHandedSystem
  85807. * @param useQuaternion
  85808. */
  85809. private static _AddKeyframeValue;
  85810. /**
  85811. * Determine the interpolation based on the key frames
  85812. * @param keyFrames
  85813. * @param animationChannelTargetPath
  85814. * @param useQuaternion
  85815. */
  85816. private static _DeduceInterpolation;
  85817. /**
  85818. * Adds an input tangent or output tangent to the output data
  85819. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85820. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85821. * @param outputs The animation data by keyframe
  85822. * @param animationChannelTargetPath The target animation channel
  85823. * @param interpolation The interpolation type
  85824. * @param keyFrame The key frame with the animation data
  85825. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85826. * @param useQuaternion Specifies if quaternions are used
  85827. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85828. */
  85829. private static AddSplineTangent;
  85830. /**
  85831. * Get the minimum and maximum key frames' frame values
  85832. * @param keyFrames animation key frames
  85833. * @returns the minimum and maximum key frame value
  85834. */
  85835. private static calculateMinMaxKeyFrames;
  85836. }
  85837. }
  85838. declare module BABYLON.GLTF2.Exporter {
  85839. /** @hidden */
  85840. export var textureTransformPixelShader: {
  85841. name: string;
  85842. shader: string;
  85843. };
  85844. }
  85845. declare module BABYLON.GLTF2.Exporter.Extensions {
  85846. /**
  85847. * @hidden
  85848. */
  85849. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85850. private _recordedTextures;
  85851. /** Name of this extension */
  85852. readonly name: string;
  85853. /** Defines whether this extension is enabled */
  85854. enabled: boolean;
  85855. /** Defines whether this extension is required */
  85856. required: boolean;
  85857. /** Reference to the glTF exporter */
  85858. private _wasUsed;
  85859. constructor(exporter: _Exporter);
  85860. dispose(): void;
  85861. /** @hidden */
  85862. get wasUsed(): boolean;
  85863. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85864. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85865. /**
  85866. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85867. * @param babylonTexture
  85868. * @param offset
  85869. * @param rotation
  85870. * @param scale
  85871. * @param scene
  85872. */
  85873. private _textureTransformTextureAsync;
  85874. }
  85875. }
  85876. declare module BABYLON.GLTF2.Exporter.Extensions {
  85877. /**
  85878. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85879. */
  85880. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85881. /** The name of this extension. */
  85882. readonly name: string;
  85883. /** Defines whether this extension is enabled. */
  85884. enabled: boolean;
  85885. /** Defines whether this extension is required */
  85886. required: boolean;
  85887. /** Reference to the glTF exporter */
  85888. private _exporter;
  85889. private _lights;
  85890. /** @hidden */
  85891. constructor(exporter: _Exporter);
  85892. /** @hidden */
  85893. dispose(): void;
  85894. /** @hidden */
  85895. get wasUsed(): boolean;
  85896. /** @hidden */
  85897. onExporting(): void;
  85898. /**
  85899. * Define this method to modify the default behavior when exporting a node
  85900. * @param context The context when exporting the node
  85901. * @param node glTF node
  85902. * @param babylonNode BabylonJS node
  85903. * @param nodeMap Node mapping of unique id to glTF node index
  85904. * @returns nullable INode promise
  85905. */
  85906. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85907. [key: number]: number;
  85908. }): Promise<Nullable<INode>>;
  85909. }
  85910. }
  85911. declare module BABYLON.GLTF2.Exporter.Extensions {
  85912. /**
  85913. * @hidden
  85914. */
  85915. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85916. /** Name of this extension */
  85917. readonly name: string;
  85918. /** Defines whether this extension is enabled */
  85919. enabled: boolean;
  85920. /** Defines whether this extension is required */
  85921. required: boolean;
  85922. /** Reference to the glTF exporter */
  85923. private _textureInfos;
  85924. private _exportedTextures;
  85925. private _wasUsed;
  85926. constructor(exporter: _Exporter);
  85927. dispose(): void;
  85928. /** @hidden */
  85929. get wasUsed(): boolean;
  85930. private _getTextureIndex;
  85931. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85932. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85933. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85934. }
  85935. }
  85936. declare module BABYLON.GLTF2.Exporter.Extensions {
  85937. /**
  85938. * @hidden
  85939. */
  85940. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85941. /** Name of this extension */
  85942. readonly name: string;
  85943. /** Defines whether this extension is enabled */
  85944. enabled: boolean;
  85945. /** Defines whether this extension is required */
  85946. required: boolean;
  85947. private _wasUsed;
  85948. constructor(exporter: _Exporter);
  85949. /** @hidden */
  85950. get wasUsed(): boolean;
  85951. dispose(): void;
  85952. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85953. }
  85954. }
  85955. declare module BABYLON {
  85956. /**
  85957. * Class for generating STL data from a Babylon scene.
  85958. */
  85959. export class STLExport {
  85960. /**
  85961. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85962. * @param meshes list defines the mesh to serialize
  85963. * @param download triggers the automatic download of the file.
  85964. * @param fileName changes the downloads fileName.
  85965. * @param binary changes the STL to a binary type.
  85966. * @param isLittleEndian toggle for binary type exporter.
  85967. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  85968. * @returns the STL as UTF8 string
  85969. */
  85970. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  85971. }
  85972. }
  85973. declare module "babylonjs-gltf2interface" {
  85974. export = BABYLON.GLTF2;
  85975. }
  85976. /**
  85977. * Module for glTF 2.0 Interface
  85978. */
  85979. declare module BABYLON.GLTF2 {
  85980. /**
  85981. * The datatype of the components in the attribute
  85982. */
  85983. const enum AccessorComponentType {
  85984. /**
  85985. * Byte
  85986. */
  85987. BYTE = 5120,
  85988. /**
  85989. * Unsigned Byte
  85990. */
  85991. UNSIGNED_BYTE = 5121,
  85992. /**
  85993. * Short
  85994. */
  85995. SHORT = 5122,
  85996. /**
  85997. * Unsigned Short
  85998. */
  85999. UNSIGNED_SHORT = 5123,
  86000. /**
  86001. * Unsigned Int
  86002. */
  86003. UNSIGNED_INT = 5125,
  86004. /**
  86005. * Float
  86006. */
  86007. FLOAT = 5126,
  86008. }
  86009. /**
  86010. * Specifies if the attirbute is a scalar, vector, or matrix
  86011. */
  86012. const enum AccessorType {
  86013. /**
  86014. * Scalar
  86015. */
  86016. SCALAR = "SCALAR",
  86017. /**
  86018. * Vector2
  86019. */
  86020. VEC2 = "VEC2",
  86021. /**
  86022. * Vector3
  86023. */
  86024. VEC3 = "VEC3",
  86025. /**
  86026. * Vector4
  86027. */
  86028. VEC4 = "VEC4",
  86029. /**
  86030. * Matrix2x2
  86031. */
  86032. MAT2 = "MAT2",
  86033. /**
  86034. * Matrix3x3
  86035. */
  86036. MAT3 = "MAT3",
  86037. /**
  86038. * Matrix4x4
  86039. */
  86040. MAT4 = "MAT4",
  86041. }
  86042. /**
  86043. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86044. */
  86045. const enum AnimationChannelTargetPath {
  86046. /**
  86047. * Translation
  86048. */
  86049. TRANSLATION = "translation",
  86050. /**
  86051. * Rotation
  86052. */
  86053. ROTATION = "rotation",
  86054. /**
  86055. * Scale
  86056. */
  86057. SCALE = "scale",
  86058. /**
  86059. * Weights
  86060. */
  86061. WEIGHTS = "weights",
  86062. }
  86063. /**
  86064. * Interpolation algorithm
  86065. */
  86066. const enum AnimationSamplerInterpolation {
  86067. /**
  86068. * The animated values are linearly interpolated between keyframes
  86069. */
  86070. LINEAR = "LINEAR",
  86071. /**
  86072. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86073. */
  86074. STEP = "STEP",
  86075. /**
  86076. * The animation's interpolation is computed using a cubic spline with specified tangents
  86077. */
  86078. CUBICSPLINE = "CUBICSPLINE",
  86079. }
  86080. /**
  86081. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86082. */
  86083. const enum CameraType {
  86084. /**
  86085. * A perspective camera containing properties to create a perspective projection matrix
  86086. */
  86087. PERSPECTIVE = "perspective",
  86088. /**
  86089. * An orthographic camera containing properties to create an orthographic projection matrix
  86090. */
  86091. ORTHOGRAPHIC = "orthographic",
  86092. }
  86093. /**
  86094. * The mime-type of the image
  86095. */
  86096. const enum ImageMimeType {
  86097. /**
  86098. * JPEG Mime-type
  86099. */
  86100. JPEG = "image/jpeg",
  86101. /**
  86102. * PNG Mime-type
  86103. */
  86104. PNG = "image/png",
  86105. }
  86106. /**
  86107. * The alpha rendering mode of the material
  86108. */
  86109. const enum MaterialAlphaMode {
  86110. /**
  86111. * The alpha value is ignored and the rendered output is fully opaque
  86112. */
  86113. OPAQUE = "OPAQUE",
  86114. /**
  86115. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86116. */
  86117. MASK = "MASK",
  86118. /**
  86119. * 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)
  86120. */
  86121. BLEND = "BLEND",
  86122. }
  86123. /**
  86124. * The type of the primitives to render
  86125. */
  86126. const enum MeshPrimitiveMode {
  86127. /**
  86128. * Points
  86129. */
  86130. POINTS = 0,
  86131. /**
  86132. * Lines
  86133. */
  86134. LINES = 1,
  86135. /**
  86136. * Line Loop
  86137. */
  86138. LINE_LOOP = 2,
  86139. /**
  86140. * Line Strip
  86141. */
  86142. LINE_STRIP = 3,
  86143. /**
  86144. * Triangles
  86145. */
  86146. TRIANGLES = 4,
  86147. /**
  86148. * Triangle Strip
  86149. */
  86150. TRIANGLE_STRIP = 5,
  86151. /**
  86152. * Triangle Fan
  86153. */
  86154. TRIANGLE_FAN = 6,
  86155. }
  86156. /**
  86157. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86158. */
  86159. const enum TextureMagFilter {
  86160. /**
  86161. * Nearest
  86162. */
  86163. NEAREST = 9728,
  86164. /**
  86165. * Linear
  86166. */
  86167. LINEAR = 9729,
  86168. }
  86169. /**
  86170. * Minification filter. All valid values correspond to WebGL enums
  86171. */
  86172. const enum TextureMinFilter {
  86173. /**
  86174. * Nearest
  86175. */
  86176. NEAREST = 9728,
  86177. /**
  86178. * Linear
  86179. */
  86180. LINEAR = 9729,
  86181. /**
  86182. * Nearest Mip-Map Nearest
  86183. */
  86184. NEAREST_MIPMAP_NEAREST = 9984,
  86185. /**
  86186. * Linear Mipmap Nearest
  86187. */
  86188. LINEAR_MIPMAP_NEAREST = 9985,
  86189. /**
  86190. * Nearest Mipmap Linear
  86191. */
  86192. NEAREST_MIPMAP_LINEAR = 9986,
  86193. /**
  86194. * Linear Mipmap Linear
  86195. */
  86196. LINEAR_MIPMAP_LINEAR = 9987,
  86197. }
  86198. /**
  86199. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86200. */
  86201. const enum TextureWrapMode {
  86202. /**
  86203. * Clamp to Edge
  86204. */
  86205. CLAMP_TO_EDGE = 33071,
  86206. /**
  86207. * Mirrored Repeat
  86208. */
  86209. MIRRORED_REPEAT = 33648,
  86210. /**
  86211. * Repeat
  86212. */
  86213. REPEAT = 10497,
  86214. }
  86215. /**
  86216. * glTF Property
  86217. */
  86218. interface IProperty {
  86219. /**
  86220. * Dictionary object with extension-specific objects
  86221. */
  86222. extensions?: {
  86223. [key: string]: any;
  86224. };
  86225. /**
  86226. * Application-Specific data
  86227. */
  86228. extras?: any;
  86229. }
  86230. /**
  86231. * glTF Child of Root Property
  86232. */
  86233. interface IChildRootProperty extends IProperty {
  86234. /**
  86235. * The user-defined name of this object
  86236. */
  86237. name?: string;
  86238. }
  86239. /**
  86240. * Indices of those attributes that deviate from their initialization value
  86241. */
  86242. interface IAccessorSparseIndices extends IProperty {
  86243. /**
  86244. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86245. */
  86246. bufferView: number;
  86247. /**
  86248. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86249. */
  86250. byteOffset?: number;
  86251. /**
  86252. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86253. */
  86254. componentType: AccessorComponentType;
  86255. }
  86256. /**
  86257. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86258. */
  86259. interface IAccessorSparseValues extends IProperty {
  86260. /**
  86261. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86262. */
  86263. bufferView: number;
  86264. /**
  86265. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86266. */
  86267. byteOffset?: number;
  86268. }
  86269. /**
  86270. * Sparse storage of attributes that deviate from their initialization value
  86271. */
  86272. interface IAccessorSparse extends IProperty {
  86273. /**
  86274. * The number of attributes encoded in this sparse accessor
  86275. */
  86276. count: number;
  86277. /**
  86278. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86279. */
  86280. indices: IAccessorSparseIndices;
  86281. /**
  86282. * 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
  86283. */
  86284. values: IAccessorSparseValues;
  86285. }
  86286. /**
  86287. * 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
  86288. */
  86289. interface IAccessor extends IChildRootProperty {
  86290. /**
  86291. * The index of the bufferview
  86292. */
  86293. bufferView?: number;
  86294. /**
  86295. * The offset relative to the start of the bufferView in bytes
  86296. */
  86297. byteOffset?: number;
  86298. /**
  86299. * The datatype of components in the attribute
  86300. */
  86301. componentType: AccessorComponentType;
  86302. /**
  86303. * Specifies whether integer data values should be normalized
  86304. */
  86305. normalized?: boolean;
  86306. /**
  86307. * The number of attributes referenced by this accessor
  86308. */
  86309. count: number;
  86310. /**
  86311. * Specifies if the attribute is a scalar, vector, or matrix
  86312. */
  86313. type: AccessorType;
  86314. /**
  86315. * Maximum value of each component in this attribute
  86316. */
  86317. max?: number[];
  86318. /**
  86319. * Minimum value of each component in this attribute
  86320. */
  86321. min?: number[];
  86322. /**
  86323. * Sparse storage of attributes that deviate from their initialization value
  86324. */
  86325. sparse?: IAccessorSparse;
  86326. }
  86327. /**
  86328. * Targets an animation's sampler at a node's property
  86329. */
  86330. interface IAnimationChannel extends IProperty {
  86331. /**
  86332. * The index of a sampler in this animation used to compute the value for the target
  86333. */
  86334. sampler: number;
  86335. /**
  86336. * The index of the node and TRS property to target
  86337. */
  86338. target: IAnimationChannelTarget;
  86339. }
  86340. /**
  86341. * The index of the node and TRS property that an animation channel targets
  86342. */
  86343. interface IAnimationChannelTarget extends IProperty {
  86344. /**
  86345. * The index of the node to target
  86346. */
  86347. node: number;
  86348. /**
  86349. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86350. */
  86351. path: AnimationChannelTargetPath;
  86352. }
  86353. /**
  86354. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86355. */
  86356. interface IAnimationSampler extends IProperty {
  86357. /**
  86358. * The index of an accessor containing keyframe input values, e.g., time
  86359. */
  86360. input: number;
  86361. /**
  86362. * Interpolation algorithm
  86363. */
  86364. interpolation?: AnimationSamplerInterpolation;
  86365. /**
  86366. * The index of an accessor, containing keyframe output values
  86367. */
  86368. output: number;
  86369. }
  86370. /**
  86371. * A keyframe animation
  86372. */
  86373. interface IAnimation extends IChildRootProperty {
  86374. /**
  86375. * An array of channels, each of which targets an animation's sampler at a node's property
  86376. */
  86377. channels: IAnimationChannel[];
  86378. /**
  86379. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86380. */
  86381. samplers: IAnimationSampler[];
  86382. }
  86383. /**
  86384. * Metadata about the glTF asset
  86385. */
  86386. interface IAsset extends IChildRootProperty {
  86387. /**
  86388. * A copyright message suitable for display to credit the content creator
  86389. */
  86390. copyright?: string;
  86391. /**
  86392. * Tool that generated this glTF model. Useful for debugging
  86393. */
  86394. generator?: string;
  86395. /**
  86396. * The glTF version that this asset targets
  86397. */
  86398. version: string;
  86399. /**
  86400. * The minimum glTF version that this asset targets
  86401. */
  86402. minVersion?: string;
  86403. }
  86404. /**
  86405. * A buffer points to binary geometry, animation, or skins
  86406. */
  86407. interface IBuffer extends IChildRootProperty {
  86408. /**
  86409. * 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
  86410. */
  86411. uri?: string;
  86412. /**
  86413. * The length of the buffer in bytes
  86414. */
  86415. byteLength: number;
  86416. }
  86417. /**
  86418. * A view into a buffer generally representing a subset of the buffer
  86419. */
  86420. interface IBufferView extends IChildRootProperty {
  86421. /**
  86422. * The index of the buffer
  86423. */
  86424. buffer: number;
  86425. /**
  86426. * The offset into the buffer in bytes
  86427. */
  86428. byteOffset?: number;
  86429. /**
  86430. * The lenth of the bufferView in bytes
  86431. */
  86432. byteLength: number;
  86433. /**
  86434. * The stride, in bytes
  86435. */
  86436. byteStride?: number;
  86437. }
  86438. /**
  86439. * An orthographic camera containing properties to create an orthographic projection matrix
  86440. */
  86441. interface ICameraOrthographic extends IProperty {
  86442. /**
  86443. * The floating-point horizontal magnification of the view. Must not be zero
  86444. */
  86445. xmag: number;
  86446. /**
  86447. * The floating-point vertical magnification of the view. Must not be zero
  86448. */
  86449. ymag: number;
  86450. /**
  86451. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86452. */
  86453. zfar: number;
  86454. /**
  86455. * The floating-point distance to the near clipping plane
  86456. */
  86457. znear: number;
  86458. }
  86459. /**
  86460. * A perspective camera containing properties to create a perspective projection matrix
  86461. */
  86462. interface ICameraPerspective extends IProperty {
  86463. /**
  86464. * The floating-point aspect ratio of the field of view
  86465. */
  86466. aspectRatio?: number;
  86467. /**
  86468. * The floating-point vertical field of view in radians
  86469. */
  86470. yfov: number;
  86471. /**
  86472. * The floating-point distance to the far clipping plane
  86473. */
  86474. zfar?: number;
  86475. /**
  86476. * The floating-point distance to the near clipping plane
  86477. */
  86478. znear: number;
  86479. }
  86480. /**
  86481. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86482. */
  86483. interface ICamera extends IChildRootProperty {
  86484. /**
  86485. * An orthographic camera containing properties to create an orthographic projection matrix
  86486. */
  86487. orthographic?: ICameraOrthographic;
  86488. /**
  86489. * A perspective camera containing properties to create a perspective projection matrix
  86490. */
  86491. perspective?: ICameraPerspective;
  86492. /**
  86493. * Specifies if the camera uses a perspective or orthographic projection
  86494. */
  86495. type: CameraType;
  86496. }
  86497. /**
  86498. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86499. */
  86500. interface IImage extends IChildRootProperty {
  86501. /**
  86502. * 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
  86503. */
  86504. uri?: string;
  86505. /**
  86506. * The image's MIME type
  86507. */
  86508. mimeType?: ImageMimeType;
  86509. /**
  86510. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86511. */
  86512. bufferView?: number;
  86513. }
  86514. /**
  86515. * Material Normal Texture Info
  86516. */
  86517. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86518. /**
  86519. * The scalar multiplier applied to each normal vector of the normal texture
  86520. */
  86521. scale?: number;
  86522. }
  86523. /**
  86524. * Material Occlusion Texture Info
  86525. */
  86526. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86527. /**
  86528. * A scalar multiplier controlling the amount of occlusion applied
  86529. */
  86530. strength?: number;
  86531. }
  86532. /**
  86533. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86534. */
  86535. interface IMaterialPbrMetallicRoughness {
  86536. /**
  86537. * The material's base color factor
  86538. */
  86539. baseColorFactor?: number[];
  86540. /**
  86541. * The base color texture
  86542. */
  86543. baseColorTexture?: ITextureInfo;
  86544. /**
  86545. * The metalness of the material
  86546. */
  86547. metallicFactor?: number;
  86548. /**
  86549. * The roughness of the material
  86550. */
  86551. roughnessFactor?: number;
  86552. /**
  86553. * The metallic-roughness texture
  86554. */
  86555. metallicRoughnessTexture?: ITextureInfo;
  86556. }
  86557. /**
  86558. * The material appearance of a primitive
  86559. */
  86560. interface IMaterial extends IChildRootProperty {
  86561. /**
  86562. * 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
  86563. */
  86564. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86565. /**
  86566. * The normal map texture
  86567. */
  86568. normalTexture?: IMaterialNormalTextureInfo;
  86569. /**
  86570. * The occlusion map texture
  86571. */
  86572. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86573. /**
  86574. * The emissive map texture
  86575. */
  86576. emissiveTexture?: ITextureInfo;
  86577. /**
  86578. * 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
  86579. */
  86580. emissiveFactor?: number[];
  86581. /**
  86582. * The alpha rendering mode of the material
  86583. */
  86584. alphaMode?: MaterialAlphaMode;
  86585. /**
  86586. * The alpha cutoff value of the material
  86587. */
  86588. alphaCutoff?: number;
  86589. /**
  86590. * Specifies whether the material is double sided
  86591. */
  86592. doubleSided?: boolean;
  86593. }
  86594. /**
  86595. * Geometry to be rendered with the given material
  86596. */
  86597. interface IMeshPrimitive extends IProperty {
  86598. /**
  86599. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86600. */
  86601. attributes: {
  86602. [name: string]: number;
  86603. };
  86604. /**
  86605. * The index of the accessor that contains the indices
  86606. */
  86607. indices?: number;
  86608. /**
  86609. * The index of the material to apply to this primitive when rendering
  86610. */
  86611. material?: number;
  86612. /**
  86613. * The type of primitives to render. All valid values correspond to WebGL enums
  86614. */
  86615. mode?: MeshPrimitiveMode;
  86616. /**
  86617. * 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
  86618. */
  86619. targets?: {
  86620. [name: string]: number;
  86621. }[];
  86622. }
  86623. /**
  86624. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86625. */
  86626. interface IMesh extends IChildRootProperty {
  86627. /**
  86628. * An array of primitives, each defining geometry to be rendered with a material
  86629. */
  86630. primitives: IMeshPrimitive[];
  86631. /**
  86632. * Array of weights to be applied to the Morph Targets
  86633. */
  86634. weights?: number[];
  86635. }
  86636. /**
  86637. * A node in the node hierarchy
  86638. */
  86639. interface INode extends IChildRootProperty {
  86640. /**
  86641. * The index of the camera referenced by this node
  86642. */
  86643. camera?: number;
  86644. /**
  86645. * The indices of this node's children
  86646. */
  86647. children?: number[];
  86648. /**
  86649. * The index of the skin referenced by this node
  86650. */
  86651. skin?: number;
  86652. /**
  86653. * A floating-point 4x4 transformation matrix stored in column-major order
  86654. */
  86655. matrix?: number[];
  86656. /**
  86657. * The index of the mesh in this node
  86658. */
  86659. mesh?: number;
  86660. /**
  86661. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86662. */
  86663. rotation?: number[];
  86664. /**
  86665. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86666. */
  86667. scale?: number[];
  86668. /**
  86669. * The node's translation along the x, y, and z axes
  86670. */
  86671. translation?: number[];
  86672. /**
  86673. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86674. */
  86675. weights?: number[];
  86676. }
  86677. /**
  86678. * Texture sampler properties for filtering and wrapping modes
  86679. */
  86680. interface ISampler extends IChildRootProperty {
  86681. /**
  86682. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86683. */
  86684. magFilter?: TextureMagFilter;
  86685. /**
  86686. * Minification filter. All valid values correspond to WebGL enums
  86687. */
  86688. minFilter?: TextureMinFilter;
  86689. /**
  86690. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86691. */
  86692. wrapS?: TextureWrapMode;
  86693. /**
  86694. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86695. */
  86696. wrapT?: TextureWrapMode;
  86697. }
  86698. /**
  86699. * The root nodes of a scene
  86700. */
  86701. interface IScene extends IChildRootProperty {
  86702. /**
  86703. * The indices of each root node
  86704. */
  86705. nodes: number[];
  86706. }
  86707. /**
  86708. * Joints and matrices defining a skin
  86709. */
  86710. interface ISkin extends IChildRootProperty {
  86711. /**
  86712. * 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
  86713. */
  86714. inverseBindMatrices?: number;
  86715. /**
  86716. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86717. */
  86718. skeleton?: number;
  86719. /**
  86720. * 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)
  86721. */
  86722. joints: number[];
  86723. }
  86724. /**
  86725. * A texture and its sampler
  86726. */
  86727. interface ITexture extends IChildRootProperty {
  86728. /**
  86729. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86730. */
  86731. sampler?: number;
  86732. /**
  86733. * The index of the image used by this texture
  86734. */
  86735. source: number;
  86736. }
  86737. /**
  86738. * Reference to a texture
  86739. */
  86740. interface ITextureInfo extends IProperty {
  86741. /**
  86742. * The index of the texture
  86743. */
  86744. index: number;
  86745. /**
  86746. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86747. */
  86748. texCoord?: number;
  86749. }
  86750. /**
  86751. * The root object for a glTF asset
  86752. */
  86753. interface IGLTF extends IProperty {
  86754. /**
  86755. * An array of accessors. An accessor is a typed view into a bufferView
  86756. */
  86757. accessors?: IAccessor[];
  86758. /**
  86759. * An array of keyframe animations
  86760. */
  86761. animations?: IAnimation[];
  86762. /**
  86763. * Metadata about the glTF asset
  86764. */
  86765. asset: IAsset;
  86766. /**
  86767. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86768. */
  86769. buffers?: IBuffer[];
  86770. /**
  86771. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86772. */
  86773. bufferViews?: IBufferView[];
  86774. /**
  86775. * An array of cameras
  86776. */
  86777. cameras?: ICamera[];
  86778. /**
  86779. * Names of glTF extensions used somewhere in this asset
  86780. */
  86781. extensionsUsed?: string[];
  86782. /**
  86783. * Names of glTF extensions required to properly load this asset
  86784. */
  86785. extensionsRequired?: string[];
  86786. /**
  86787. * An array of images. An image defines data used to create a texture
  86788. */
  86789. images?: IImage[];
  86790. /**
  86791. * An array of materials. A material defines the appearance of a primitive
  86792. */
  86793. materials?: IMaterial[];
  86794. /**
  86795. * An array of meshes. A mesh is a set of primitives to be rendered
  86796. */
  86797. meshes?: IMesh[];
  86798. /**
  86799. * An array of nodes
  86800. */
  86801. nodes?: INode[];
  86802. /**
  86803. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86804. */
  86805. samplers?: ISampler[];
  86806. /**
  86807. * The index of the default scene
  86808. */
  86809. scene?: number;
  86810. /**
  86811. * An array of scenes
  86812. */
  86813. scenes?: IScene[];
  86814. /**
  86815. * An array of skins. A skin is defined by joints and matrices
  86816. */
  86817. skins?: ISkin[];
  86818. /**
  86819. * An array of textures
  86820. */
  86821. textures?: ITexture[];
  86822. }
  86823. /**
  86824. * The glTF validation results
  86825. * @ignore
  86826. */
  86827. interface IGLTFValidationResults {
  86828. info: {
  86829. generator: string;
  86830. hasAnimations: boolean;
  86831. hasDefaultScene: boolean;
  86832. hasMaterials: boolean;
  86833. hasMorphTargets: boolean;
  86834. hasSkins: boolean;
  86835. hasTextures: boolean;
  86836. maxAttributesUsed: number;
  86837. primitivesCount: number
  86838. };
  86839. issues: {
  86840. messages: Array<string>;
  86841. numErrors: number;
  86842. numHints: number;
  86843. numInfos: number;
  86844. numWarnings: number;
  86845. truncated: boolean
  86846. };
  86847. mimeType: string;
  86848. uri: string;
  86849. validatedAt: string;
  86850. validatorVersion: string;
  86851. }
  86852. /**
  86853. * The glTF validation options
  86854. */
  86855. interface IGLTFValidationOptions {
  86856. /** Uri to use */
  86857. uri?: string;
  86858. /** Function used to load external resources */
  86859. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86860. /** Boolean indicating that we need to validate accessor data */
  86861. validateAccessorData?: boolean;
  86862. /** max number of issues allowed */
  86863. maxIssues?: number;
  86864. /** Ignored issues */
  86865. ignoredIssues?: Array<string>;
  86866. /** Value to override severy settings */
  86867. severityOverrides?: Object;
  86868. }
  86869. /**
  86870. * The glTF validator object
  86871. * @ignore
  86872. */
  86873. interface IGLTFValidator {
  86874. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86875. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86876. }
  86877. /**
  86878. * Interfaces from the EXT_lights_image_based extension
  86879. */
  86880. /** @hidden */
  86881. interface IEXTLightsImageBased_LightReferenceImageBased {
  86882. light: number;
  86883. }
  86884. /** @hidden */
  86885. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86886. intensity: number;
  86887. rotation: number[];
  86888. specularImageSize: number;
  86889. specularImages: number[][];
  86890. irradianceCoefficients: number[][];
  86891. }
  86892. /** @hidden */
  86893. interface IEXTLightsImageBased {
  86894. lights: IEXTLightsImageBased_LightImageBased[];
  86895. }
  86896. /**
  86897. * Interfaces from the EXT_mesh_gpu_instancing extension
  86898. * !!! Experimental Extension Subject to Changes !!!
  86899. */
  86900. /** @hidden */
  86901. interface IEXTMeshGpuInstancing {
  86902. mesh?: number;
  86903. attributes: { [name: string]: number };
  86904. }
  86905. /**
  86906. * Interfaces from the KHR_draco_mesh_compression extension
  86907. */
  86908. /** @hidden */
  86909. interface IKHRDracoMeshCompression {
  86910. bufferView: number;
  86911. attributes: { [name: string]: number };
  86912. }
  86913. /**
  86914. * Interfaces from the KHR_lights_punctual extension
  86915. */
  86916. /** @hidden */
  86917. const enum IKHRLightsPunctual_LightType {
  86918. DIRECTIONAL = "directional",
  86919. POINT = "point",
  86920. SPOT = "spot"
  86921. }
  86922. /** @hidden */
  86923. interface IKHRLightsPunctual_LightReference {
  86924. light: number;
  86925. }
  86926. /** @hidden */
  86927. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86928. type: IKHRLightsPunctual_LightType;
  86929. color?: number[];
  86930. intensity?: number;
  86931. range?: number;
  86932. spot?: {
  86933. innerConeAngle?: number;
  86934. outerConeAngle?: number;
  86935. };
  86936. }
  86937. /** @hidden */
  86938. interface IKHRLightsPunctual {
  86939. lights: IKHRLightsPunctual_Light[];
  86940. }
  86941. /**
  86942. * Interfaces from the KHR_materials_clearcoat extension
  86943. * !!! Experimental Extension Subject to Changes !!!
  86944. */
  86945. /** @hidden */
  86946. interface IKHRMaterialsClearcoat {
  86947. clearcoatFactor: number;
  86948. clearcoatTexture: ITextureInfo;
  86949. clearcoatRoughnessFactor: number;
  86950. clearcoatRoughnessTexture: ITextureInfo;
  86951. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86952. }
  86953. /**
  86954. * Interfaces from the KHR_materials_ior extension
  86955. * !!! Experimental Extension Subject to Changes !!!
  86956. */
  86957. /** @hidden */
  86958. interface IKHRMaterialsIor {
  86959. ior: number;
  86960. }
  86961. /**
  86962. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86963. */
  86964. /** @hidden */
  86965. interface IKHRMaterialsPbrSpecularGlossiness {
  86966. diffuseFactor: number[];
  86967. diffuseTexture: ITextureInfo;
  86968. specularFactor: number[];
  86969. glossinessFactor: number;
  86970. specularGlossinessTexture: ITextureInfo;
  86971. }
  86972. /**
  86973. * Interfaces from the KHR_materials_sheen extension
  86974. * !!! Experimental Extension Subject to Changes !!!
  86975. */
  86976. /** @hidden */
  86977. interface IKHRMaterialsSheen {
  86978. sheenColorFactor?: number[];
  86979. sheenColorTexture?: ITextureInfo;
  86980. sheenRoughnessFactor?: number;
  86981. sheenRoughnessTexture?: ITextureInfo;
  86982. }
  86983. /**
  86984. * Interfaces from the KHR_materials_specular extension
  86985. * !!! Experimental Extension Subject to Changes !!!
  86986. */
  86987. /** @hidden */
  86988. interface IKHRMaterialsSpecular {
  86989. specularFactor: number;
  86990. specularColorFactor: number[];
  86991. specularTexture: ITextureInfo;
  86992. }
  86993. /**
  86994. * Interfaces from the KHR_materials_transmission extension
  86995. * !!! Experimental Extension Subject to Changes !!!
  86996. */
  86997. /** @hidden */
  86998. interface IKHRMaterialsTransmission {
  86999. transmissionFactor?: number;
  87000. transmissionTexture?: ITextureInfo;
  87001. }
  87002. /**
  87003. * Interfaces from the KHR_materials_translucency extension
  87004. * !!! Experimental Extension Subject to Changes !!!
  87005. */
  87006. /** @hidden */
  87007. interface IKHRMaterialsTranslucency {
  87008. translucencyFactor?: number;
  87009. translucencyTexture?: ITextureInfo;
  87010. }
  87011. /**
  87012. * Interfaces from the KHR_materials_variants extension
  87013. * !!! Experimental Extension Subject to Changes !!!
  87014. */
  87015. /** @hidden */
  87016. interface IKHRMaterialVariants_Mapping extends IProperty {
  87017. mappings: Array<{
  87018. variants: number[];
  87019. material: number;
  87020. }>;
  87021. }
  87022. /** @hidden */
  87023. interface IKHRMaterialVariants_Variant extends IProperty {
  87024. name: string;
  87025. }
  87026. /** @hidden */
  87027. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  87028. variants: Array<IKHRMaterialVariants_Variant>;
  87029. }
  87030. /**
  87031. * Interfaces from the KHR_texture_basisu extension
  87032. * !!! Experimental Extension Subject to Changes !!!
  87033. */
  87034. /** @hidden */
  87035. interface IKHRTextureBasisU {
  87036. source: number;
  87037. }
  87038. /**
  87039. * Interfaces from the EXT_texture_webp extension
  87040. */
  87041. /** @hidden */
  87042. interface IEXTTextureWebP {
  87043. source: number;
  87044. }
  87045. /**
  87046. * Interfaces from the KHR_texture_transform extension
  87047. */
  87048. /** @hidden */
  87049. interface IKHRTextureTransform {
  87050. offset?: number[];
  87051. rotation?: number;
  87052. scale?: number[];
  87053. texCoord?: number;
  87054. }
  87055. /**
  87056. * Interfaces from the KHR_xmp extension
  87057. * !!! Experimental Extension Subject to Changes !!!
  87058. */
  87059. /** @hidden */
  87060. interface IKHRXmp_Data {
  87061. [key: string]: unknown;
  87062. }
  87063. /** @hidden */
  87064. interface IKHRXmp_Gltf {
  87065. packets: IKHRXmp_Data[];
  87066. }
  87067. /** @hidden */
  87068. interface IKHRXmp_Node {
  87069. packet: number;
  87070. }
  87071. /**
  87072. * Interfaces from the MSFT_audio_emitter extension
  87073. */
  87074. /** @hidden */
  87075. interface IMSFTAudioEmitter_ClipReference {
  87076. clip: number;
  87077. weight?: number;
  87078. }
  87079. /** @hidden */
  87080. interface IMSFTAudioEmitter_EmittersReference {
  87081. emitters: number[];
  87082. }
  87083. /** @hidden */
  87084. const enum IMSFTAudioEmitter_DistanceModel {
  87085. linear = "linear",
  87086. inverse = "inverse",
  87087. exponential = "exponential",
  87088. }
  87089. /** @hidden */
  87090. interface IMSFTAudioEmitter_Emitter {
  87091. name?: string;
  87092. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87093. refDistance?: number;
  87094. maxDistance?: number;
  87095. rolloffFactor?: number;
  87096. innerAngle?: number;
  87097. outerAngle?: number;
  87098. loop?: boolean;
  87099. volume?: number;
  87100. clips: IMSFTAudioEmitter_ClipReference[];
  87101. }
  87102. /** @hidden */
  87103. const enum IMSFTAudioEmitter_AudioMimeType {
  87104. WAV = "audio/wav",
  87105. }
  87106. /** @hidden */
  87107. interface IMSFTAudioEmitter_Clip extends IProperty {
  87108. uri?: string;
  87109. bufferView?: number;
  87110. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87111. }
  87112. /** @hidden */
  87113. const enum IMSFTAudioEmitter_AnimationEventAction {
  87114. play = "play",
  87115. pause = "pause",
  87116. stop = "stop",
  87117. }
  87118. /** @hidden */
  87119. interface IMSFTAudioEmitter_AnimationEvent {
  87120. action: IMSFTAudioEmitter_AnimationEventAction;
  87121. emitter: number;
  87122. time: number;
  87123. startOffset?: number;
  87124. }
  87125. /**
  87126. * Interfaces from the MSFT_lod extension
  87127. */
  87128. /** @hidden */
  87129. interface IMSFTLOD {
  87130. ids: number[];
  87131. }
  87132. }
  87133. declare module BABYLON {
  87134. /** @hidden */
  87135. export var cellPixelShader: {
  87136. name: string;
  87137. shader: string;
  87138. };
  87139. }
  87140. declare module BABYLON {
  87141. /** @hidden */
  87142. export var cellVertexShader: {
  87143. name: string;
  87144. shader: string;
  87145. };
  87146. }
  87147. declare module BABYLON {
  87148. export class CellMaterial extends BABYLON.PushMaterial {
  87149. private _diffuseTexture;
  87150. diffuseTexture: BABYLON.BaseTexture;
  87151. diffuseColor: BABYLON.Color3;
  87152. _computeHighLevel: boolean;
  87153. computeHighLevel: boolean;
  87154. private _disableLighting;
  87155. disableLighting: boolean;
  87156. private _maxSimultaneousLights;
  87157. maxSimultaneousLights: number;
  87158. constructor(name: string, scene: BABYLON.Scene);
  87159. needAlphaBlending(): boolean;
  87160. needAlphaTesting(): boolean;
  87161. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87162. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87163. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87164. getAnimatables(): BABYLON.IAnimatable[];
  87165. getActiveTextures(): BABYLON.BaseTexture[];
  87166. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87167. dispose(forceDisposeEffect?: boolean): void;
  87168. getClassName(): string;
  87169. clone(name: string): CellMaterial;
  87170. serialize(): any;
  87171. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87172. }
  87173. }
  87174. declare module BABYLON {
  87175. export class CustomShaderStructure {
  87176. FragmentStore: string;
  87177. VertexStore: string;
  87178. constructor();
  87179. }
  87180. export class ShaderSpecialParts {
  87181. constructor();
  87182. Fragment_Begin: string;
  87183. Fragment_Definitions: string;
  87184. Fragment_MainBegin: string;
  87185. Fragment_Custom_Diffuse: string;
  87186. Fragment_Before_Lights: string;
  87187. Fragment_Before_Fog: string;
  87188. Fragment_Custom_Alpha: string;
  87189. Fragment_Before_FragColor: string;
  87190. Vertex_Begin: string;
  87191. Vertex_Definitions: string;
  87192. Vertex_MainBegin: string;
  87193. Vertex_Before_PositionUpdated: string;
  87194. Vertex_Before_NormalUpdated: string;
  87195. Vertex_After_WorldPosComputed: string;
  87196. Vertex_MainEnd: string;
  87197. }
  87198. export class CustomMaterial extends BABYLON.StandardMaterial {
  87199. static ShaderIndexer: number;
  87200. CustomParts: ShaderSpecialParts;
  87201. _isCreatedShader: boolean;
  87202. _createdShaderName: string;
  87203. _customUniform: string[];
  87204. _newUniforms: string[];
  87205. _newUniformInstances: {
  87206. [name: string]: any;
  87207. };
  87208. _newSamplerInstances: {
  87209. [name: string]: BABYLON.Texture;
  87210. };
  87211. _customAttributes: string[];
  87212. FragmentShader: string;
  87213. VertexShader: string;
  87214. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87215. ReviewUniform(name: string, arr: string[]): string[];
  87216. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87217. constructor(name: string, scene: BABYLON.Scene);
  87218. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87219. AddAttribute(name: string): CustomMaterial;
  87220. Fragment_Begin(shaderPart: string): CustomMaterial;
  87221. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87222. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87223. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87224. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87225. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87226. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87227. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87228. Vertex_Begin(shaderPart: string): CustomMaterial;
  87229. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87230. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87231. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87232. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87233. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87234. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87235. }
  87236. }
  87237. declare module BABYLON {
  87238. export class ShaderAlebdoParts {
  87239. constructor();
  87240. Fragment_Begin: string;
  87241. Fragment_Definitions: string;
  87242. Fragment_MainBegin: string;
  87243. Fragment_Custom_Albedo: string;
  87244. Fragment_Before_Lights: string;
  87245. Fragment_Custom_MetallicRoughness: string;
  87246. Fragment_Custom_MicroSurface: string;
  87247. Fragment_Before_Fog: string;
  87248. Fragment_Custom_Alpha: string;
  87249. Fragment_Before_FragColor: string;
  87250. Vertex_Begin: string;
  87251. Vertex_Definitions: string;
  87252. Vertex_MainBegin: string;
  87253. Vertex_Before_PositionUpdated: string;
  87254. Vertex_Before_NormalUpdated: string;
  87255. Vertex_After_WorldPosComputed: string;
  87256. Vertex_MainEnd: string;
  87257. }
  87258. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87259. static ShaderIndexer: number;
  87260. CustomParts: ShaderAlebdoParts;
  87261. _isCreatedShader: boolean;
  87262. _createdShaderName: string;
  87263. _customUniform: string[];
  87264. _newUniforms: string[];
  87265. _newUniformInstances: {
  87266. [name: string]: any;
  87267. };
  87268. _newSamplerInstances: {
  87269. [name: string]: BABYLON.Texture;
  87270. };
  87271. _customAttributes: string[];
  87272. FragmentShader: string;
  87273. VertexShader: string;
  87274. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87275. ReviewUniform(name: string, arr: string[]): string[];
  87276. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87277. constructor(name: string, scene: BABYLON.Scene);
  87278. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87279. AddAttribute(name: string): PBRCustomMaterial;
  87280. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87281. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87282. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87283. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87284. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87285. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87286. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87287. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87288. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87289. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87290. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87291. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87292. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87293. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87294. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87295. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87296. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87297. }
  87298. }
  87299. declare module BABYLON {
  87300. /** @hidden */
  87301. export var firePixelShader: {
  87302. name: string;
  87303. shader: string;
  87304. };
  87305. }
  87306. declare module BABYLON {
  87307. /** @hidden */
  87308. export var fireVertexShader: {
  87309. name: string;
  87310. shader: string;
  87311. };
  87312. }
  87313. declare module BABYLON {
  87314. export class FireMaterial extends BABYLON.PushMaterial {
  87315. private _diffuseTexture;
  87316. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87317. private _distortionTexture;
  87318. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87319. private _opacityTexture;
  87320. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87321. diffuseColor: BABYLON.Color3;
  87322. speed: number;
  87323. private _scaledDiffuse;
  87324. private _lastTime;
  87325. constructor(name: string, scene: BABYLON.Scene);
  87326. needAlphaBlending(): boolean;
  87327. needAlphaTesting(): boolean;
  87328. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87329. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87330. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87331. getAnimatables(): BABYLON.IAnimatable[];
  87332. getActiveTextures(): BABYLON.BaseTexture[];
  87333. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87334. getClassName(): string;
  87335. dispose(forceDisposeEffect?: boolean): void;
  87336. clone(name: string): FireMaterial;
  87337. serialize(): any;
  87338. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87339. }
  87340. }
  87341. declare module BABYLON {
  87342. /** @hidden */
  87343. export var furPixelShader: {
  87344. name: string;
  87345. shader: string;
  87346. };
  87347. }
  87348. declare module BABYLON {
  87349. /** @hidden */
  87350. export var furVertexShader: {
  87351. name: string;
  87352. shader: string;
  87353. };
  87354. }
  87355. declare module BABYLON {
  87356. export class FurMaterial extends BABYLON.PushMaterial {
  87357. private _diffuseTexture;
  87358. diffuseTexture: BABYLON.BaseTexture;
  87359. private _heightTexture;
  87360. heightTexture: BABYLON.BaseTexture;
  87361. diffuseColor: BABYLON.Color3;
  87362. furLength: number;
  87363. furAngle: number;
  87364. furColor: BABYLON.Color3;
  87365. furOffset: number;
  87366. furSpacing: number;
  87367. furGravity: BABYLON.Vector3;
  87368. furSpeed: number;
  87369. furDensity: number;
  87370. furOcclusion: number;
  87371. furTexture: BABYLON.DynamicTexture;
  87372. private _disableLighting;
  87373. disableLighting: boolean;
  87374. private _maxSimultaneousLights;
  87375. maxSimultaneousLights: number;
  87376. highLevelFur: boolean;
  87377. _meshes: BABYLON.AbstractMesh[];
  87378. private _furTime;
  87379. constructor(name: string, scene: BABYLON.Scene);
  87380. get furTime(): number;
  87381. set furTime(furTime: number);
  87382. needAlphaBlending(): boolean;
  87383. needAlphaTesting(): boolean;
  87384. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87385. updateFur(): void;
  87386. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87387. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87388. getAnimatables(): BABYLON.IAnimatable[];
  87389. getActiveTextures(): BABYLON.BaseTexture[];
  87390. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87391. dispose(forceDisposeEffect?: boolean): void;
  87392. clone(name: string): FurMaterial;
  87393. serialize(): any;
  87394. getClassName(): string;
  87395. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87396. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87397. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87398. }
  87399. }
  87400. declare module BABYLON {
  87401. /** @hidden */
  87402. export var gradientPixelShader: {
  87403. name: string;
  87404. shader: string;
  87405. };
  87406. }
  87407. declare module BABYLON {
  87408. /** @hidden */
  87409. export var gradientVertexShader: {
  87410. name: string;
  87411. shader: string;
  87412. };
  87413. }
  87414. declare module BABYLON {
  87415. export class GradientMaterial extends BABYLON.PushMaterial {
  87416. private _maxSimultaneousLights;
  87417. maxSimultaneousLights: number;
  87418. topColor: BABYLON.Color3;
  87419. topColorAlpha: number;
  87420. bottomColor: BABYLON.Color3;
  87421. bottomColorAlpha: number;
  87422. offset: number;
  87423. scale: number;
  87424. smoothness: number;
  87425. private _disableLighting;
  87426. disableLighting: boolean;
  87427. constructor(name: string, scene: BABYLON.Scene);
  87428. needAlphaBlending(): boolean;
  87429. needAlphaTesting(): boolean;
  87430. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87431. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87433. getAnimatables(): BABYLON.IAnimatable[];
  87434. dispose(forceDisposeEffect?: boolean): void;
  87435. clone(name: string): GradientMaterial;
  87436. serialize(): any;
  87437. getClassName(): string;
  87438. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87439. }
  87440. }
  87441. declare module BABYLON {
  87442. /** @hidden */
  87443. export var gridPixelShader: {
  87444. name: string;
  87445. shader: string;
  87446. };
  87447. }
  87448. declare module BABYLON {
  87449. /** @hidden */
  87450. export var gridVertexShader: {
  87451. name: string;
  87452. shader: string;
  87453. };
  87454. }
  87455. declare module BABYLON {
  87456. /**
  87457. * The grid materials allows you to wrap any shape with a grid.
  87458. * Colors are customizable.
  87459. */
  87460. export class GridMaterial extends BABYLON.PushMaterial {
  87461. /**
  87462. * Main color of the grid (e.g. between lines)
  87463. */
  87464. mainColor: BABYLON.Color3;
  87465. /**
  87466. * Color of the grid lines.
  87467. */
  87468. lineColor: BABYLON.Color3;
  87469. /**
  87470. * The scale of the grid compared to unit.
  87471. */
  87472. gridRatio: number;
  87473. /**
  87474. * Allows setting an offset for the grid lines.
  87475. */
  87476. gridOffset: BABYLON.Vector3;
  87477. /**
  87478. * The frequency of thicker lines.
  87479. */
  87480. majorUnitFrequency: number;
  87481. /**
  87482. * The visibility of minor units in the grid.
  87483. */
  87484. minorUnitVisibility: number;
  87485. /**
  87486. * The grid opacity outside of the lines.
  87487. */
  87488. opacity: number;
  87489. /**
  87490. * Determine RBG output is premultiplied by alpha value.
  87491. */
  87492. preMultiplyAlpha: boolean;
  87493. private _opacityTexture;
  87494. opacityTexture: BABYLON.BaseTexture;
  87495. private _gridControl;
  87496. /**
  87497. * constructor
  87498. * @param name The name given to the material in order to identify it afterwards.
  87499. * @param scene The scene the material is used in.
  87500. */
  87501. constructor(name: string, scene: BABYLON.Scene);
  87502. /**
  87503. * Returns wehter or not the grid requires alpha blending.
  87504. */
  87505. needAlphaBlending(): boolean;
  87506. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87507. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87508. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87509. /**
  87510. * Dispose the material and its associated resources.
  87511. * @param forceDisposeEffect will also dispose the used effect when true
  87512. */
  87513. dispose(forceDisposeEffect?: boolean): void;
  87514. clone(name: string): GridMaterial;
  87515. serialize(): any;
  87516. getClassName(): string;
  87517. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87518. }
  87519. }
  87520. declare module BABYLON {
  87521. /** @hidden */
  87522. export var lavaPixelShader: {
  87523. name: string;
  87524. shader: string;
  87525. };
  87526. }
  87527. declare module BABYLON {
  87528. /** @hidden */
  87529. export var lavaVertexShader: {
  87530. name: string;
  87531. shader: string;
  87532. };
  87533. }
  87534. declare module BABYLON {
  87535. export class LavaMaterial extends BABYLON.PushMaterial {
  87536. private _diffuseTexture;
  87537. diffuseTexture: BABYLON.BaseTexture;
  87538. noiseTexture: BABYLON.BaseTexture;
  87539. fogColor: BABYLON.Color3;
  87540. speed: number;
  87541. movingSpeed: number;
  87542. lowFrequencySpeed: number;
  87543. fogDensity: number;
  87544. private _lastTime;
  87545. diffuseColor: BABYLON.Color3;
  87546. private _disableLighting;
  87547. disableLighting: boolean;
  87548. private _unlit;
  87549. unlit: boolean;
  87550. private _maxSimultaneousLights;
  87551. maxSimultaneousLights: number;
  87552. private _scaledDiffuse;
  87553. constructor(name: string, scene: BABYLON.Scene);
  87554. needAlphaBlending(): boolean;
  87555. needAlphaTesting(): boolean;
  87556. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87557. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87558. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87559. getAnimatables(): BABYLON.IAnimatable[];
  87560. getActiveTextures(): BABYLON.BaseTexture[];
  87561. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87562. dispose(forceDisposeEffect?: boolean): void;
  87563. clone(name: string): LavaMaterial;
  87564. serialize(): any;
  87565. getClassName(): string;
  87566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87567. }
  87568. }
  87569. declare module BABYLON {
  87570. /** @hidden */
  87571. export var mixPixelShader: {
  87572. name: string;
  87573. shader: string;
  87574. };
  87575. }
  87576. declare module BABYLON {
  87577. /** @hidden */
  87578. export var mixVertexShader: {
  87579. name: string;
  87580. shader: string;
  87581. };
  87582. }
  87583. declare module BABYLON {
  87584. export class MixMaterial extends BABYLON.PushMaterial {
  87585. /**
  87586. * Mix textures
  87587. */
  87588. private _mixTexture1;
  87589. mixTexture1: BABYLON.BaseTexture;
  87590. private _mixTexture2;
  87591. mixTexture2: BABYLON.BaseTexture;
  87592. /**
  87593. * Diffuse textures
  87594. */
  87595. private _diffuseTexture1;
  87596. diffuseTexture1: BABYLON.Texture;
  87597. private _diffuseTexture2;
  87598. diffuseTexture2: BABYLON.Texture;
  87599. private _diffuseTexture3;
  87600. diffuseTexture3: BABYLON.Texture;
  87601. private _diffuseTexture4;
  87602. diffuseTexture4: BABYLON.Texture;
  87603. private _diffuseTexture5;
  87604. diffuseTexture5: BABYLON.Texture;
  87605. private _diffuseTexture6;
  87606. diffuseTexture6: BABYLON.Texture;
  87607. private _diffuseTexture7;
  87608. diffuseTexture7: BABYLON.Texture;
  87609. private _diffuseTexture8;
  87610. diffuseTexture8: BABYLON.Texture;
  87611. /**
  87612. * Uniforms
  87613. */
  87614. diffuseColor: BABYLON.Color3;
  87615. specularColor: BABYLON.Color3;
  87616. specularPower: number;
  87617. private _disableLighting;
  87618. disableLighting: boolean;
  87619. private _maxSimultaneousLights;
  87620. maxSimultaneousLights: number;
  87621. constructor(name: string, scene: BABYLON.Scene);
  87622. needAlphaBlending(): boolean;
  87623. needAlphaTesting(): boolean;
  87624. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87625. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87626. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87627. getAnimatables(): BABYLON.IAnimatable[];
  87628. getActiveTextures(): BABYLON.BaseTexture[];
  87629. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87630. dispose(forceDisposeEffect?: boolean): void;
  87631. clone(name: string): MixMaterial;
  87632. serialize(): any;
  87633. getClassName(): string;
  87634. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87635. }
  87636. }
  87637. declare module BABYLON {
  87638. /** @hidden */
  87639. export var normalPixelShader: {
  87640. name: string;
  87641. shader: string;
  87642. };
  87643. }
  87644. declare module BABYLON {
  87645. /** @hidden */
  87646. export var normalVertexShader: {
  87647. name: string;
  87648. shader: string;
  87649. };
  87650. }
  87651. declare module BABYLON {
  87652. export class NormalMaterial extends BABYLON.PushMaterial {
  87653. private _diffuseTexture;
  87654. diffuseTexture: BABYLON.BaseTexture;
  87655. diffuseColor: BABYLON.Color3;
  87656. private _disableLighting;
  87657. disableLighting: boolean;
  87658. private _maxSimultaneousLights;
  87659. maxSimultaneousLights: number;
  87660. constructor(name: string, scene: BABYLON.Scene);
  87661. needAlphaBlending(): boolean;
  87662. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87663. needAlphaTesting(): boolean;
  87664. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87665. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87666. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87667. getAnimatables(): BABYLON.IAnimatable[];
  87668. getActiveTextures(): BABYLON.BaseTexture[];
  87669. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87670. dispose(forceDisposeEffect?: boolean): void;
  87671. clone(name: string): NormalMaterial;
  87672. serialize(): any;
  87673. getClassName(): string;
  87674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87675. }
  87676. }
  87677. declare module BABYLON {
  87678. /** @hidden */
  87679. export var shadowOnlyPixelShader: {
  87680. name: string;
  87681. shader: string;
  87682. };
  87683. }
  87684. declare module BABYLON {
  87685. /** @hidden */
  87686. export var shadowOnlyVertexShader: {
  87687. name: string;
  87688. shader: string;
  87689. };
  87690. }
  87691. declare module BABYLON {
  87692. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87693. private _activeLight;
  87694. private _needAlphaBlending;
  87695. constructor(name: string, scene: BABYLON.Scene);
  87696. shadowColor: BABYLON.Color3;
  87697. needAlphaBlending(): boolean;
  87698. needAlphaTesting(): boolean;
  87699. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87700. get activeLight(): BABYLON.IShadowLight;
  87701. set activeLight(light: BABYLON.IShadowLight);
  87702. private _getFirstShadowLightForMesh;
  87703. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87704. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87705. clone(name: string): ShadowOnlyMaterial;
  87706. serialize(): any;
  87707. getClassName(): string;
  87708. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87709. }
  87710. }
  87711. declare module BABYLON {
  87712. /** @hidden */
  87713. export var simplePixelShader: {
  87714. name: string;
  87715. shader: string;
  87716. };
  87717. }
  87718. declare module BABYLON {
  87719. /** @hidden */
  87720. export var simpleVertexShader: {
  87721. name: string;
  87722. shader: string;
  87723. };
  87724. }
  87725. declare module BABYLON {
  87726. export class SimpleMaterial extends BABYLON.PushMaterial {
  87727. private _diffuseTexture;
  87728. diffuseTexture: BABYLON.BaseTexture;
  87729. diffuseColor: BABYLON.Color3;
  87730. private _disableLighting;
  87731. disableLighting: boolean;
  87732. private _maxSimultaneousLights;
  87733. maxSimultaneousLights: number;
  87734. constructor(name: string, scene: BABYLON.Scene);
  87735. needAlphaBlending(): boolean;
  87736. needAlphaTesting(): boolean;
  87737. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87738. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87739. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87740. getAnimatables(): BABYLON.IAnimatable[];
  87741. getActiveTextures(): BABYLON.BaseTexture[];
  87742. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87743. dispose(forceDisposeEffect?: boolean): void;
  87744. clone(name: string): SimpleMaterial;
  87745. serialize(): any;
  87746. getClassName(): string;
  87747. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87748. }
  87749. }
  87750. declare module BABYLON {
  87751. /** @hidden */
  87752. export var skyPixelShader: {
  87753. name: string;
  87754. shader: string;
  87755. };
  87756. }
  87757. declare module BABYLON {
  87758. /** @hidden */
  87759. export var skyVertexShader: {
  87760. name: string;
  87761. shader: string;
  87762. };
  87763. }
  87764. declare module BABYLON {
  87765. /**
  87766. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87767. * @see https://doc.babylonjs.com/extensions/sky
  87768. */
  87769. export class SkyMaterial extends BABYLON.PushMaterial {
  87770. /**
  87771. * Defines the overall luminance of sky in interval ]0, 1[.
  87772. */
  87773. luminance: number;
  87774. /**
  87775. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87776. */
  87777. turbidity: number;
  87778. /**
  87779. * Defines the sky appearance (light intensity).
  87780. */
  87781. rayleigh: number;
  87782. /**
  87783. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87784. */
  87785. mieCoefficient: number;
  87786. /**
  87787. * Defines the amount of haze particles following the Mie scattering theory.
  87788. */
  87789. mieDirectionalG: number;
  87790. /**
  87791. * Defines the distance of the sun according to the active scene camera.
  87792. */
  87793. distance: number;
  87794. /**
  87795. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87796. * "inclined".
  87797. */
  87798. inclination: number;
  87799. /**
  87800. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87801. * an object direction and a reference direction.
  87802. */
  87803. azimuth: number;
  87804. /**
  87805. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87806. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87807. */
  87808. sunPosition: BABYLON.Vector3;
  87809. /**
  87810. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87811. * .sunPosition property.
  87812. */
  87813. useSunPosition: boolean;
  87814. /**
  87815. * Defines an offset vector used to get a horizon offset.
  87816. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87817. */
  87818. cameraOffset: BABYLON.Vector3;
  87819. private _cameraPosition;
  87820. /**
  87821. * Instantiates a new sky material.
  87822. * This material allows to create dynamic and texture free
  87823. * effects for skyboxes by taking care of the atmosphere state.
  87824. * @see https://doc.babylonjs.com/extensions/sky
  87825. * @param name Define the name of the material in the scene
  87826. * @param scene Define the scene the material belong to
  87827. */
  87828. constructor(name: string, scene: BABYLON.Scene);
  87829. /**
  87830. * Specifies if the material will require alpha blending
  87831. * @returns a boolean specifying if alpha blending is needed
  87832. */
  87833. needAlphaBlending(): boolean;
  87834. /**
  87835. * Specifies if this material should be rendered in alpha test mode
  87836. * @returns false as the sky material doesn't need alpha testing.
  87837. */
  87838. needAlphaTesting(): boolean;
  87839. /**
  87840. * Get the texture used for alpha test purpose.
  87841. * @returns null as the sky material has no texture.
  87842. */
  87843. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87844. /**
  87845. * Get if the submesh is ready to be used and all its information available.
  87846. * Child classes can use it to update shaders
  87847. * @param mesh defines the mesh to check
  87848. * @param subMesh defines which submesh to check
  87849. * @param useInstances specifies that instances should be used
  87850. * @returns a boolean indicating that the submesh is ready or not
  87851. */
  87852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87853. /**
  87854. * Binds the submesh to this material by preparing the effect and shader to draw
  87855. * @param world defines the world transformation matrix
  87856. * @param mesh defines the mesh containing the submesh
  87857. * @param subMesh defines the submesh to bind the material to
  87858. */
  87859. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87860. /**
  87861. * Get the list of animatables in the material.
  87862. * @returns the list of animatables object used in the material
  87863. */
  87864. getAnimatables(): BABYLON.IAnimatable[];
  87865. /**
  87866. * Disposes the material
  87867. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87868. */
  87869. dispose(forceDisposeEffect?: boolean): void;
  87870. /**
  87871. * Makes a duplicate of the material, and gives it a new name
  87872. * @param name defines the new name for the duplicated material
  87873. * @returns the cloned material
  87874. */
  87875. clone(name: string): SkyMaterial;
  87876. /**
  87877. * Serializes this material in a JSON representation
  87878. * @returns the serialized material object
  87879. */
  87880. serialize(): any;
  87881. /**
  87882. * Gets the current class name of the material e.g. "SkyMaterial"
  87883. * Mainly use in serialization.
  87884. * @returns the class name
  87885. */
  87886. getClassName(): string;
  87887. /**
  87888. * Creates a sky material from parsed material data
  87889. * @param source defines the JSON representation of the material
  87890. * @param scene defines the hosting scene
  87891. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87892. * @returns a new sky material
  87893. */
  87894. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87895. }
  87896. }
  87897. declare module BABYLON {
  87898. /** @hidden */
  87899. export var terrainPixelShader: {
  87900. name: string;
  87901. shader: string;
  87902. };
  87903. }
  87904. declare module BABYLON {
  87905. /** @hidden */
  87906. export var terrainVertexShader: {
  87907. name: string;
  87908. shader: string;
  87909. };
  87910. }
  87911. declare module BABYLON {
  87912. export class TerrainMaterial extends BABYLON.PushMaterial {
  87913. private _mixTexture;
  87914. mixTexture: BABYLON.BaseTexture;
  87915. private _diffuseTexture1;
  87916. diffuseTexture1: BABYLON.Texture;
  87917. private _diffuseTexture2;
  87918. diffuseTexture2: BABYLON.Texture;
  87919. private _diffuseTexture3;
  87920. diffuseTexture3: BABYLON.Texture;
  87921. private _bumpTexture1;
  87922. bumpTexture1: BABYLON.Texture;
  87923. private _bumpTexture2;
  87924. bumpTexture2: BABYLON.Texture;
  87925. private _bumpTexture3;
  87926. bumpTexture3: BABYLON.Texture;
  87927. diffuseColor: BABYLON.Color3;
  87928. specularColor: BABYLON.Color3;
  87929. specularPower: number;
  87930. private _disableLighting;
  87931. disableLighting: boolean;
  87932. private _maxSimultaneousLights;
  87933. maxSimultaneousLights: number;
  87934. constructor(name: string, scene: BABYLON.Scene);
  87935. needAlphaBlending(): boolean;
  87936. needAlphaTesting(): boolean;
  87937. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87938. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87939. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87940. getAnimatables(): BABYLON.IAnimatable[];
  87941. getActiveTextures(): BABYLON.BaseTexture[];
  87942. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87943. dispose(forceDisposeEffect?: boolean): void;
  87944. clone(name: string): TerrainMaterial;
  87945. serialize(): any;
  87946. getClassName(): string;
  87947. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87948. }
  87949. }
  87950. declare module BABYLON {
  87951. /** @hidden */
  87952. export var triplanarPixelShader: {
  87953. name: string;
  87954. shader: string;
  87955. };
  87956. }
  87957. declare module BABYLON {
  87958. /** @hidden */
  87959. export var triplanarVertexShader: {
  87960. name: string;
  87961. shader: string;
  87962. };
  87963. }
  87964. declare module BABYLON {
  87965. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87966. mixTexture: BABYLON.BaseTexture;
  87967. private _diffuseTextureX;
  87968. diffuseTextureX: BABYLON.BaseTexture;
  87969. private _diffuseTextureY;
  87970. diffuseTextureY: BABYLON.BaseTexture;
  87971. private _diffuseTextureZ;
  87972. diffuseTextureZ: BABYLON.BaseTexture;
  87973. private _normalTextureX;
  87974. normalTextureX: BABYLON.BaseTexture;
  87975. private _normalTextureY;
  87976. normalTextureY: BABYLON.BaseTexture;
  87977. private _normalTextureZ;
  87978. normalTextureZ: BABYLON.BaseTexture;
  87979. tileSize: number;
  87980. diffuseColor: BABYLON.Color3;
  87981. specularColor: BABYLON.Color3;
  87982. specularPower: number;
  87983. private _disableLighting;
  87984. disableLighting: boolean;
  87985. private _maxSimultaneousLights;
  87986. maxSimultaneousLights: number;
  87987. constructor(name: string, scene: BABYLON.Scene);
  87988. needAlphaBlending(): boolean;
  87989. needAlphaTesting(): boolean;
  87990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87993. getAnimatables(): BABYLON.IAnimatable[];
  87994. getActiveTextures(): BABYLON.BaseTexture[];
  87995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87996. dispose(forceDisposeEffect?: boolean): void;
  87997. clone(name: string): TriPlanarMaterial;
  87998. serialize(): any;
  87999. getClassName(): string;
  88000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  88001. }
  88002. }
  88003. declare module BABYLON {
  88004. /** @hidden */
  88005. export var waterPixelShader: {
  88006. name: string;
  88007. shader: string;
  88008. };
  88009. }
  88010. declare module BABYLON {
  88011. /** @hidden */
  88012. export var waterVertexShader: {
  88013. name: string;
  88014. shader: string;
  88015. };
  88016. }
  88017. declare module BABYLON {
  88018. export class WaterMaterial extends BABYLON.PushMaterial {
  88019. renderTargetSize: BABYLON.Vector2;
  88020. private _bumpTexture;
  88021. bumpTexture: BABYLON.BaseTexture;
  88022. diffuseColor: BABYLON.Color3;
  88023. specularColor: BABYLON.Color3;
  88024. specularPower: number;
  88025. private _disableLighting;
  88026. disableLighting: boolean;
  88027. private _maxSimultaneousLights;
  88028. maxSimultaneousLights: number;
  88029. /**
  88030. * Defines the wind force.
  88031. */
  88032. windForce: number;
  88033. /**
  88034. * Defines the direction of the wind in the plane (X, Z).
  88035. */
  88036. windDirection: BABYLON.Vector2;
  88037. /**
  88038. * Defines the height of the waves.
  88039. */
  88040. waveHeight: number;
  88041. /**
  88042. * Defines the bump height related to the bump map.
  88043. */
  88044. bumpHeight: number;
  88045. /**
  88046. * Defines wether or not: to add a smaller moving bump to less steady waves.
  88047. */
  88048. private _bumpSuperimpose;
  88049. bumpSuperimpose: boolean;
  88050. /**
  88051. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  88052. */
  88053. private _fresnelSeparate;
  88054. fresnelSeparate: boolean;
  88055. /**
  88056. * Defines wether or not bump Wwves modify the reflection.
  88057. */
  88058. private _bumpAffectsReflection;
  88059. bumpAffectsReflection: boolean;
  88060. /**
  88061. * Defines the water color blended with the refraction (near).
  88062. */
  88063. waterColor: BABYLON.Color3;
  88064. /**
  88065. * Defines the blend factor related to the water color.
  88066. */
  88067. colorBlendFactor: number;
  88068. /**
  88069. * Defines the water color blended with the reflection (far).
  88070. */
  88071. waterColor2: BABYLON.Color3;
  88072. /**
  88073. * Defines the blend factor related to the water color (reflection, far).
  88074. */
  88075. colorBlendFactor2: number;
  88076. /**
  88077. * Defines the maximum length of a wave.
  88078. */
  88079. waveLength: number;
  88080. /**
  88081. * Defines the waves speed.
  88082. */
  88083. waveSpeed: number;
  88084. /**
  88085. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  88086. */
  88087. waveCount: number;
  88088. /**
  88089. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88090. * will avoid calculating useless pixels in the pixel shader of the water material.
  88091. */
  88092. disableClipPlane: boolean;
  88093. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88094. private _mesh;
  88095. private _refractionRTT;
  88096. private _reflectionRTT;
  88097. private _reflectionTransform;
  88098. private _lastTime;
  88099. private _lastDeltaTime;
  88100. private _useLogarithmicDepth;
  88101. private _waitingRenderList;
  88102. private _imageProcessingConfiguration;
  88103. private _imageProcessingObserver;
  88104. /**
  88105. * Gets a boolean indicating that current material needs to register RTT
  88106. */
  88107. get hasRenderTargetTextures(): boolean;
  88108. /**
  88109. * Constructor
  88110. */
  88111. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88112. get useLogarithmicDepth(): boolean;
  88113. set useLogarithmicDepth(value: boolean);
  88114. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88115. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88116. addToRenderList(node: any): void;
  88117. enableRenderTargets(enable: boolean): void;
  88118. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88119. get renderTargetsEnabled(): boolean;
  88120. needAlphaBlending(): boolean;
  88121. needAlphaTesting(): boolean;
  88122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88123. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88124. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88125. private _createRenderTargets;
  88126. getAnimatables(): BABYLON.IAnimatable[];
  88127. getActiveTextures(): BABYLON.BaseTexture[];
  88128. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88129. dispose(forceDisposeEffect?: boolean): void;
  88130. clone(name: string): WaterMaterial;
  88131. serialize(): any;
  88132. getClassName(): string;
  88133. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88134. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88135. }
  88136. }
  88137. declare module BABYLON {
  88138. /** @hidden */
  88139. export var asciiartPixelShader: {
  88140. name: string;
  88141. shader: string;
  88142. };
  88143. }
  88144. declare module BABYLON {
  88145. /**
  88146. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88147. *
  88148. * It basically takes care rendering the font front the given font size to a texture.
  88149. * This is used later on in the postprocess.
  88150. */
  88151. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88152. private _font;
  88153. private _text;
  88154. private _charSize;
  88155. /**
  88156. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88157. */
  88158. get charSize(): number;
  88159. /**
  88160. * Create a new instance of the Ascii Art FontTexture class
  88161. * @param name the name of the texture
  88162. * @param font the font to use, use the W3C CSS notation
  88163. * @param text the caracter set to use in the rendering.
  88164. * @param scene the scene that owns the texture
  88165. */
  88166. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88167. /**
  88168. * Gets the max char width of a font.
  88169. * @param font the font to use, use the W3C CSS notation
  88170. * @return the max char width
  88171. */
  88172. private getFontWidth;
  88173. /**
  88174. * Gets the max char height of a font.
  88175. * @param font the font to use, use the W3C CSS notation
  88176. * @return the max char height
  88177. */
  88178. private getFontHeight;
  88179. /**
  88180. * Clones the current AsciiArtTexture.
  88181. * @return the clone of the texture.
  88182. */
  88183. clone(): AsciiArtFontTexture;
  88184. /**
  88185. * Parses a json object representing the texture and returns an instance of it.
  88186. * @param source the source JSON representation
  88187. * @param scene the scene to create the texture for
  88188. * @return the parsed texture
  88189. */
  88190. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88191. }
  88192. /**
  88193. * Option available in the Ascii Art Post Process.
  88194. */
  88195. export interface IAsciiArtPostProcessOptions {
  88196. /**
  88197. * The font to use following the w3c font definition.
  88198. */
  88199. font?: string;
  88200. /**
  88201. * The character set to use in the postprocess.
  88202. */
  88203. characterSet?: string;
  88204. /**
  88205. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88206. * This number is defined between 0 and 1;
  88207. */
  88208. mixToTile?: number;
  88209. /**
  88210. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88211. * This number is defined between 0 and 1;
  88212. */
  88213. mixToNormal?: number;
  88214. }
  88215. /**
  88216. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88217. *
  88218. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88219. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88220. */
  88221. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88222. /**
  88223. * The font texture used to render the char in the post process.
  88224. */
  88225. private _asciiArtFontTexture;
  88226. /**
  88227. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88228. * This number is defined between 0 and 1;
  88229. */
  88230. mixToTile: number;
  88231. /**
  88232. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88233. * This number is defined between 0 and 1;
  88234. */
  88235. mixToNormal: number;
  88236. /**
  88237. * Instantiates a new Ascii Art Post Process.
  88238. * @param name the name to give to the postprocess
  88239. * @camera the camera to apply the post process to.
  88240. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88241. */
  88242. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88243. }
  88244. }
  88245. declare module BABYLON {
  88246. /** @hidden */
  88247. export var digitalrainPixelShader: {
  88248. name: string;
  88249. shader: string;
  88250. };
  88251. }
  88252. declare module BABYLON {
  88253. /**
  88254. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88255. *
  88256. * It basically takes care rendering the font front the given font size to a texture.
  88257. * This is used later on in the postprocess.
  88258. */
  88259. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88260. private _font;
  88261. private _text;
  88262. private _charSize;
  88263. /**
  88264. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88265. */
  88266. get charSize(): number;
  88267. /**
  88268. * Create a new instance of the Digital Rain FontTexture class
  88269. * @param name the name of the texture
  88270. * @param font the font to use, use the W3C CSS notation
  88271. * @param text the caracter set to use in the rendering.
  88272. * @param scene the scene that owns the texture
  88273. */
  88274. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88275. /**
  88276. * Gets the max char width of a font.
  88277. * @param font the font to use, use the W3C CSS notation
  88278. * @return the max char width
  88279. */
  88280. private getFontWidth;
  88281. /**
  88282. * Gets the max char height of a font.
  88283. * @param font the font to use, use the W3C CSS notation
  88284. * @return the max char height
  88285. */
  88286. private getFontHeight;
  88287. /**
  88288. * Clones the current DigitalRainFontTexture.
  88289. * @return the clone of the texture.
  88290. */
  88291. clone(): DigitalRainFontTexture;
  88292. /**
  88293. * Parses a json object representing the texture and returns an instance of it.
  88294. * @param source the source JSON representation
  88295. * @param scene the scene to create the texture for
  88296. * @return the parsed texture
  88297. */
  88298. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88299. }
  88300. /**
  88301. * Option available in the Digital Rain Post Process.
  88302. */
  88303. export interface IDigitalRainPostProcessOptions {
  88304. /**
  88305. * The font to use following the w3c font definition.
  88306. */
  88307. font?: string;
  88308. /**
  88309. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88310. * This number is defined between 0 and 1;
  88311. */
  88312. mixToTile?: number;
  88313. /**
  88314. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88315. * This number is defined between 0 and 1;
  88316. */
  88317. mixToNormal?: number;
  88318. }
  88319. /**
  88320. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88321. *
  88322. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88323. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88324. */
  88325. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88326. /**
  88327. * The font texture used to render the char in the post process.
  88328. */
  88329. private _digitalRainFontTexture;
  88330. /**
  88331. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88332. * This number is defined between 0 and 1;
  88333. */
  88334. mixToTile: number;
  88335. /**
  88336. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88337. * This number is defined between 0 and 1;
  88338. */
  88339. mixToNormal: number;
  88340. /**
  88341. * Instantiates a new Digital Rain Post Process.
  88342. * @param name the name to give to the postprocess
  88343. * @camera the camera to apply the post process to.
  88344. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88345. */
  88346. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88347. }
  88348. }
  88349. declare module BABYLON {
  88350. /** @hidden */
  88351. export var brickProceduralTexturePixelShader: {
  88352. name: string;
  88353. shader: string;
  88354. };
  88355. }
  88356. declare module BABYLON {
  88357. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88358. private _numberOfBricksHeight;
  88359. private _numberOfBricksWidth;
  88360. private _jointColor;
  88361. private _brickColor;
  88362. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88363. updateShaderUniforms(): void;
  88364. get numberOfBricksHeight(): number;
  88365. set numberOfBricksHeight(value: number);
  88366. get numberOfBricksWidth(): number;
  88367. set numberOfBricksWidth(value: number);
  88368. get jointColor(): BABYLON.Color3;
  88369. set jointColor(value: BABYLON.Color3);
  88370. get brickColor(): BABYLON.Color3;
  88371. set brickColor(value: BABYLON.Color3);
  88372. /**
  88373. * Serializes this brick procedural texture
  88374. * @returns a serialized brick procedural texture object
  88375. */
  88376. serialize(): any;
  88377. /**
  88378. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88379. * @param parsedTexture defines parsed texture data
  88380. * @param scene defines the current scene
  88381. * @param rootUrl defines the root URL containing brick procedural texture information
  88382. * @returns a parsed Brick Procedural BABYLON.Texture
  88383. */
  88384. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88385. }
  88386. }
  88387. declare module BABYLON {
  88388. /** @hidden */
  88389. export var cloudProceduralTexturePixelShader: {
  88390. name: string;
  88391. shader: string;
  88392. };
  88393. }
  88394. declare module BABYLON {
  88395. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88396. private _skyColor;
  88397. private _cloudColor;
  88398. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88399. updateShaderUniforms(): void;
  88400. get skyColor(): BABYLON.Color4;
  88401. set skyColor(value: BABYLON.Color4);
  88402. get cloudColor(): BABYLON.Color4;
  88403. set cloudColor(value: BABYLON.Color4);
  88404. /**
  88405. * Serializes this cloud procedural texture
  88406. * @returns a serialized cloud procedural texture object
  88407. */
  88408. serialize(): any;
  88409. /**
  88410. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88411. * @param parsedTexture defines parsed texture data
  88412. * @param scene defines the current scene
  88413. * @param rootUrl defines the root URL containing cloud procedural texture information
  88414. * @returns a parsed Cloud Procedural BABYLON.Texture
  88415. */
  88416. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88417. }
  88418. }
  88419. declare module BABYLON {
  88420. /** @hidden */
  88421. export var fireProceduralTexturePixelShader: {
  88422. name: string;
  88423. shader: string;
  88424. };
  88425. }
  88426. declare module BABYLON {
  88427. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88428. private _time;
  88429. private _speed;
  88430. private _autoGenerateTime;
  88431. private _fireColors;
  88432. private _alphaThreshold;
  88433. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88434. updateShaderUniforms(): void;
  88435. render(useCameraPostProcess?: boolean): void;
  88436. static get PurpleFireColors(): BABYLON.Color3[];
  88437. static get GreenFireColors(): BABYLON.Color3[];
  88438. static get RedFireColors(): BABYLON.Color3[];
  88439. static get BlueFireColors(): BABYLON.Color3[];
  88440. get autoGenerateTime(): boolean;
  88441. set autoGenerateTime(value: boolean);
  88442. get fireColors(): BABYLON.Color3[];
  88443. set fireColors(value: BABYLON.Color3[]);
  88444. get time(): number;
  88445. set time(value: number);
  88446. get speed(): BABYLON.Vector2;
  88447. set speed(value: BABYLON.Vector2);
  88448. get alphaThreshold(): number;
  88449. set alphaThreshold(value: number);
  88450. /**
  88451. * Serializes this fire procedural texture
  88452. * @returns a serialized fire procedural texture object
  88453. */
  88454. serialize(): any;
  88455. /**
  88456. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88457. * @param parsedTexture defines parsed texture data
  88458. * @param scene defines the current scene
  88459. * @param rootUrl defines the root URL containing fire procedural texture information
  88460. * @returns a parsed Fire Procedural BABYLON.Texture
  88461. */
  88462. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88463. }
  88464. }
  88465. declare module BABYLON {
  88466. /** @hidden */
  88467. export var grassProceduralTexturePixelShader: {
  88468. name: string;
  88469. shader: string;
  88470. };
  88471. }
  88472. declare module BABYLON {
  88473. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88474. private _grassColors;
  88475. private _groundColor;
  88476. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88477. updateShaderUniforms(): void;
  88478. get grassColors(): BABYLON.Color3[];
  88479. set grassColors(value: BABYLON.Color3[]);
  88480. get groundColor(): BABYLON.Color3;
  88481. set groundColor(value: BABYLON.Color3);
  88482. /**
  88483. * Serializes this grass procedural texture
  88484. * @returns a serialized grass procedural texture object
  88485. */
  88486. serialize(): any;
  88487. /**
  88488. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88489. * @param parsedTexture defines parsed texture data
  88490. * @param scene defines the current scene
  88491. * @param rootUrl defines the root URL containing grass procedural texture information
  88492. * @returns a parsed Grass Procedural BABYLON.Texture
  88493. */
  88494. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88495. }
  88496. }
  88497. declare module BABYLON {
  88498. /** @hidden */
  88499. export var marbleProceduralTexturePixelShader: {
  88500. name: string;
  88501. shader: string;
  88502. };
  88503. }
  88504. declare module BABYLON {
  88505. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88506. private _numberOfTilesHeight;
  88507. private _numberOfTilesWidth;
  88508. private _amplitude;
  88509. private _jointColor;
  88510. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88511. updateShaderUniforms(): void;
  88512. get numberOfTilesHeight(): number;
  88513. set numberOfTilesHeight(value: number);
  88514. get amplitude(): number;
  88515. set amplitude(value: number);
  88516. get numberOfTilesWidth(): number;
  88517. set numberOfTilesWidth(value: number);
  88518. get jointColor(): BABYLON.Color3;
  88519. set jointColor(value: BABYLON.Color3);
  88520. /**
  88521. * Serializes this marble procedural texture
  88522. * @returns a serialized marble procedural texture object
  88523. */
  88524. serialize(): any;
  88525. /**
  88526. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88527. * @param parsedTexture defines parsed texture data
  88528. * @param scene defines the current scene
  88529. * @param rootUrl defines the root URL containing marble procedural texture information
  88530. * @returns a parsed Marble Procedural BABYLON.Texture
  88531. */
  88532. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88533. }
  88534. }
  88535. declare module BABYLON {
  88536. /** @hidden */
  88537. export var normalMapProceduralTexturePixelShader: {
  88538. name: string;
  88539. shader: string;
  88540. };
  88541. }
  88542. declare module BABYLON {
  88543. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88544. private _baseTexture;
  88545. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88546. updateShaderUniforms(): void;
  88547. render(useCameraPostProcess?: boolean): void;
  88548. resize(size: any, generateMipMaps: any): void;
  88549. get baseTexture(): BABYLON.Texture;
  88550. set baseTexture(texture: BABYLON.Texture);
  88551. /**
  88552. * Serializes this normal map procedural texture
  88553. * @returns a serialized normal map procedural texture object
  88554. */
  88555. serialize(): any;
  88556. /**
  88557. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88558. * @param parsedTexture defines parsed texture data
  88559. * @param scene defines the current scene
  88560. * @param rootUrl defines the root URL containing normal map procedural texture information
  88561. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88562. */
  88563. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88564. }
  88565. }
  88566. declare module BABYLON {
  88567. /** @hidden */
  88568. export var perlinNoiseProceduralTexturePixelShader: {
  88569. name: string;
  88570. shader: string;
  88571. };
  88572. }
  88573. declare module BABYLON {
  88574. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88575. time: number;
  88576. timeScale: number;
  88577. translationSpeed: number;
  88578. private _currentTranslation;
  88579. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88580. updateShaderUniforms(): void;
  88581. render(useCameraPostProcess?: boolean): void;
  88582. resize(size: any, generateMipMaps: any): void;
  88583. /**
  88584. * Serializes this perlin noise procedural texture
  88585. * @returns a serialized perlin noise procedural texture object
  88586. */
  88587. serialize(): any;
  88588. /**
  88589. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88590. * @param parsedTexture defines parsed texture data
  88591. * @param scene defines the current scene
  88592. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88593. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88594. */
  88595. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88596. }
  88597. }
  88598. declare module BABYLON {
  88599. /** @hidden */
  88600. export var roadProceduralTexturePixelShader: {
  88601. name: string;
  88602. shader: string;
  88603. };
  88604. }
  88605. declare module BABYLON {
  88606. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88607. private _roadColor;
  88608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88609. updateShaderUniforms(): void;
  88610. get roadColor(): BABYLON.Color3;
  88611. set roadColor(value: BABYLON.Color3);
  88612. /**
  88613. * Serializes this road procedural texture
  88614. * @returns a serialized road procedural texture object
  88615. */
  88616. serialize(): any;
  88617. /**
  88618. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88619. * @param parsedTexture defines parsed texture data
  88620. * @param scene defines the current scene
  88621. * @param rootUrl defines the root URL containing road procedural texture information
  88622. * @returns a parsed Road Procedural BABYLON.Texture
  88623. */
  88624. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88625. }
  88626. }
  88627. declare module BABYLON {
  88628. /** @hidden */
  88629. export var starfieldProceduralTexturePixelShader: {
  88630. name: string;
  88631. shader: string;
  88632. };
  88633. }
  88634. declare module BABYLON {
  88635. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88636. private _time;
  88637. private _alpha;
  88638. private _beta;
  88639. private _zoom;
  88640. private _formuparam;
  88641. private _stepsize;
  88642. private _tile;
  88643. private _brightness;
  88644. private _darkmatter;
  88645. private _distfading;
  88646. private _saturation;
  88647. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88648. updateShaderUniforms(): void;
  88649. get time(): number;
  88650. set time(value: number);
  88651. get alpha(): number;
  88652. set alpha(value: number);
  88653. get beta(): number;
  88654. set beta(value: number);
  88655. get formuparam(): number;
  88656. set formuparam(value: number);
  88657. get stepsize(): number;
  88658. set stepsize(value: number);
  88659. get zoom(): number;
  88660. set zoom(value: number);
  88661. get tile(): number;
  88662. set tile(value: number);
  88663. get brightness(): number;
  88664. set brightness(value: number);
  88665. get darkmatter(): number;
  88666. set darkmatter(value: number);
  88667. get distfading(): number;
  88668. set distfading(value: number);
  88669. get saturation(): number;
  88670. set saturation(value: number);
  88671. /**
  88672. * Serializes this starfield procedural texture
  88673. * @returns a serialized starfield procedural texture object
  88674. */
  88675. serialize(): any;
  88676. /**
  88677. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88678. * @param parsedTexture defines parsed texture data
  88679. * @param scene defines the current scene
  88680. * @param rootUrl defines the root URL containing startfield procedural texture information
  88681. * @returns a parsed Starfield Procedural BABYLON.Texture
  88682. */
  88683. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88684. }
  88685. }
  88686. declare module BABYLON {
  88687. /** @hidden */
  88688. export var woodProceduralTexturePixelShader: {
  88689. name: string;
  88690. shader: string;
  88691. };
  88692. }
  88693. declare module BABYLON {
  88694. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88695. private _ampScale;
  88696. private _woodColor;
  88697. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88698. updateShaderUniforms(): void;
  88699. get ampScale(): number;
  88700. set ampScale(value: number);
  88701. get woodColor(): BABYLON.Color3;
  88702. set woodColor(value: BABYLON.Color3);
  88703. /**
  88704. * Serializes this wood procedural texture
  88705. * @returns a serialized wood procedural texture object
  88706. */
  88707. serialize(): any;
  88708. /**
  88709. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88710. * @param parsedTexture defines parsed texture data
  88711. * @param scene defines the current scene
  88712. * @param rootUrl defines the root URL containing wood procedural texture information
  88713. * @returns a parsed Wood Procedural BABYLON.Texture
  88714. */
  88715. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88716. }
  88717. }